| |
- exit(i)
- Exit properly the program
- extrude(mesh_file_name, bath_file_name, nb_layers=None, z_layers=None, layers_function=None, mesh_file_name_out='', factor_show=0, addLayerDepthAtBot=10000000000.0, periodicity=None)
- fetch_ftp(file_name, data_dir=None)
- This function downloads some data from the SLIM servers if available. The data is downloaded in the user global_data_directory. Data is only downloaded if it does not exist locally or is older than the server data.
global_data_directory is by default ~/.cache/slim_data/
- get_data_from_netcdf(nc_file_name, variable_name)
- Return the array containing the values of the variable in the nectdf file (SLIM format)
keyword arguments:
* nc_file_name
path to the netcdf file (.nc format)
* variable_name
name of the variable in the netcdf file
- get_distance(region, physical_tags, dmax=1000)
- Return the minimum distance from each node on the region to the physical tags. The index of the 1-D array returned is the nodal index, same as Region.coordinates
keyword arguments:
* region
slimPre Region object of the nodes on which compute the distance
* physical_tags
vector containing the physical tags from which the minimum distance will be computed
* dmax : float (default: 1000)
points will be inserted on lines every dmax interval
- interpolate_from_structured_file(nodes, structured_file, fill_value=-9999, transpose_matrix=False)
- Interpolates the values from a structured file of gmsh type:
ox oy oz
dx dy dz
nx ny nz
val11 val12 ...
val21 val22 ...
...
This module is only available in 2D !
keyword arguments:
* nodes
coordinates of the nodes to interpolate at (from Region or Coordinate_system)
* structured_file
name of the file containing the structured data (binary files should end with '.bin' extension)
* fill_value
default value given to a point outside the structured grid
* transpose_matrix
boolean assessing if the matrix should be transposed (Default: False) (True if nx is the number of lines and ny is the number of columns)
- interpolate_from_structured_grid(x, y, ox, oy, dx, dy, data, fill_value=-9999.0)
- Interpolates the values from a structured grid
keyword arguments:
* x
list of the x-coordinates of all the points to interpolate at
* y
list of the y-coordinates of all the points to interpolate at
* ox
x-origin of the structured data
* oy
y-origin of the structured data
* dx
x-step of the structured data
* dy
y-step of the structured data
* data
structured grid
* fill_value
default value given to a point outside the structured grid
- make_directory(data_dir)
- Create data_dir directory if it does not exist yet
- mesh_shp(shp_inputs, lon, lat, mesh_size, mesh_size_min, output, projection='+latlong +ellps=WGS84', boundary_names={})
- Generate a mesh file in gmsh .msh file format (http://gmsh.info/). The mesh is generated on a sphere of radius 1. The mesh size
should be specified on this sphere (i.e. distances should be divided by the earth radius)
arguments:
* shp_inputs : list of string
vector of path to files in the ESRI shape file format. The shape files can be composed of point, lines or polygons. The projection
used in the shape files should be longitude-latitude (in degrees).
* lon, lat : float
position of one point inside the domain, the mesh region is the close surface containing this point.
* mesh_size : (float x, float y, float z) -> float
callback to get the desired element size, (on a sphere of radius 1) at one point on this sphere
* mesh_size_min : float
minimum value of the mesh size (approximatively the minimum value returned by mesh_size) on a sphere of radius 1
* output : string
name of the output file
* projection : string
description of the projection used in the output file in the libproj "+" format (the mesh itself is generated on the sphere)
* boundary_name : dictionary of (int, string)
to assign physicals names to the boundary elements of the mesh, a field (of type integer64) called "entity" should be present in the shape files. Then this parameter can be used to map the values of this field to physical names
- netcdf_to_msh(mesh_file_name, nc_file_name, variable_name, export_file_name, time=0)
- Export a field in the netcdf format to msh format.
keyword arguments:
* mesh_file_name
path to the mesh file (.msh format)
* nc_file_name
path to the netcdf file (.nc format)
* variable_name
name of the variable in the netcdf file
* export_file_name
path to the field name (.idx format)
* time
time at which the data will be exported in msh format (default: 0)
- partition_id()
- Return the number of the current partition as a string
- partition_mesh(mesh_file_name, partitioned_mesh_file_name)
- Partition the mesh
keyword arguments:
* mesh_file_name
path to the mesh file (.msh format)
* partitioned_mesh_file_name
name where the partitioned mesh is stored.
- partition_nb()
- Return the number of partitions used as a string
- read_temporal_serie(file_name, time=None, output_netcdf=None)
- Return a temporal serie from a text data file.
If time is given, the function returns a vector with the data interpolated
at the instants of time object.
If time is not given, the function returns a tuple (time, data), where
time is a Time object with the instants of the data file
data is a vector with the values of the data file
keyword arguments:
* file_name
path to the file.
Data must be given in the following format:
1991-06-10 00:00:00, 20.7
1991-06-11 00:00:00, 40.2
1991-06-15 00:00:00, 13.8
Different date must be strictly increasing but the time step
does not have to be constant
* time
time is a slimPre Time object.
if time is given, data will be interpolated to the time instants.
* output_netcdf
output_netcdf = ('netcdf_file_name', 'variable_name')
if output_netcdf is given, the data are written in a netcdf file
- residual_flow(region, flow, bathymetry, data_file_name=None)
- Set a residual flow
It will return the velocity (u, v) such that speeds at all the nodes are constant and the velocity is normal to the boundary. The total transport (in m^3 s^-1) is equal to the given flow.
The physical tags of the region object must be boundary physical tags.
keyword arguments:
* region
slimPre Region object on which put the data
* flow
value of the flow crossing the region (must be a boundary region), in m^3 s^-1
* bathymetry
bathymetry in netcdf format or msh format. It is necessary to compute the transport
* data_file_name
name of the netcdf data file where the residual flow is exported (optional)
- set_global_data_directory(path)
- Edit the global_data_directory
- smooth_bathymetry(mesh, bathymetry, output_file_name, coefficient=0.5, transform_p0=True)
- Smooth the bathymetry in order to locally reduce the noise in the momentum
keyword arguments:
* mesh
slimPre mesh object
* bathymetry
bathymetry file
Format:
* tuple containing the raw bathymetry data file (.nc format) and the name of the variable bathymetry
* bathymetry mesh file (.msh or .idx)
* output_file_name
name of the file name containing the smooth bathymetry. The format is netcdf (if transform_p0 = False) or idx (if transform_p0 = True).
* coefficient
coefficient for the smoothing algorithm (default: 0.5). This forbids the bathymetry from moving from more than 100*coefficient % on a single element
* transform_p0
flag to transform the bathymetry to a bathymetry constant per element. This gives a good stability and has negligible impact the results (default: True)
- tpxo_tide(region, time, data_file_name=None, export_as_transport=True)
- Give TPXO tides data
This function will download the files tpxo and generate the data at the requested time steps.
It will return the tpxo tides as variables (ssh, u, v) with u and v as transport (default) or velocity
keyword arguments:
* region
slimPre Region object on which put the data
* time
Time object of the instant at which put the data
* data_file_name
name of the netcdf data file where tides are exported (optional)
* export_transport
flag to specify whether exports are water transport [m^2/s] (True) or velocity [m/s] (False) (default: True)
- write_file(file_name, region=None, time=None, data=[])
- Create a SLIM netcdf file, standard input for SLIM simulations.
keyword arguments:
* file_name
name of the netcdf file to write
* region
slimPre Region object (optional).
* time
slimPre Time object (optional).
* data
data is a list of data tuples. Each tuple follows the form
("data_name", data_array)
where data_array is an array of n lines and m columns, n being the number of nodes in the region and m being the number of time steps in the time.
|