OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
249 stars 120 forks source link

Vertical levels #464

Closed Oklyagina closed 3 years ago

Oklyagina commented 3 years ago

Dear Knut-Frode, I faced a problem of incorrect vertical levels reading from .nc file. data.nc provides 25 sigma - levels, but both reader_netCDF_CF_generic and reader_netCDF_CF_unstructured see only the first level and read it as z - coordinate. I tried to make standard mapping and add other levels manually, but it didn't help. Could you please suggest what to do with this issue? image

knutfrode commented 3 years ago

Hi,

The unstructured reader supports sigma levels, but should only be used for unstructured files, but should anyway normally not be able to open structured file. The ROMS-native-reader also supports sigma-levels, but works only for raw output from the ROMS model.

But your file is presumably a regular structured file (rectangular in x and y)? The generic netCDF-reader does however presently not support sigma-levels, only regularly gridded z-levels.

What is the source of your file? Can you post a full ncdump?

Oklyagina commented 3 years ago

Thank you for the explanations, sad to hear it

The file is an output of INMOM (Institute of Numerical Mathematics Ocean Model) calculations. Here is the file with dump: Netcdf.txt

knutfrode commented 3 years ago

This file seems not CF-compliant, and it is in fact not possible to detect automatically what the level (lev) coordinate means.

Sigma should be between 0 and 1, but the numbers you provide above are between 1.74 and 955.73. Could this be z in meters instead?

If so, then all layers should be read by OpenDrift (reader_netCDF_CF_generic), but there could be some ambiguity due to the second vertical axis lev_2. Can you try to remove the lev_2 variable from a file, and see if that helps?

It would also be useful if you could paste the output log from opening this file:

from opendrift.readers.reader_netCDF_CF_generic import Reader
r = Reader('data.nc')
knutfrode commented 3 years ago

The coordinates indicate that this is Caspian Sea, which has a max depth of 1025m, which strongly indicates that your lev coordinate is in meters, and not sigma.

Then I expect it to work by removing lev_2. This means however that you probably also must remove from your mapping dictionary the two variables which have lev_2 as their vertical coordinate (2D variables): hhq and ssh.

Oklyagina commented 3 years ago

I asked the authors, lev is definitely sigma - level, but multiplied by 1000 for scaling. So it seems I have to ask the colleagues for a file with output in z - levels. I will implement your advice as soon I get a new file. Thanks a lot!

knutfrode commented 3 years ago

Closing this issue. Please re-open if still relevant.