[Thread Prev][Thread Next][Index]

Re: [ferret_users] Problems with reordering axes (use/order) when reading in netcdf file



Hi Al,

What version are you running? There were a few updates to USE/ORDER in the last several years.  The last item in the release notes for V7.6 lists this bug fix:


-Ansley

On 3/15/2021 10:20 AM, Albert Hermann - NOAA Affiliate wrote:
(just re-posting this with a more appropriate subject line)

Hi ferreters,
I have been experiencing some ferret problems lately, regarding the use of "use/order" on netcdf files. Here's what I get for the file with ncdump:

-------------------------------------------------
yes? sp ncdump -h ensall/tfunc_aggregate_flipped_roms.nc
netcdf tfunc_aggregate_flipped_roms {
dimensions:
        XAX1_10 = 10 ;
        ZMO = 12 ;
        TLONG = 510 ;
        ENSEMBLE = 13 ;
        EAX = 13 ;
        STRING1_15 = 15 ;
variables:
        double XAX1_10(XAX1_10) ;
                XAX1_10:point_spacing = "even" ;
                XAX1_10:axis = "X" ;
        double ZMO(ZMO) ;
                ZMO:point_spacing = "even" ;
                ZMO:axis = "Z" ;
                ZMO:standard_name = "altitude" ;
        double TLONG(TLONG) ;
                TLONG:point_spacing = "even" ;
                TLONG:axis = "T" ;
                TLONG:standard_name = "time" ;
        double ENSEMBLE(ENSEMBLE) ;
                ENSEMBLE:units = "realization" ;
                ENSEMBLE:point_spacing = "even" ;
                ENSEMBLE:axis = "E" ;
        double tfunc(ENSEMBLE, TLONG, ZMO, XAX1_10) ;
                tfunc:missing_value = -1.e+34 ;
                tfunc:_FillValue = -1.e+34 ;
                tfunc:long_name = "IF (FLIPT[D=FLIP] EQ 1) THEN TFUNC_RAW[D=TFUNC_AGGREGATE] ELSE TFUNC_RAW[D=TFUNC_AGGREGATE]*(-1)" ;
        double tfunc_scaled(ENSEMBLE, TLONG, ZMO, XAX1_10) ;
                tfunc_scaled:missing_value = -1.e+34 ;
                tfunc_scaled:_FillValue = -1.e+34 ;
                tfunc_scaled:long_name = "IF (FLIPT[D=FLIP] EQ 1) THEN TFUNC_SCALED_RAW[D=TFUNC_AGGREGATE] ELSE TFUNC_SCALED_RAW[D=TFUNC_AGGREGATE]*(-1)" ;
        double EAX(EAX) ;
                EAX:point_spacing = "even" ;
                EAX:axis = "E" ;
        char member_tfunc(EAX, STRING1_15) ;
                member_tfunc:long_name = "MEMBER_TFUNC_RAW[D=TFUNC_AGGREGATE]" ;

// global attributes:
                :history = "PyFerret V7.5 (optimized)  9-Mar-21" ;
                :Conventions = "CF-1.6" ;
}
----------------------------------------------


As shown, the time axis is of length 510. A simple read without the "order" option yields this:

-----------------------------------------------
yes? can dat/all;use ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L         M         N
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      ...       1:12      1:510     1:8       ...
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      ...       1:12      1:510     1:8       ...
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  ...       ...       ...       ...       1:8       ...
----------------------------------------------------------------------------

I get the same thing when I explicitly ask for xzte ordering:

---------------
yes? can dat/all;use/order=xzte ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L         M         N
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      ...       1:12      1:510     1:8       ...
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      ...       1:12      1:510     1:8       ...
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  1:8       ...       ...       ...       ...       ...
-------------------

Now, for my purposes I wish to reorder the axes when I read it in. In one case I wish to reassign the axes from xzte to zxty. If I "use/order=zxty", ferret scrambles things as follows:

------------------------------------------------------------------------------------
yes? can dat/all;use/order=zxty ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:510     1:10      1:8       1:12
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:510     1:10      1:8       1:12
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  ...       ...       1:8       ...
-------------------------------------------------------------------------------------

Oddly, I do get what I want if I reverse the request to use/order=ytxz:

----------------------------------------------------------------------------------------
yes? can dat/all;use/order=ytxz ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:12      1:8       1:10      1:510
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:12      1:8       1:10      1:510
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  ...       1:8       ...       ...
----------------------------------------------------------

In a different case I wish to reassign axes from xzte to xzty. Here again things get scrambled:

-----------------------------------------------
yes? can dat/all;use/order=xzty ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      1:510     1:8       1:12
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      1:510     1:8       1:12
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  1:8       ...       ...       ...
-------------------------------------

and the only way to get what I truly want is to use this very non-intuitive arrangement of "use/oder=xtyz":

---------------------------------------------------------
yes? can dat/all;use/order=xtyz ensall/tfunc_aggregate_flipped_forcing.nc;sh dat
     currently SET data sets:
    1> ensall/tfunc_aggregate_flipped_forcing.nc  (default)
 name     title                             I         J         K         L
 TFUNC    IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      1:8       1:12      1:510
 TFUNC_SCALED
          IF (FLIPT[D=FLIP] EQ 1) THEN TF  1:10      1:8       1:12      1:510
 MEMBER_TFUNC
          MEMBER_TFUNC_RAW[D=TFUNC_AGGREG  1:8       ...       ...       ...
-------------------------------------------------------------

Any ideas as to what is going wrong? Does the /order option not work (or get scrambled) when an ensemble axis is present? Any help appreciated.

Best,
Al Hermann


--
albert.j.hermann@xxxxxxxx
Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115
206-526-6495

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

Privacy Policy | Disclaimer | Accessibility Statement