[Thread Prev][Thread Next][Index]

Re: [ferret_users] Error when subsetting NetCDF file



Hi Ansley,

Thanks so much, that has solved the problem!  I now have a follow up question:

I imported these subsampled netCDF files into MATLAB, and they mysteriously changed size from 2160x586x1x60 to 2174x586x1x60. I then performed some calculations resulting in new fields called OMEGAAR and OMEGAAR2100 (also 2174x586x1x60) and used nccreate and ncwrite to append them to my original netcdf file.  So now I have two sets of variables in the same .nc file which have two different x axes, with the two new variables being ever-so-slightly too long in the x-direction.  Also, the new variables don't appear to be georeferenced (see out put of "grid" below).  So, my question is, how can I force these two new variables to use the X grids of the original variables and save them as a new file where everything is consistent? If it involves arbitrarily trimming them by 14 in the x-direction that should be fine because the resolution is quite high and I will only be using the resulting figures for qualitative purposes.

Thanks for your help,
Nancy

yes? show data

     currently SET data sets:

    1> ./BSOSE20132017wOmega.nc

 name     title                             I         J         K         L

 TEMP     Temperature                      1:2160    1:586     1:1       1:60

 S        Salinity                         1:2160    1:586     1:1       1:60

 TCARBN   DIC                              1:2160    1:586     1:1       1:60

 ALKALI   TAlk                             1:2160    1:586     1:1       1:60

 PHT      pHT                              1:2160    1:586     1:1       1:60

 PCO2     pCO2                             1:2160    1:586     ...       1:60

 NITRATE  Nitrate                          1:2160    1:586     1:1       1:60

 OMEGAAR                                   1:2174    1:586     1:1       1:60

 OMEGAAR2100

                                           1:2174    1:586     1:1       1:60

yes? show grid S[d=1]

    GRID GGB1

 name       axis              # pts   start                end                 subset

 XC        LONGITUDE         2160mi   0.083E(0.083333)     0.083W(359.92)      full

 YC        LATITUDE           586 i   77.983S              30.017S             full

 Z52_52    DEPTH (m)            1 r-  -2.1                 -2.1                full

 TIME      TIME                60 r   30-JAN-2013 20:48    31-DEC-2017 10:24   full

yes? show grid OMEGAAR[d=1]

    GRID GGB3

 name       axis              # pts   start                end                 subset

 XCN6_2167 X                 2174 r   1                    2174                full

 YC        LATITUDE           586 i   77.983S              30.017S             full

 Z52_52    DEPTH (m)            1 r-  -2.1                 -2.1                full

 TIME      TIME                60 r   30-JAN-2013 20:48    31-DEC-2017 10:24   full




Nancy L. Williams
NRC Postdoctoral Fellow
NOAA Pacific Marine Environmental Laboratory


On Wed, Nov 28, 2018 at 2:54 PM Ansley C. Manke <ansley.b.manke@xxxxxxxx> wrote:

Hi ,

Nancy and I looked at this and it turns out that the file uses an INT64 data type to store the time coordinates.  That's very slightly non-standard, as INT64 is a type not listed in the CF standard. We will be able to add it to the types that PyFerret (and Ferret) recognizes.  That will be in a future PyFerret release.

Meanwhile, we can redefine the time axis within the PyFerret session, so PyFerret will write it out ok, and without changing any of the time information. DEFINE AXIS/LIKE= gets the time origin and units from the original axis and t[gt=time] will use the same coordinates.  It just makes it a Ferret-defined axis rather than an axis from the file.

yes? define axis/t/like=time time = t[gt=time]
Replacing definition of axis TIME
           *** NOTE: grid GON1 used by data set bsose_i001_2013to2017_monthly_Salt
           *** NOTE: Redefinition may alter apparent contents of data set
...

There may be more lines of ***NOTE  as the definition of the axis "time" from the file is being changed for all of the grids in the file.  Again this is happening just in the session, making new definition of what PyFerret is going to use for the time axis of the variable.

-Ansley


On 11/28/2018 9:47 AM, Nancy Williams - NOAA Affiliate wrote:
Hello All,

I am trying to subset a large NetCDF file to sample only monthly surface salinity values for 2013-2017 using the following code but am getting a NetCDF error.  Please let me know if you have any suggestions.

Thanks,
Nancy Williams

williams% pyferret

  NOAA/PMEL TMAP

  PyFerret v7.42 (optimized)

  Darwin 14.5.0 - 08/01/18

  27-Nov-18 15:35     


yes? set memory/size=1000

yes? use bsose_i001_2013to2017_monthly_Salt.nc

           *** NOTE: Internal err: unknown data type

           *** NOTE: Axis coordinates are decreasing-ordered. Reversing ordering for axis Z

yes? show data

     currently SET data sets:

    1> ./bsose_i001_2013to2017_monthly_Salt.nc  (default)

 name     title                                                     L

 ITER     model timestep number            ...       ...       ...       1:60

 DEPTH    ocean depth                      1:2160    1:586     ...       ...

 RA       cell area                        1:2160    1:586     ...       ...

 DRF      cell z size                      ...       ...       1:52      ...

 HFACC    vertical fraction of open cell   1:2160    1:586     1:52      ...

 SALT     Salinity                         1:2160    1:586     1:52      1:60

 

yes? let S=SALT[k=52]

yes? show var

 Created by DEFINE VARIABLE:

 >>> Definitions that replace any file variable of same name:

     S = SALT[K=52]

yes? save/clobber/file="BSOSE20132017.nc" S

 LISTing to file BSOSE20132017.nc

NetCDF: Not a valid data type or _FillValue type mismatch (OPeNDAP/netCDF Error code -45)

 Failed creating coord variable TIME

yes? 


--
Nancy L. Williams
NRC Postdoctoral Fellow
NOAA Pacific Marine Environmental Laboratory
nancy.williams@xxxxxxxx

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement