[Thread Prev][Thread Next][Index]

Re: [ferret_users] How to convert 1d var to 3d



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


On Tue, Mar 2, 2021 at 10:12 AM Ansley Manke <a.c.manke@xxxxxxxxx> wrote:
Hi,

Here's an FAQ, for when the locations LON, LAT, PRES represent a grid. 
It shows an example where the data is 2-D, but it should get you
started.  Note that the way the data are ordered in the file is
important.  If longitude varies fastest, then latitude, then pressure,
this method is what you need.

https://ferret.pmel.noaa.gov/Ferret/faq/reading-ascii-data-representing-a-grid


If the data are ordered differently or if the data locations are not a
grid but are scattered, then it's called "Point data" in the
documentation.  You'll want to use one of the SCAT2GRID functions. Look
here:
https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/working-with-special-data-sets/POINT-DATA

To see a list of the functions that are available for working in x,y,z,
do this from the command line:


    yes? show function scat2grid*xyz*


On 3/1/2021 4:08 AM, Swetha sivakumar wrote:

> Hello
>
> name     title                             I         J     K         L
>  LAT      lat                              1:44      ... ...       ...
>  LON      lon                              1:44      ... ...       ...
>  WS       ws                               1:44      ... ...       ...
>  PRESS    press                            1:44      ... ...       ...
>
> The above is my data. I want to convert ws and press from 1d to 3d
> (lon,lat,var).
> How do I do that?
>
> Thanks in advance.
> Regards
> Swetha


--
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