This issue is more to open a discussion on naming conventions.
My Dataset has the following format:
Dimensions: time: 7272 node: 301572 face: 588314 max_no_vertices: 3
Coordinates:
longitude (node) float32 ...
latitude (node) float32 ...
time (time) datetime64[ns] 2023-01-01 ... 2023-10-30T23:00:00
Data variables:
u (time, node) float32 ...
v (time, node) float32 ...
elev (time, node) float32 ...
face_nodes (face, max_no_vertices) int32 ...
When I try to plot:
plot_map = thalassa.plot(
ds=ds.isel(time=-1),
variable="max_elev",
clim_min=0,
clim_max=1,
clabel="meters",
cmap = 'jet'
)
I get the following error:
KeyError Traceback (most recent call last)
Cell In[22], [line 1](vscode-notebook-cell:?execution_count=22&line=1)
----> [1](vscode-notebook-cell:?execution_count=22&line=1) plot_map = thalassa.plot(
[2](vscode-notebook-cell:?execution_count=22&line=2) ds=ds.isel(time=-1),
[3](vscode-notebook-cell:?execution_count=22&line=3) variable="max_elev",
[4](vscode-notebook-cell:?execution_count=22&line=4) clim_min=0,
[5](vscode-notebook-cell:?execution_count=22&line=5) clim_max=1,
[6](vscode-notebook-cell:?execution_count=22&line=6) clabel="meters",
[7](vscode-notebook-cell:?execution_count=22&line=7) cmap = 'jet'
[8](vscode-notebook-cell:?execution_count=22&line=8) )
File ~/work/gist/Validation_Protocol/.venv/lib/python3.11/site-packages/thalassa/plotting.py:153, in plot(ds, variable, bbox, title, cmap, colorbar, clabel, clim_min, clim_max, x_range, y_range, show_mesh)
[93].venv/lib/python3.11/site-packages/thalassa/plotting.py:93) """
[94].venv/lib/python3.11/site-packages/thalassa/plotting.py:94) Return the plot of the specified `variable`.
[95].venv/lib/python3.11/site-packages/thalassa/plotting.py:95)
(...)
[149].venv/lib/python3.11/site-packages/thalassa/plotting.py:149)
[150].venv/lib/python3.11/site-packages/thalassa/plotting.py:150) """
[151].venv/lib/python3.11/site-packages/thalassa/plotting.py:151) import holoviews as hv
--> [153].venv/lib/python3.11/site-packages/thalassa/plotting.py:153) ds = normalization.normalize(ds)
[154].venv/lib/python3.11/site-packages/thalassa/plotting.py:154) _sanity_check(ds=ds, variable=variable)
[155].venv/lib/python3.11/site-packages/thalassa/plotting.py:155) if bbox:
File ~/work/gist/Validation_Protocol/.venv/lib/python3.11/site-packages/thalassa/normalization.py:203, in normalize(ds)
[201].venv/lib/python3.11/site-packages/thalassa/normalization.py:201) logger.debug("Dataset normalization: Started")
[202].venv/lib/python3.11/site-packages/thalassa/normalization.py:202) fmt = infer_format(ds)
--> [203].venv/lib/python3.11/site-packages/thalassa/normalization.py:203) normalizer_func = NORMALIZE_DISPATCHER[fmt]
[204].venv/lib/python3.11/site-packages/thalassa/normalization.py:204) normalized_ds = normalizer_func(ds)
[205].venv/lib/python3.11/site-packages/thalassa/normalization.py:205) # Handle quad elements
[206].venv/lib/python3.11/site-packages/thalassa/normalization.py:206) # Splitting quad elements to triangles, means that the number of faces increases
[207].venv/lib/python3.11/site-packages/thalassa/normalization.py:207) # There are two options:
(...)
[210].venv/lib/python3.11/site-packages/thalassa/normalization.py:210) # I'd rather avoid altering the values of the provided netcdf file therefore we go for option #2,
[211].venv/lib/python3.11/site-packages/thalassa/normalization.py:211) # i.e. we create the `triface_nodes` variable.
KeyError: <THALASSA_FORMATS.UNKNOWN: 'UNKNOWN'>
That is caused by:
ds = thalassa.normalization.normalize(ds)
I found the solution by making my dataset compliant with the GENERIC
format:
ds = ds.rename({
"longitude": "lon",
"latitude": "lat",
"face_nodes": "triface_nodes",
"max_no_vertices": "three",
"face": "triface",
}) # make variable compliant with thalassa
I also understood the convention face_nodes
/ triface_nodes
is before / after the Quad elements test.
concerning the connectivity of the mesh:
Would it be possible to skip the quad element test if you know already that the mesh is an unstructured triangle grid?
Also, I think ideally the connectivity of mesh should be renamed to mesh_topology
, according to UGRID and cf_xarray conventions
concerning the coordinates
Would it acceptable to consider other names for coordinates ? like Lon
, x
or longitude
, or should this aspect be dealt by the user?