You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When slicing a dataset, it is very complex to get the variables without depth component (like bedlevel, waterlevel) out of it. An example for bedlevel is given below. The desired result is the bed level along the slice line_array in a line plot with distance along the line_array on the xaxis. This should be simplified.
import matplotlib.pyplot as plt
plt.close('all')
import numpy as np
import dfm_tools as dfmt
file_nc = dfmt.data.fm_grevelingen_map(return_filepath=True)
uds = dfmt.open_partitioned_dataset(file_nc)
line_array = np.array([[ 53181.96942503, 424270.83361629],
[ 55160.15232593, 416913.77136685]])
# fig, ax = plt.subplots()
# uds['mesh2d_flowelem_bl'].ugrid.plot(cmap='jet') #TODO: default is edgecolor='face', should work even better with edgecolor='none', but that results in seethrough edges anyway, report to matplotlib?
# ax.plot(line_array[:,0],line_array[:,1],'b',linewidth=3)
xr_crs_ugrid = dfmt.polyline_mapslice(uds.isel(time=0).max(dim="nmesh2d_layer").max(dim="nmesh2d_interface"), line_array)
fig, ax = plt.subplots()
xr_crs_ugrid['mesh2d_flowelem_bl'].ugrid.plot()
fig, ax = plt.subplots()
xr_crs_ugrid['mesh2d_flowelem_bl'].plot()
# s_array = xr_crs_ugrid.grid.face_coordinates[:,0] #contains nans for some reason
s_array_nonan = xr_crs_ugrid.grid.node_coordinates[:,0][xr_crs_ugrid.grid.face_node_connectivity].mean(axis=1)
bed_array = xr_crs_ugrid['mesh2d_flowelem_bl'].to_numpy()
fig, ax = plt.subplots()
ax.plot(s_array_nonan,bed_array)
Looks nice but not desired:
Desired, but complex workaround needed at this moment:
A simpler alternative, but results in degrees on x-axis for spherical models:
When slicing a dataset, it is very complex to get the variables without depth component (like bedlevel, waterlevel) out of it. An example for bedlevel is given below. The desired result is the bed level along the slice
line_array
in a line plot with distance along theline_array
on the xaxis. This should be simplified.Looks nice but not desired:
Desired, but complex workaround needed at this moment:
A simpler alternative, but results in degrees on x-axis for spherical models:
The text was updated successfully, but these errors were encountered: