gridmarthe.operasem.geometry
Module to manage geometry attributes of Marthe grids/domain
- gridmarthe.operasem.geometry.get_active_mask(ds, varname='permeab', nanval=[-9999.0, 0.0], as_array=False, shp_file=None)[source]
Filter dataset on non-nan values, and dissolve results to get a mask shape
Input ds should be the permh dataset (read from permh file, ie Horizontal hydraulic conductivity).
- Parameters:
ds (xr.Dataset)
varname (str, optional) – default is ‘permeab’
nanval (float or list, optional.) – default are ‘permeab’ nan values : 0,-9999.
as_array (bool, optional.) – default is False. Option to get result as a xr.Dataset and not geodataframe.
shp_file (str, optional.) – if set (and not as_array), used to stored result in a file.
- Returns:
either a xr.Dataset filter to mask array or a
gpd.GeoDataFrame with active domain.
- gridmarthe.operasem.geometry.compute_geometry(topo, hsubs, mask=None)[source]
Compute geometry attributes of Marthe domain
- Parameters:
topo (xr.Dataset) – Topgraphy of the domain (stored in the first layer, in Marthe Conventions).
hsubs (xr.Dataset) – altitude of all the lower boundary in the domain
mask (numpy.array) – list of indices (zone) to keep, if None (default) not used.
- Returns:
xr.Dataset – A new dataset with layer, depth, thickness, upper/lower altitude.
- gridmarthe.operasem.geometry.get_surface_layer(ds, aquif_layers=None)[source]
Compute surface mask of marthe domain
This function return min layer for every zone of a grimarthe dataset with z coords A subset on specific (aquifers) layers can be performed with aquif_layers. if set, aquif_layers must be a sequence (list, tuple, array) of layer (list of int).
This should be used to get a surface mask, ie get zone to filter a dataset.
Examples
>>> mask = get_surface_layer(ds, [6,8,9]) >>> ds_surf = ds.sel(zone=mask.zone.data)
- gridmarthe.operasem.geometry.search_zone(ds, i=None, j=None, x=None, y=None, z=None)[source]
search zone number in marthe grid, based on xy or ij (col, lig)
This function can be used to search zone number from coordinates or indices. You must provide either (i,j) or (x,y).
Note
if ds is multilayered, you need to provide the layer you want (z arg., int type)
ds should contains dx and dy
ds should not have assigned coords (x and y are variables, zone is the dimension
coordinates (with time))
- Parameters:
ds (xr.Dataset) – dataset with zone, x, y, dx, dy variables.
i (int, optional) – column index to search zone.
j (int, optional) – row index to search zone.
x (float, optional) – x coordinate to search zone.
y (float, optional) – y coordinate to search zone.
z (int, optional) – layer index to search zone. If not provided, all layers are considered.
- Returns:
zone (xr.Dataset) – dataset with zone variable, containing the zone number(s) corresponding to the provided coordinates. If no zone is found, an empty dataset is returned.
If multiple zones are found, all of them are returned.