NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 20 forks source link

NOTEs: Could not adjust grid , Axes in grids may be inconsistent #1962

Closed AnsleyManke closed 4 years ago

AnsleyManke commented 4 years ago

On opening some datasets we get warning messages like this (Wei Cheng recently reported this)

           *** NOTE: Could not adjust grid for variable sivol
           *** NOTE: Axes in grids may be inconsistent.

Possibly in conjunction with notes about unrecognized axis units. A file like this (shortening the ncdump header for clarity) fails to open correctly:

netcdf sivol_SImon_CAMS-CSM1-0_historical_r1i1p1f1_gn_197901-201412 {
dimensions:
        i = 360 ;
        j = 200 ;
        time = UNLIMITED ; // (432 currently)
        vertices = 4 ;
variables:
        int i(i) ;
                i:units = "1" ;
                i:long_name = "cell index along first dimension" ;
        int j(j) ;
                j:units = "1" ;
                j:long_name = "cell index along second dimension" ;
        float latitude(j, i) ;
                latitude:standard_name = "latitude" ;
                latitude:long_name = "latitude" ;
                latitude:units = "degrees_north" ;
                latitude:_FillValue = 1.e+20f ;
        float longitude(j, i) ;
                longitude:standard_name = "longitude" ;
                longitude:long_name = "longitude" ;
                longitude:units = "degrees_east" ;
                longitude:_FillValue = 1.e+20f ;
        double time(time) ;
                time:units = "days since 1850-1-1 00:00" ;
                time:axis = "T" ;
                time:long_name = "time" ;
        float sivol(time, j, i) ;
                sivol:standard_name = "sea_ice_thickness" ;
                sivol:long_name = "Sea-Ice Volume per Area" ;
                sivol:missing_value = 1.e+20f ;
                sivol:_FillValue = 1.e+20f ;
        float vertices_latitude(j, i, vertices) ;
                vertices_latitude:units = "degrees_north" ;
                vertices_latitude:missing_value = 1.e+20f ;
                vertices_latitude:_FillValue = 1.e+20f ;
        float vertices_longitude(j, i, vertices) ;
                vertices_longitude:units = "degrees_east" ;
                vertices_longitude:missing_value = 1.e+20f ;
                vertices_longitude:_FillValue = 1.e+20f ;

The file opens with a bunch of NOTE's and then has pretty wacky grids that can't be fixed up with Ferret commands:

yes? use /home/merlot/ksmith/Tests/Wei/sivol_SImon_CAMS-CSM1-0_historical_r1i1p1f1_gn_197901-201412.nc
           *** NOTE: Units on axis "i" are not recognized: 1
           *** NOTE: They will not be convertible:
           *** NOTE: Units on axis "j" are not recognized: 1
           *** NOTE: They will not be convertible:
           *** NOTE:
           *** NOTE: Could not adjust grid for variable latitude
           *** NOTE: Axes in grids may be inconsistent.
           *** NOTE:
           *** NOTE: Could not adjust grid for variable longitude
           *** NOTE: Axes in grids may be inconsistent.
           *** NOTE:
           *** NOTE: Could not adjust grid for variable sivol
           *** NOTE: Axes in grids may be inconsistent.
yes? sh dat
     currently SET data sets:
    1> /home/merlot/ksmith/Tests/Wei/sivol_SImon_CAMS-CSM1-0_historical_r1i1p1f1_gn_197901-201412.nc  (default)
 name     title                             I         J         K         L
 LATITUDE latitude                         ...       ...       1:200     ...
 LONGITUDE
          longitude                        ...       ...       1:200     ...
 SIVOL    Sea-Ice Volume per Area          ...       ...       1:200     ...
 VERTICES_LATITUDE
                                           1:4       1:360     1:200     ...
 VERTICES_LONGITUDE
                                           1:4       1:360     1:200     ...

but another similar file opens up fine, even with the same grid setup:

netcdf sivol_SImon_GFDL-ESM4_historical_r1i1p1f1_gn_197901-201412 {
dimensions:
        y = 576 ;
        x = 720 ;
        vertex = 4 ;
variables:
        double x(x) ;
                x:units = "degrees" ;
                x:axis = "X" ;
        double y(y) ;
                y:units = "degrees" ;
                y:axis = "Y" ;
        float latitude(y, x) ;
                latitude:long_name = "latitude" ;
                latitude:units = "degrees_north" ;
                latitude:cell_methods = "y: point x: point" ;
                latitude:standard_name = "latitude" ;
        float lat_bnds(y, x, vertex) ;
                lat_bnds:long_name = "latitude bounds" ;
                lat_bnds:units = "degrees_north" ;
                lat_bnds:axis = "Y" ;
        float longitude(y, x) ;
                longitude:long_name = "longitude" ;
                longitude:units = "degrees_east" ;
                longitude:cell_methods = "y: point x: point" ;
                longitude:standard_name = "longitude" ;
                longitude:bounds = "lon_bnds" ;
        float lon_bnds(y, x, vertex) ;
                lon_bnds:long_name = "longitude bounds" ;
                lon_bnds:units = "degrees_east" ;
                lon_bnds:axis = "X" ;
        float longitude(y, x) ;
                longitude:long_name = "longitude" ;
                longitude:units = "degrees_east" ;
                longitude:cell_methods = "y: point x: point" ;
                longitude:standard_name = "longitude" ;
        float sivol(time, y, x) ;
                sivol:long_name = "Sea-ice volume per area" ;
                sivol:missing_value = 1.e+20f ;
                sivol:units = "m" ;

Both have 2-D variables longitude and latitude with axes (i,j) or (x,y) and also "vertex" or "bounds" variables that have dimensions (j, i, vertices) or (vertex, x, y)

Ferret/PyFerret doesn't determine the first file has axis i is in the X direction and axis j is in the Y direction. But in the second file it decides that x is in the X direction and y in the Y direction using the axis attribute.

I think we have changes to be made here:

1) Go ahead and decide that an axis named i is in the X direction. We already allow axes named X, Y, Z, or T to be in those directions; could also recognize I, J, K, or L as being in those directions. This doesn't solve things in general but would let this set of CMIP6 model outputs open correctly.

2) Change the behavior if any axis direction is still undetermined and we're unable to form consistent grids. Report the problem and stop with an error message rather than trying to continue.

**ERROR: inconsistent data grids: File needs axis attributes on coordinate variables indicating correct directions

AnsleyManke commented 4 years ago

this is fixed as suggested above.

1) Allow single-letter I, J, K, L to indicate axis direction (but not M and N as those aren't as standard). That lets us use the example file as-is.

2) If the file initialization stage can't create consistent grids for the variables and dimensions in the file, stop with a note suggesting AXIS attributes for setting axis directions.