NOAA-PMEL / Ferret

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

SAVE/RIGID makes file Ferret can't read #1785

Closed karlmsmith closed 6 years ago

karlmsmith commented 6 years ago

Reported by @AnsleyManke on 1 Mar 2017 22:34 UTC Jim Johnson ran into this, running long-standing scripts that read time series data and write netCDF files.

Define an irregular time axis and some data on it, and save it with SAVE/RIGID.

yes? let var = {123, 234, 345, 456, 567, 678, 789}
yes? define axis/t/t0=1-jan-2015/units=day tax = \
{ 312.1, 312.7, 313.4, 314.2, 314.7, 315.4, 316.1}

yes? let vart = reshape(var, t[gt=tax])
yes? save/clobber/rigid/file=new2.nc vart
 LISTing to file new2.nc

yes? sp ncdump -h new2.nc
netcdf new2 {
dimensions:
        TAX = 7 ;
        TAXedges = 8 ;
variables:
        double TAX(TAX) ;
                TAX:units = "day since 2015-01-01 00:00:00" ;
                TAX:point_spacing = "uneven" ;
                TAX:axis = "T" ;
                TAX:bounds = "TAX_bnds" ;
                TAX:time_origin = "1-JAN-2015" ;
                TAX:standard_name = "time" ;
                TAX:edges = "TAXedges" ;
        double TAXedges(TAXedges) ;
                TAXedges:edges = " " ;
        double VART(TAX) ;
                VART:missing_value = -1.e+34 ;
                VART:_FillValue = -1.e+34 ;
                VART:long_name = "RESHAPE(VAR, T[GT=TAX])" ;

// global attributes:
                :history = "FERRET V7.1 (optimized)  1-Mar-17" ;
                :Conventions = "CF-1.6" ;
}

The file has both bounds and edges attributes on the time axis. It has edges for the time axis in the variable TAXedges, but bounds were not saved.

Now try using the file. Until about Ferret v6.95, the file could be used correctly, with the variable having the right time axis. But now Ferret does not create a correct grid.

yes? can data/all; can var/all
yes? use new2
           *** NOTE: Axis has both edges and bounds attributes: TAX - edges definition ignored
           *** NOTE: netCDF bounds variable definition error
           *** NOTE: Bounds definition "TAX_bnds" points to no existing axis
           *** NOTE: Ignoring BOUNDS attribute
yes? sh dat
     currently SET data sets:
    1> ./new2.nc  (default)
 name     title                             I         J         K         L
 VART     RESHAPE(VAR, T[GT=TAX])          1:-7777   ...       ...       ...

Migrated-From: http://dunkel.pmel.noaa.gov/trac/ferret/ticket/2513

karlmsmith commented 6 years ago

Comment by @AnsleyManke on 6 Mar 2017 23:54 UTC This is fixed. If SAVE/RIGID is given, the file gets no record axis. The handling of bounds and edges is now treated as for any other file: for an irregular axis, write bounds by default. Otherwise write edges or bounds if specified with /EDGES or /BOUNDS.

In addition Ferret will now correctly open and initialize the file made by previous versions having bounds and edges attributes and containing the edges coordinate variable.