Project

General

Profile

Inverted vertical levels in grads

Added by Charles Manson over 11 years ago

Hi,

I am processing model output with CDO.
CDO sinfo for input file e.g.:

cdo sinfo -selname,temp ccam_NCEP.200901.nc
cdo sinfo: Started child process "selname,temp ccam_NCEP.200901.nc (pipe1.1)".
   File format: netCDF
    -1 : Institut Source   Param       Time Typ  Grid Size Num  Levels Num
     1 : unknown  unknown  -13         var  I16      6534   1      18   1
   Horizontal grids :
     1 : lonlat       > size      : dim = 6534  nlon = 54  nlat = 121
                        lon       : first = 25  last = 33  inc = 0.150943396  degrees_east
                        lat       : first = -41  last = -23  inc = 0.150001526  degrees_north
   Vertical grids :
     1 : generic            sigma_level : 0.99554199 0.978394985 0.94581598 0.899863005
                                          0.842593014 0.776063025 0.70233202 0.623457015
                                          0.541495025 0.458505005 0.376542985 0.29766801
                                          0.223937005 0.157407001 0.100137003 0.0541837998
                                          0.0216048993 0.00445816014
   Time axis :  25 steps
     RefTime =  2009-01-01 00:00:00  Units = minutes  Calendar = STANDARD
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  2009-01-01 00:00:00  2009-01-01 01:00:00  2009-01-01 02:00:00  2009-01-01 03:00:00
  2009-01-01 04:00:00  2009-01-01 05:00:00  2009-01-01 06:00:00  2009-01-01 07:00:00
  2009-01-01 08:00:00  2009-01-01 09:00:00  2009-01-01 10:00:00  2009-01-01 11:00:00
  2009-01-01 12:00:00  2009-01-01 13:00:00  2009-01-01 14:00:00  2009-01-01 15:00:00
  2009-01-01 16:00:00  2009-01-01 17:00:00  2009-01-01 18:00:00  2009-01-01 19:00:00
  2009-01-01 20:00:00  2009-01-01 21:00:00  2009-01-01 22:00:00  2009-01-01 23:00:00
  2009-01-02 00:00:00
cdo(2) selname: Processed 2940300 values from 14 variables over 25 timesteps. ( 0.06s )
cdo sinfo: Processed 1 variable over 25 timesteps. ( 0.06s )

I use any CDO processor, e.g. monmean and I get:

cdo sinfo: Started child process "selname,temp ccam_NCEP.200901_mon.nc (pipe1.1)".
   File format: netCDF
    -1 : Institut Source   Param       Time Typ  Grid Size Num  Levels Num
     1 : unknown  unknown  -13         var  I16      6534   1      18   1
   Horizontal grids :
     1 : lonlat       > size      : dim = 6534  nlon = 54  nlat = 121
                        lon       : first = 25  last = 33  inc = 0.150943396  degrees_east
                        lat       : first = -41  last = -23  inc = 0.150001526  degrees_north
   Vertical grids :
     1 : generic            sigma_level : 0.99554199 0.978394985 0.94581598 0.899863005
                                          0.842593014 0.776063025 0.70233202 0.623457015
                                          0.541495025 0.458505005 0.376542985 0.29766801
                                          0.223937005 0.157407001 0.100137003 0.0541837998
                                          0.0216048993 0.00445816014
   Time axis :  1 step
     RefTime =  2009-01-01 00:00:00  Units = minutes  Calendar = STANDARD
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  2009-01-02 00:00:00
cdo(2) selname: Processed 117612 values from 14 variables over 1 timestep. ( 0.00s )
cdo sinfo: Processed 1 variable over 1 timestep. ( 0.00s )

It looks fine to me, but when I open the processed file in Grads, the vertical coordinates are switched.
Z=1 corresponds to the highest sigma, i.e. 0.004, and Z=18 is 0.995.

I use invertlev and get:

   Vertical grids :
     1 : generic            sigma_level : 0.00445816014 0.0216048993 0.0541837998
                                          0.100137003 0.157407001 0.223937005 0.29766801
                                          0.376542985 0.458505005 0.541495025 0.623457015
                                          0.70233202 0.776063025 0.842593014 0.899863005
                                          0.94581598 0.978394985 0.99554199

I open it up in Grads and still get Z1=0.004 etc.

Is this a Grads thing, or am I doing something else wrong here?


Replies (9)

RE: Inverted vertical levels in grads - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

Can you please upload:

1) a sample of your data (must be < 50MB or a link to download the data)?, and
2) output of "cdo -V"

Those info may help the CDO guys here to identify the problem!

Cheers,
J.

RE: Inverted vertical levels in grads - Added by Charles Manson over 11 years ago

Hi Jaison,

cdo -V yields:

Climate Data Operators version 1.5.3 (http://code.zmaw.de/projects/cdo)
Compiler: gcc -std=gnu99 -g -O2 -pthread
 version: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
    with: PTHREADS Z
Compiled: by root on xxx.xxx.xxx.xxx (x86_64-unknown-linux-gnu) Jan 23 2012 11:47:55
     CDI library version : 1.5.3 of Jan 23 2012 11:47:51
 CGRIBEX library version : 1.5.1 of Aug 29 2011 20:30:27
  netCDF library version : "3.6.3" of Jan  7 2012 19:23:06 $
 SERVICE library version : 1.3.0 of Jan 23 2012 11:47:42
   EXTRA library version : 1.3.0 of Jan 23 2012 11:47:39
     IEG library version : 1.3.0 of Jan 23 2012 11:47:41
    FILE library version : 1.7.1 of Jan 23 2012 11:47:40

Ok I've had to create a smaller input file (ccam_NCEP.200901.nc).
I process with CDO monmean and I get the switched levels in Grads for ccam_NCEP.200901_mon.nc.

I saw there was an error in a previous version (https://code.zmaw.de/boards/1/topics/581).
Could this be it?

RE: Inverted vertical levels in grads - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

I don't think there is something wrong.

It looks fine to me, but when I open the processed file in Grads, the vertical coordinates are switched.
Z=1 corresponds to the highest sigma, i.e. 0.004, and Z=18 is 0.995.

I'm a bit confused here, as far as CDO is concerned the vertical axis z=1 corresponds to the top-of-the-atmosphere => lowest sigma(?); and z=18 means the lowest layer => highest sigma(?). I think GrADS is reading the file correctly, (and you don't need to invert the axis I guess). May CDO gurus can help you with more info or if I'm wrong.

Cheers,
J.

RE: Inverted vertical levels in grads - Added by Charles Manson over 11 years ago

Thanks for having a look Jaison!

If CDO does see z=1 being the top of the atmosphere then yes that would be a problem.
Just to clarify, when I state z=1 I'm talking about "set z 1" in Grads. i.e. the first z level in the file.
In the input file, this corresponds to the first layer, i.e. level 1, which has a sigma coordinate of 0.995, which is closest to the surface.
If CDO is seeing the first level as the top of the atmosphere then that is a problem.

I've just tried using 1.5.5 win32:

Climate Data Operators version 1.5.5 (http://code.zmaw.de/projects/cdo)
Compiler: i586-mingw32msvc-gcc -std=gnu99 -g -O2
 version: i586-mingw32msvc-gcc (GCC) 4.2.1-sjlj (mingw32-2)
    with: PTHREADS Z PROJ.4
Compiled: by ubuntu on ubuntu (i686-pc-linux-gnu) May 18 2012 10:42:14
     CDI library version : 1.5.5 of May 18 2012 10:41:58
 CGRIBEX library version : 1.5.2 of May 11 2012 14:32:49
  netCDF library version : "3.6.3" of Jan  7 2011 09:12:06 $
    HDF5 library version : 1.8.4
 SERVICE library version : 1.3.0 of May 18 2012 10:41:34
   EXTRA library version : 1.3.0 of May 18 2012 10:41:28
     IEG library version : 1.3.0 of May 18 2012 10:41:32
    FILE library version : 1.8.0 of May 18 2012 10:41:28

and I get the same "inverted" levels.
In other words, "set z 1" in Grads gives me a sigma coordinate of 0.004, a height of 1000s of meters, a very low temperature and pressure.
All these things are telling me I'm looking at the top most level in the model, whereas "set z 1" should be giving me the surface most layer.

RE: Inverted vertical levels in grads - Added by Charles Manson over 11 years ago

Update:
I have also tried opening the file in IDV.
There the vertical coordinate is assumed to be height (basically something like 0.004m to 0.995m).
Does CDO cater for sigma coordinates?

RE: Inverted vertical levels in grads - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

The "set z" equivalent command in cdo (I think) is sellevidx, so -sellevidx,1 give what you want.

OR

you may try converting your input to GRIB and then generate a grads descriptor file with cdo: gradsdes1

then most likely CDO and GrADS select the levels in the same way

more info is here https://code.zmaw.de/embedded/cdo/1.5.5/cdo.html#x1-5950002.15.1

Cheers,
Jaison

RE: Inverted vertical levels in grads - Added by Charles Manson over 11 years ago

Hi,

-sellevidx seems to merely select 1 level.
I need the entire vertical.

However I used -sellevidx to do some rudimentary testing:

"-sellevidx,1" does give me in Grads the level corresponding to sigma 0.995 and

"-sellevidx,18" gives me the level corresponding to sigma 0.004.

But, if I do "-sellevidx,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18" then the resultant file gets the inverted levels.

So CDO is correctly reading the indices/levels.
It seems when writing out a 3D file the vertical coordinate system is assumed to be altitude, which increases with height.
And the file is written assuming that convention, instead of the sigma convention, where the higher value (0.995) is supposed to be level ID 1.

Well that's what I assume.
I know VERY little about CDO.

I see a routine "setzaxis" in the manual.
Hybrid model levels are mentioned.
Maybe this will solve my problem.
I think it is similar to what you suggest with the GRIB conversion.

thanks.

RE: Inverted vertical levels in grads - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

But, if I do "-sellevidx,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"

(just for your info) there is short-cut to the above command:

cdo -sellevidx,1/18 does the same job

Cheers,
J.

PS: the same trick works for other operators and other values.

RE: Inverted vertical levels in grads - Added by Fumiaki Ogawa almost 7 years ago

I had the same problem, but NCO solved it in my case.

ncatted -a positive,lev,o,c,"down" ifile.nc ofile.nc

Cheers.

    (1-9/9)