gridmarthe.plot_outcrop

gridmarthe.plot_outcrop(ds_outcrop, fig=None, ax=None, cbar_width='3', labels=None, file_out=None, show=False, **kwargs)[source]

Usefull function to plot outcrop layers of a marthe (multilayer) grid

There is two mode implementend yet, using xr.plot or gpd.plot (useful for nested grid).

To use this function, ds provided need to have a z variable (i.e model used need to be multilayer) and user need to assign coords before and keep the z dimension as a variable (see Note).

Note

If input is a xarray.Dataset instance, ds_outcrop need to get coords before but keep z as a variable. To do so, use:

>>> gm.assign_coords(ds_outcrop, add_lay=False)
Parameters:
  • ds_outcrop (xr.Dataset) – output of gridmarthe.get_surface_layer()

  • fig (matplotlib figure, Optional.) – if provided, data are plotted on this figure, otherwise fig, ax instances will be created

  • ax (matplotlib axe, Optional.) – if provided, data are plotted on this axis, otherwise fig, ax instances will be created

  • cbar_width (str, Optional.) – width of colorbar, as a percentage of the main axis. Default is ‘3’

  • labels (list, Optional.) – labels for layers in colorbar

  • file_out (str, Optional.) – If not None (default), file name to write plot

  • show (bool, Optional.) – Show result (plt.show()), default is False.

  • **kwargs – Any keywords argument to pass to either xarray.Dataset.plot.pcolormesh() or geopandas.GeoDataFrame.plot().

Returns:

fig, ax, ax_cbar if not show, otherwise return None

Example

xarray version:

>>> ds_surf = gm.get_surface_layer(ds)
>>> gm.plot_outcrop(gm.assign_coords(ds_surf, add_lay=False))

geopandas version:

>>> ds_surf = gm.get_surface_layer(ds)
>>> gm.plot_outcrop(gm.to_geodataframe(ds_surf))