gridmarthe.load_marthe_grid

gridmarthe.load_marthe_grid(filename, varname=None, fpastp=None, dates=None, drop_nan=False, nan_value=None, xyfactor=1.0, shallow_only=False, add_col_row=False, add_id_grid=False, title=None, var_attrs={}, model_attrs={'domain': 'FR-France', 'projection': 'epsg:27572', 'resolution_units': 'm'}, engine='xarray', verbose=False, **kwargs)[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 zone is 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, optional) – variable to access in martgrid file, e.g CHARGE for 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, optional) – A pastp file to read for dates

  • dates (sequence, optional) – 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

  • drop_nan (bool, optional) – Drop nan values (corresponding to nan_value) in xarray object to return. Default is False (keep nan values).

  • nan_value (float, optional) –

    A code value for nan values. The default value is inferred from field name. E.g. of default nan values:

    • hydraulic conductivity: 0 or -9999. (Warning: a value of +9999. is not a NaN value for hydraulic conductivity. See Marthe User Guide for explanation about this code, refering here to impervious layer);

    • hydraulic head: 9999.;

    • groundwater flow: 0. (9999. is used as special value for this field);

    • any other: 9999.

  • xyfactor (int or float, optional) – factor to transform X and Y values. e.g.: 1000 to convert km XY to meters. Default is 1.

  • shallow_only (bool, optional) – Boolean to read only the first layer. Default is False.

  • add_col_row (bool, optional) – Add columns (col) and rows (lig) index (from 1 to n), Default is False.

  • add_id_grid (bool, optional) – Add grid id (from 0 to n), useful for nested grids. 0 is main grid, Default is False

  • title (str , optional) – Title for grid attributes. Default is None (not used)

  • var_attrs (dict, optional) – Dictionnary of attributes to add to variable DataArray.

  • model_attrs (dict, optional) –

    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, optional) – 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, optional) – 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.