Closed Liu-Jincan closed 1 year ago
thanks for your issue @Liu-Jincan! There are two challenges here:
Your netCDF file does contain variables that are defined on the nodes, rather than on the faces as in the example that you used above. Visualization on the nodes is not yet supported by the current release, but there are ways to circumvent this (https://github.com/psyplot/psyplot/pull/31). Here is how you can create a new conda environment with the necessary packages:
Create a file named environment.yml
with the following content:
name: psyplot-ugrid
channels:
- conda-forge
dependencies:
- psy-maps
- pyqt
- netcdf4
- dask
- pip
- pip:
- git+https://github.com/Chilipp/psyplot.git@ugrid
- git+https://github.com/Chilipp/gridded.git@dual_node_mesh
create the conda environment via conda env create -f environment.yml
activate the conda environment via conda activate psyplot-ugrid
Your netcdf file is missing the mesh variable that is necessary for the UGRID dimensions. This mesh variable (in this example, the variable Mesh2
, defines how to find the face-node-connectivty, what are the parameters, and so on. without this variable, psyplot is not able to visualize the data. However, I was able to figure out the structure of this variable for your file. So here is how you can repair it
import xarray as xr
ds = xr.open_dataset("ww3.20220815T00Z.nc")
ds["mesh"] = xr.Variable((), 1, {"face_node_connectivity": "tri", "node_coordinates": "longitude latitude"})
ds["tri"].attrs["start_index"] = 1
ds["hs"].attrs["mesh"] = "mesh"
ds["fp"].attrs["mesh"] = "mesh"
ds.to_netcdf("ww3.20220815T00Z-fixed.nc")
Once you fixed your file and installed the necessary libraries, you should be able to visualize the data, e.g. via
import psyplot.project as psy
sp = psy.plot.mapplot("ww3.20220815T00Z-fixed.nc", name="fp")
or via
psyplot ww3.20220815T00Z-fixed.nc -pm mapplot -n fp -o test.png
which gives you the following output
Thank you very much for your reply @Chilipp, and the suggestion is very helpful to me. :smiley:
Here's my plot via psyplot
, cool~:
Awesome! Glad that I could help :smiley:
First of all, thank you so much for developing this tool.
Summary
I have recently been introduced to
psyplot
and would like to visualize WAVEWATCH III (WW3) wave model unstructured grid data.Reason
I have tried to plot the WW3 unstructured grid data (
hs
orfp
) using the code from this website, and my code is as follows:The
ww3.20220815T00Z.nc
could be downloaded via icloud link.And the running error is as follows:
I know it's probably because the NetCDF data doesn't meet the UGRID Conventions, but I really don't know how to change it to work.
Output of
psyplot -aV