Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GETM level > depth #4

Open
johansoderkvist opened this issue Mar 23, 2021 · 2 comments
Open

GETM level > depth #4

johansoderkvist opened this issue Mar 23, 2021 · 2 comments

Comments

@johansoderkvist
Copy link

I am not able to display the actual depth values on y-axis when plotting GETM files that has "level" as vertical dimension.
Both multiplot and pyncview display level-number on y-axis when plotting GETM nc-file variable[time,level,latc,lonc]
Is there any way to change from level to depth on y-axis?

Best regards
Johan

@jornbr
Copy link
Member

jornbr commented Mar 23, 2021

Hi Johan,

PyNcView/multiplot/xmlplot pick coordinate variables based on the CF coordinates attribute. If that attribute is not present for the variable you are plotting, it will use a coordinate variable with the same name as the dimension itself (here: level), or if not present, a series of integers. So the "ultimate" solution would be to make sure the variable you are viewing has the coordinates attribute. If that is not an option, you can manually force PyNcView to use a specific coordinate variable for any given dimension, by right-clicking the filename in the tree on the left, and choosing "Reassign coordinates...". Multiplot takes a --reassign argument that should achieve the same.

Cheers,

Jorn

@markusReinert
Copy link

Hi,

have you already solved your problem, @johansoderkvist? There seemed to have been a discussion on a similar issue: https://groups.google.com/g/getm-users/c/R80Q8HHkhF0

This discussion, however, does not talk about the case of sigma coordinates. I realized that my GETM files created with flexible output are only shown correctly in pyncview if I use adaptive coordinates but not if I switch to sigma coordinates. In the latter case, the vertical coordinate is "sigma" and not converted to "depth", similar to @johansoderkvist's issue.

I found the explanation for this behavior in the file netcdf.py. The method testFile of NetCDFStore_GOTM explains the convention that is assumed for a GOTM/GETM dataset:

# Test for GETM convention for general, hybrid or adaptive vertical coordinates.
if 'level' in ncdims and 'bathymetry' in ncvars and ('h' in ncvars or 'hmean' in ncvars): match = True

# Test for GETM convention for sigma vertical coordinates.
if 'sigma' in ncdims and 'bathymetry' in ncvars and ('elev' in ncvars or 'elevmean' in ncvars): match = True

As we can see, the convention is different for adaptive and sigma coordinates. In the first case, pyncview requires the variables bathymetry and h (which is called hn by default in GETM flexible output), while in the latter, elev is needed instead of hn. This seems inconsistent to me, because the calculation of depth is also possible in sigma coordinates if bathymetry and h are given. For me, this caused the issue in pyncview, because I used to call sea surface elevation eta instead of elev.

I suggest that this behavior should be documented, as it is not obvious which fields are required for the conversion from level/sigma to depth in pyncview, and which names the variables should have. In addition, it might also be a good option to allow bathymetry and h for the case of sigma-coordinates.

Where should we document the convention of vertical coordinates for GETM in pyncview?

Cheers,
Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants