gridmarthe.load_marthe_grid
- gridmarthe.load_marthe_grid(filename, varname=None, fpastp=None, dates=None, nanval=None, drop_nan=False, xyfactor=1.0, shallow_only=False, keepligcol=False, add_id_grid=False, title=None, var_attrs={}, model_attrs={'domain': 'FR-France', 'projection': 'epsg:27572', 'resolution_units': 'm'}, engine='xarray', verbose=False)[source]
Read Marthe Grid File as xarray.Dataset
The gridfile is read as a sequence: the variable for all layer for main grid, then all layer for nested grids, is stored in a 1D vector for every timestep. A single spatial identifier
zoneis used to map spatial coordinates.Before plot operations, user can assign coordinates (set x,y as dimension coordinates and drop zone) to get 2-D arrays (or 3D arrays if multilayer) for every timesteps.
- Parameters:
filename (str) – A path to marthegrid file (.permh, .out, etc.)
varname (str, Optionnal) – variable to access in martgrid file, e.g
CHARGEfor groundwater head. See marthegrid file content. if None is passed (default), function will scan all varnames in filename and keep first only if ‘all’ is passed, function will scan all varnames in filename and keep all. All datavars are added to dataset, using recursive call to func if wrong variable name is passed, empty data will be returned.fpastp (str, Optionnal) – A pastp file to read for dates
dates (sequence, Optionnal) – Can be a pd.date_range, pd.Series, pd.DatetimeIndex, np.array or list of datetime/np.datetime objects. If no dates (or no fpastp) is provided, a fake sequence of dates from 1850 to 1900 will be used for xarray object
nanval (float, Optionnal) – A code value for nan values. Default is 9999.
drop_nan (bool, Optionnal) – Drop nan values (corresponding to nanval) in xarray object to return. Default is False (keep nan values).
xyfactor (int or float, Optionnal) – factor to transform X and Y values. e.g.: 1000 to convert km XY to meters. Default is 1.
shallow_only (bool, Optionnal) – Boolean to read only the first layer. Default is False.
keepligcol (bool, Optionnal) – Add columns (col) and rows (lig) index (from 1 to n), Default is False.
add_id_grid (bool, Optionnal) – Add grid id (from 0 to n), useful for nested grids. 0 is main grid, Default is False
title (str , Optionnal) – Title for grid attributes. Default is None (not used)
var_attrs (dict, Optionnal) – Dictionnary of attributes to add to variable DataArray.
model_attrs (dict, Optionnal) –
Dictionnary of attributes to add to Dataset. by default, gis attrs are added and can be modified
>>> { ... 'resolution_units': 'm', ... 'projection' : 'epsg:27572', ... 'domain' : 'FR-France' ... }
engine (str, Optionnal) – Engine to use for returned object. Default is ‘xarray’, which return xarray.Dataset object. Another option is ‘numpy’, which return a list of numpy arrays : [zvar, zdates, isteps, zxcol, zylig, zdxlu, zdylu, ztitle, dims]
verbose (bool, Optionnal) – Print some information about execution in stdout. Default is False.
- Returns:
ds (xr.Dataset) – A xarray.Dataset object containing values and attributes read from Marthe grid file.