<jupyter_start><jupyter_text>Reading DFlowFM Map OutputDemonstrate basic loading and plotting of map output from DFlowFM. This example uses sample output which is not part of the stompyexample data.<jupyter_code>import matplotlib.pyplot as plt
import xarray as xr
from stompy.model.delft import dfm_grid
from stompy.grid import unstructured_grid
%matplotlib notebook<jupyter_output><empty_output><jupyter_text>Open the NetCDF Map file<jupyter_code>map_nc='/home/emma/test_run/r14_map.nc'

# This pulls the grid topology/geometry out of the netcdf.
# The netcdf files aren't quite ugrid compliant, so we have
# to use DFMGrid, specific to Flow FM's version of netcdf
grid=dfm_grid.DFMGrid(map_nc)

# The xarray dataset is used to access the variables which
# will be plotted on the grid
ds=xr.open_dataset(map_nc)
fig,axs=plt.subplots(1,3,sharex=True,sharey=True,figsize=(12,6))

# To make it a bit faster, supply a clipping box:
clip=(543535., 553384.,4176205., 4202129.)

grid.plot_edges(ax=axs[0],clip=clip)
grid.plot_cells(ax=axs[1],clip=clip)
grid.plot_nodes(ax=axs[2],clip=clip)

# Select the second timestep, top layer of output.
# .values returns a numpy array, dropping the XArray wrapping
surf_salt=ds.sa1.isel(time=1,laydim=0).values

fig,ax=plt.subplots(figsize=(10,8))
# plot_* commands typically return a collection
coll=grid.plot_cells(values=surf_salt)
# Doctor up the presentation a bit:
coll.set_edgecolor('face')
plt.colorbar(coll,label='Salinity (ppt)')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10053262316910785, 'fraction_numerical': 0.02796271637816245, 'mean_word_length': 6.747422680412371, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '507950', 'license': 'MIT', 'n_tokens_mistral': 571, 'n_tokens_neox': 531, 'n_words': 146, 'path': 'examples/plot_dflow_map.ipynb', 'repo_name': 'oneconcern/stompy', 'size': '1502'}