Volume Renderer does not work with NetCDF

Hello together,

I would like to visualize NetCDF data with VAPOR. The 2D renderer works well but somehow VAPOR doesn’t allow me to use the Volume, Slice and IsoSurface renderer. They are not clickable.

The NetCDF data is under CF-convention so it should work. Just to be sure I follwed the instructions from this video: CF-Conventioins for VAPOR - YouTube but I ended up with the same result - VAPOR reads the data but won’t allow me to use Volume, Slice or IsoSurface renderer.

When I import the WRF sample data that was used in the other Youtube tutorial everything (including Volume, Slice and IsoSurface) works fine.

Do you know how to fix this problem?

Greetings from Germany,
Aaron

Hi Aaron, if the 3D renderers are disabled it means that Vapor can’t read your 3D variables. It looks like your grid is curvilinear, which has a couple extra requirements. We have documentation on this that hasn’t been published yet, but you can access it at the link below. Check out the “Coordinate Variables” section, which should point you in the right direction. If it doesn’t let us know and if you share one of your files we can troubleshoot.

https://vapor.readthedocs.io/en/latest/data/netCDF/cfCompliance.html#cfcompliance

Hi Pearse, thank you for your help! I tried to generate auxiliary coordinate variables in Python but I wasn’t able to. I could generate the X,Y and Z coordinates with np.linspace in Python (it worked well with your code from here VAPOR/regularToCF.py at readTheDocs · NCAR/VAPOR · GitHub) but I just don’t know how to generate the auxiliary coordinate variables. Here are Screenshots of the dataset info of one of my original NetCDF files:

I hope you could help me to generate the variables correctly. I would like to share one of my NetCDF files but unfortunatly I’m not allowed to do that.

Greetings, Aaron

Stay tuned, I’ll have an update for you at least by Wednesday.

Hi Pearse, I tried to make the 3D data readible for VAPOR a few more times but unfortunately I wasn’t able to do it. Do you have any more ideas? The model has a rotated latitude/longitude grid with the grid internal north pole positioned at 40.0°N, 170.0°W. In the coordinate system of the rotated grid the model corners are positioned at:
SW-corner: 05.00°W, 05.00°S
NW-corner: 05.00°W, 06.50°N
NE-corner: 05.50°E, 06.50°N
SE-corner: 05.50°E, 05.00°S

This leads to the following geographic coordinates:
SW-corner: 02.98°E, 44.77°N
NW-corner: 01.04°E, 56.20°N
NE-corner: 19.84°E, 56.14°N
SE-corner: 17.72°E, 44.72°N

Probably this helps.

Greetings,
Aaron

This gets tricky if I can’t reproduce the procedure without an example file. But I understand that your work might be proprietary.

Looking at your screenshots, your data seems to conform to CF compliance. For example the variable ‘P’ is correctly defined by coordinate variables in each dimension. Your coordinate variables and dimensions (time, rlat, rlon, level, etc.) look correct to me.

I can’t really debug the data without an example file. If you can share a single timestep or even a subregion of your data, I can investigate further. I can only speculate with screenshots unfortunately, and your file looks like it should work to me.

Aaron, thanks for sharing the file. Here are the problems:

Take a look at P(time, level, rlat, rlon).

  1. time, rlat, and rlon all have coordinate variables, but level does not.
  2. The coordinate variables need an “axis” attribute (“T” for time, “X” for rlon, “Y” for rlat, and “Z” for a level coordinate variable)
  3. Any 3D variable that has a “coordinates” attribute should have four values, one for each dimension. This should be “time level rlat lon”.

These commands seem to do the trick for me. Note: You probably want to use something else to define “level” values.

import xarray as xr
import numpy as np
file = "/Users/pearse/Downloads/lfff00120000.nc"

ds = xr.open_dataset(file)
ds['level'] = np.linspace(start=2.2e+01, stop=2e+04, num=50)
ds.level.attrs['axis'] = 'Z'

ds.rlat.attrs['axis'] = 'Y'
ds.rlon.attrs['axis'] = 'X'
ds.time.attrs['axis'] = 'T'

ds.P.attrs['coordinates'] = "time level lon lat"

Hi Pearse thank you so much for helping me with this! The code seems to work well, I just have a problem saving the file. I tried to save it like this:

# Save file

ds.to_netcdf("lfff00120000_new.nc")

But the following error occoured:

ValueError: 'coordinates' found in both attrs and encoding for variable 'P'.

Is there something I have to change? Or is there another way to save the file?

  1. Can you share the script you’re using so I can try to reproduce the ValueError?

  2. You can try deleting the “coordinates” attribute. We always recommend having a “coordinates” attribute, but you may not need it if your coordinate variables have the same name as their dimension.

Hi Pearse, I deleted the coordinates line in your code and it worked! But I still have a problem because the 3D variables are turned upside down. Here are two images. The first shows a volume rendering of dBZ and the second is a XZ slice of the Temperature field. Both are upside down.

Here is the code I used:

import xarray as xr
import numpy as np
file = "lfff00150000.nc"

ds = xr.open_dataset(file)

ds['level'] = np.linspace(start=2.2e+01, stop=2e+04, num=50)
ds.level.attrs['axis'] = 'Z'
ds.rlat.attrs['axis'] = 'Y'
ds.rlon.attrs['axis'] = 'X'
ds.time.attrs['axis'] = 'T'

#ds.P.attrs['coordinates'] = "time level lon lat"

# Save file 

ds.to_netcdf("lfff00120000_new.nc")

And there is another problem because somehow I can’t choose w to plot as a slice or volume rendering. I can choose u and v and they work (apart from beeing upside down) but I’m not able to choose w.

I took a look at the data in Ncview which showed the values for P to be increasing with elevation. Vapor and NCView are both indicating that your data is upside down.