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).

Parameters:
ds_outcropxarray.Dataset

output of gridmarthe.get_surface_layer()

figmatplotlib figure, Optional.

if provided, data are plotted on this figure, otherwise fig, ax instances will be created

axmatplotlib axe, Optional.

if provided, data are plotted on this axis, otherwise fig, ax instances will be created

cbar_widthstr, Optional.

width of colorbar, as a percentage of the main axis. Default is ‘3’

labelslist, Optional.

labels for layers in colorbar

file_outstr, Optional.

If not None (default), file name to write plot

showbool, 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

Notes

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)

Examples

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))