gridmarthe.grid.processing.geometry
Module to manage geometry attributes of Marthe grids/domain
- gridmarthe.grid.processing.geometry.get_active_mask(ds, varname='permeab', nanval=[-9999.0, 0.0], as_array=False, only_mask=False, shp_file=None)[source]
Get the mask of active domain from hydraulic conductivity variable
This function (i) get the active mask as a 0/1 array and optionally (ii) filter the dataset on valid values and dissolve results to get a mask shape
Input ds should be the permh dataset (read from permh file, ie Horizontal hydraulic conductivity, without the dropnan option).
- 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.) – Option to get result as a xr.Dataset and not geodataframe. Default is False.
only_mask (bool, optional) – filter ds on active mask. Default is False, returns a dataset with ‘ibound’ variable set to 1 (active domain) or 0.
shp_file (str, optional.) – if set (and not as_array), used to stored result in a file.
- Returns:
xr.Dataset with ibound field, or gpd.GeoDataFrame of active domain if as_array
is set to False.
- gridmarthe.grid.processing.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.grid.processing.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.grid.processing.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.