Project

General

Profile

Rotated lon-lat grid

Added by praveen rai over 3 years ago

Hello all,
I have a Model output for which the coordinates are in rotated lon/lat format. I want to convert it to the regular lon/lat but I don't know how to change the rotated values to exact regular lon/lat value i.e. starting x and y values in regular coordinates. Once I have the regular regrid file, I think I can use setgrid command on my files. I want to regrid my data similar to my area of interest.
I am attaching the rotated regrid file here along with the figure showing the area of interest (this figure is generated using Panoply which automatically convert rotated values to lon/lat). I would also like to mask my data only over the land region, and any help related to all these queries will be highly appreciated.

Thanks
Praveen


Replies (22)

RE: Rotated lon-lat grid - Added by Karin Meier-Fleischer over 3 years ago

Hi Praveen,

you can use the remap operators to remap the data of the curvilinear grid to lonlat grid. See https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

For example, remap the data to global 1x1 degree rectilinear lonlat grid:

cdo -f nc -remapbil,r360x180 timmean_e031001m200002.nc ooo.nc

About masking see https://code.mpimet.mpg.de/projects/cdo/wiki/FAQ#How-can-I-create-a-1x1-degree-landsea-mask

How to mask a sub-region see maskregion operator https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.6.11

-Karin

RE: Rotated lon-lat grid - Added by praveen rai over 3 years ago

Thanks for the reply Karin. The resolution of my data is 0.44 degree. And the remapbil will convert it to a global grid with 1 degree resolution. I am more interested in remapping it to the similar x and y values as in my data with 0.44 degree resolution. I hope it's possible.

RE: Rotated lon-lat grid - Added by Karin Meier-Fleischer over 3 years ago

You have to define it as you want, e.g. ~0.44 degrees

cdo remapbil,r818x409 timmean_e031001m200002.nc outfile.nc
cdo sinfon outfile.nc 

   File format : NetCDF2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QDB           
     2 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QDBL          
     3 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QDBW          
     4 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QDBI          
     5 : MPIMET   REMO     v instant       1   1    334562   1  F32  : PS            
     6 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TS            
     7 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSL           
     8 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSW           
     9 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSI           
    10 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WS            
    11 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SN            
    12 : MPIMET   REMO     v instant       1   1    334562   1  F32  : APRL          
    13 : MPIMET   REMO     v instant       1   1    334562   1  F32  : APRC          
    14 : MPIMET   REMO     v instant       1   1    334562   1  F32  : APRS          
    15 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VDIS          
    16 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AHFS          
    17 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AHFL          
    18 : MPIMET   REMO     v instant       1   1    334562   1  F32  : PSRED         
    19 : MPIMET   REMO     v instant       1   1    334562   1  F32  : USTAR3        
    20 : MPIMET   REMO     v instant       1   1    334562   1  F32  : RUNOFF        
    21 : MPIMET   REMO     v instant       1   1    334562   1  F32  : DRAIN         
    22 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ACLCV         
    23 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ACLCOV        
    24 : MPIMET   REMO     v instant       1   2    334562   1  F32  : U10           
    25 : MPIMET   REMO     v instant       1   2    334562   1  F32  : V10           
    26 : MPIMET   REMO     v instant       1   3    334562   1  F32  : TEMP2         
    27 : MPIMET   REMO     v instant       1   3    334562   1  F32  : DEW2          
    28 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSURF         
    29 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TD            
    30 : MPIMET   REMO     v instant       1   2    334562   1  F32  : WIND10        
    31 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AZ0           
    32 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AZ0L          
    33 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AZ0W          
    34 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AZ0I          
    35 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALB           
    36 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALBEDO        
    37 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALSOL         
    38 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALSOW         
    39 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALSOI         
    40 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SRADS         
    41 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TRADS         
    42 : MPIMET   REMO     v instant       1   4    334562   1  F32  : SRAD0         
    43 : MPIMET   REMO     v instant       1   4    334562   1  F32  : TRAD0         
    44 : MPIMET   REMO     v instant       1   1    334562   1  F32  : USTR          
    45 : MPIMET   REMO     v instant       1   1    334562   1  F32  : USTRL         
    46 : MPIMET   REMO     v instant       1   1    334562   1  F32  : USTRW         
    47 : MPIMET   REMO     v instant       1   1    334562   1  F32  : USTRI         
    48 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VSTR          
    49 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VSTRL         
    50 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VSTRW         
    51 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VSTRI         
    52 : MPIMET   REMO     v instant       1   1    334562   1  F32  : EVAP          
    53 : MPIMET   REMO     v instant       1   1    334562   1  F32  : EVAPL         
    54 : MPIMET   REMO     v instant       1   1    334562   1  F32  : EVAPW         
    55 : MPIMET   REMO     v instant       1   1    334562   1  F32  : EVAPI         
    56 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TDCL          
    57 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TRAFS         
    58 : MPIMET   REMO     v instant       1   4    334562   1  F32  : TRAF0         
    59 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TCLFS         
    60 : MPIMET   REMO     v instant       1   4    334562   1  F32  : TCLF0         
    61 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WL            
    62 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VGRAT         
    63 : MPIMET   REMO     v instant       1   1    334562   1  F32  : VLT           
    64 : MPIMET   REMO     v instant       1   3    334562   1  F32  : T2MAX         
    65 : MPIMET   REMO     v instant       1   3    334562   1  F32  : T2MIN         
    66 : MPIMET   REMO     v instant       1   4    334562   1  F32  : SRAD0U        
    67 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SRADSU        
    68 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TRADSU        
    69 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSN           
    70 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TD3           
    71 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TD4           
    72 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TD5           
    73 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SEAICE        
    74 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SICED         
    75 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TEFF          
    76 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSMAX         
    77 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSMIN         
    78 : MPIMET   REMO     v instant       1   2    334562   1  F32  : WIMAX         
    79 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TOPMAX        
    80 : MPIMET   REMO     v instant       1   1    334562   1  F32  : SNMEL         
    81 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TSLIN         
    82 : MPIMET   REMO     v instant       1   1    334562   1  F32  : AHFICE        
    83 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QRES          
    84 : MPIMET   REMO     v instant       1   1    334562   1  F32  : DSNAC         
    85 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QVI           
    86 : MPIMET   REMO     v instant       1   1    334562   1  F32  : ALWCVI        
    87 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var456        
    88 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLHSL        
    89 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLHSW        
    90 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLHSI        
    91 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var457        
    92 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLQDSL       
    93 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLQDSW       
    94 : MPIMET   REMO     v instant       1   1    334562   1  F32  : BFLQDSI       
    95 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QDBOXS        
    96 : MPIMET   REMO     v instant       1   1    334562   1  F32  : QWBOXS        
    97 : MPIMET   REMO     v instant       1   1    334562   1  F32  : EKBOXS        
    98 : MPIMET   REMO     v instant       1   1    334562   1  F32  : FHBOXS        
    99 : MPIMET   REMO     v instant       1   1    334562   1  F32  : FIBOXS        
   100 : MPIMET   REMO     v instant       1   1    334562   1  F32  : TLAMBDA       
   101 : MPIMET   REMO     v instant       1   1    334562   1  F32  : DLAMBDA       
   102 : MPIMET   REMO     v instant       1   1    334562   1  F32  : PORVOL        
   103 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WI3           
   104 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WI4           
   105 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WI5           
   106 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WI            
   107 : MPIMET   REMO     v instant       1   1    334562   1  F32  : WICL          
   108 : MPIMET   REMO     v instant       1   2    334562   1  F32  : var265        
   109 : MPIMET   REMO     v instant       1   2    334562   1  F32  : var266        
   110 : MPIMET   REMO     v instant       1   2    334562   1  F32  : var275        
   111 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var271        
   112 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var276        
   113 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var1          
   114 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var2          
   115 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var3          
   116 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var4          
   117 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var5          
   118 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var12         
   119 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var13         
   120 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var301        
   121 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var302        
   122 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var303        
   123 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var336        
   124 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var287        
   125 : MPIMET   REMO     v instant       1   1    334562   1  F32  : var288        
   Grid coordinates :
     1 : lonlat                   : points=334562 (818x409)
                              lon : 0 to 359.5599 by 0.4400978 degrees_east  circular
                              lat : -90 to 90 by 0.4411765 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
     2 : height                   : levels=1
                           height : 10 m
     3 : height                   : levels=1
                         height_2 : 2 m
     4 : hybrid                   : levels=1
                              lev : 1 level
                        available : vct
   Time coordinate :  1 step
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  2000-02-00 00:00:00

RE: Rotated lon-lat grid - Added by praveen rai over 3 years ago

Thanks Karin. I have managed to convert rotated lon/lat. Now after doing the the cdo griddes I am getting something like,
53.33745 53.06757 52.79612 52.52316 52.24871 51.97282 51.69551 51.41683
51.13681 50.85549 50.57288 50.28905 50.00401 49.71778 49.43042 49.14193
48.85236 48.56172 48.27007 47.9774 47.68375 47.38915 47.09362 46.7972
46.49989 46.20173 45.90274 45.60295 45.30236 45.00103 44.69894
gridtype = projection
gridsize = 25929
xsize = 201
ysize = 129
xname = x
xlongname = "index_of_lon"
yname = y
ylongname = "index_of_lat"
xfirst = 0
xinc = 1
yfirst = 0
yinc = 1
grid_mapping = Projection

cdo sinfo timmean_FIB_CAS-44_frac.nc
File format : NetCDF
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown v instant 1 1 25929 1 F32 : -1
Grid coordinates :
1 : curvilinear : points=25929 (201x129)
lon : 7.678206 to 147.9288 degrees_east
lat : -0.9850898 to 65.10996 degrees_north
mapping : undefined
x : 0 to 200 by 1
y : 0 to 128 by 1
Vertical coordinates :
1 : surface : levels=1
Time coordinate : 1 step
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
0000-00-00 00:00:00
I think it has lon and lat as a normal variable now not as a coordinate variables. Is there any way i can now convert it to coordinate variables??
Thanks for your help.

Praveen

RE: Rotated lon-lat grid - Added by Karin Meier-Fleischer over 3 years ago

The lon and lat variables are 2D-variables and are used as dimension/coordinate variables via the coordinates attribute ascociatted to the data variables.

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Dear Karin,
I also tried your suggestion of: cdo remapbil,r360x180 filein.nc fileout.nc
This created the grid as expected, but this is not exactly what I need.

My file is a European Cordex file (cdo sinfo below). I am using the data within the files to create a new .nc file for ingestion to another program, which requires a vector of Lat and a vector of Lon (regular). Is is possible to convert the rlat and rlon to regular lat lon coordinates, so I end up with a Lon vector of 106 length and a Lat vector of 103 length (as opposed to a grid)?

File format : NetCDF4 classic
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown v instant 1 1 10918 1 F32 : -1
Grid coordinates :
1 : curvilinear : points=10918 (106x103)
lon : -44.13997 to 64.41475 degrees_east
lat : 22.20309 to 72.42257 degrees_north
mapping : rotated_latitude_longitude
rlon : -28.21 to 17.99 by 0.44 degrees
rlat : -23.21 to 21.67 by 0.44 degrees
Vertical coordinates :
1 : surface : levels=1
Time coordinate : 60 steps
RefTime = 1949-12-01 00:00:00 Units = days Calendar = standard Bounds = true
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
2006-01-16 12:00:00 2006-02-15 00:00:00 2006-03-16 12:00:00 2006-04-16 00:00:00
2006-05-16 12:00:00 2006-06-16 00:00:00 2006-07-16 12:00:00 2006-08-16 12:00:00
2006-09-16 00:00:00 2006-10-16 12:00:00 2006-11-16 00:00:00 2006-12-16 12:00:00
2007-01-16 12:00:00 2007-02-15 00:00:00 2007-03-16 12:00:00 2007-04-16 00:00:00
2007-05-16 12:00:00 2007-06-16 00:00:00 2007-07-16 12:00:00 2007-08-16 12:00:00
2007-09-16 00:00:00 2007-10-16 12:00:00 2007-11-16 00:00:00 2007-12-16 12:00:00
2008-01-16 12:00:00 2008-02-15 12:00:00 2008-03-16 12:00:00 2008-04-16 00:00:00
2008-05-16 12:00:00 2008-06-16 00:00:00 2008-07-16 12:00:00 2008-08-16 12:00:00
2008-09-16 00:00:00 2008-10-16 12:00:00 2008-11-16 00:00:00 2008-12-16 12:00:00
2009-01-16 12:00:00 2009-02-15 00:00:00 2009-03-16 12:00:00 2009-04-16 00:00:00
2009-05-16 12:00:00 2009-06-16 00:00:00 2009-07-16 12:00:00 2009-08-16 12:00:00
2009-09-16 00:00:00 2009-10-16 12:00:00 2009-11-16 00:00:00 2009-12-16 12:00:00
2010-01-16 12:00:00 2010-02-15 00:00:00 2010-03-16 12:00:00 2010-04-16 00:00:00
2010-05-16 12:00:00 2010-06-16 00:00:00 2010-07-16 12:00:00 2010-08-16 12:00:00
2010-09-16 00:00:00 2010-10-16 12:00:00 2010-11-16 00:00:00 2010-12-16 12:00:00

Any advice would be appreciated.

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

hi Cat!

remapbil does exactly what you discribed - sorry, I don't understand what's missing

cheers
ralf

RE: Rotated lon-lat grid - Added by praveen rai over 3 years ago

Hi Catriona,

Apart from CDO, you can take a look at this ncl script which exactly does what you are trying to do, and maybe after generating one regular lon-lat file, you can use remapbil. I hope it helps.

https://www.dkrz.de/up/news-and-events/workshops-and-trainings/ncl-workshops/rotated-grid

Greetings,
Praveen

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Hi Ralf,

Thanks for the quick response. Apologies, I should have been more clear. The command currently provide 'Lon' as 360 long and 'Lat' as 180 long. Is it possible to just extract the lat/lon coordinates for the Cordex area of interest with this command?..so I end up with 'Lon' as 106 long and 'Lat' as 103 long (representing only the European region)? i.e. Can that data be subsequently 'pulled' from the 'Lon' of 360 length and the 'Lat' of 180 length provided by the remapbil command?
I understand that remapbil provides the coordinates for the entire globe, so it is not a case of specifying the size of the original dataset with: cdo remapbil,r106x103 filein.nc fileout.nc
Best wishes.

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Thanks for the suggestion Praveen,
I'm going to take a look at it now.
Best wishes.

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

@Praveen, did you get that ncl script to work for you before?

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

Catriona Duffy wrote:

Hi Ralf,

Thanks for the quick response. Apologies, I should have been more clear. The command currently provide 'Lon' as 360 long and 'Lat' as 180 long. Is it possible to just extract the lat/lon coordinates for the Cordex area of interest with this command?..so I end up with 'Lon' as 106 long and 'Lat' as 103 long (representing only the European region)? i.e. Can that data be subsequently 'pulled' from the 'Lon' of 360 length and the 'Lat' of 180 length provided by the remapbil command?

check the operator sellonlatbox

I understand that remapbil provides the coordinates for the entire globe, so it is not a case of specifying the size of the original dataset with: cdo remapbil,r106x103 filein.nc fileout.nc

remapbil like all other interpolation operators take the target grid as a parameter. It doesn't matter, if the grid is global or regional. There are 3 ways to describe a grid

  1. a built-in shortcut like: global_1, r360x180 or others mentioned on the official documentation (chapter 1.3)
  2. a text representation formated in a way like the output of
    cdo griddes <ifile>
    For a regular grid this would be just a couple of lines
    cdo griddes -sellonlatbox,20,40,-20,40 -topo,global_2
    #
    # gridID 1
    #
    gridtype  = lonlat
    gridsize  = 300
    xsize     = 10
    ysize     = 30
    xname     = lon
    xlongname = "longitude" 
    xunits    = "degrees_east" 
    yname     = lat
    ylongname = "latitude" 
    yunits    = "degrees_north" 
    xfirst    = 21
    xinc      = 2
    yfirst    = -19
    yinc      = 2
    
  3. a datafile that used the target grid - CDO will read the grid from it and use it

In you case (Europe only), you might use this eastlimit=-10.8; southlimit=35.7; eastlimit=69.4; northlimit=72.3

  1. create the target grid with (set the resolution with the parameter of topo)
    cdo -sellonlatbox,-11,70,35,75 -topo,global_2 targetEuropeGrid.nc
  2. perform the remapping on the original data with the method you need
    cdo -remapbil,targetEuropeGrid.nc cordex_input.nc europe_output.nc

hth
ralf

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Thanks for your help Ralf.
I used your command line and topo wasn't recognised for some reason:
@cdo -sellonlatbox,-11,70,35,75 -topo,global_2 EuropeGrid.nc

cdo(1) topo: Process started
ECCODES ERROR : concept: no match for shortName=topo
ECCODES ERROR : concept: input handle edition=1
!!! grib_set_string( grib_handle* h, "shortName", "topo") !!!
Warning (gribapiDefParam): grib_api: No match for shortName=topo@

I can see that 'topo' is supposed to create a half degree regular grid. When I type cdo --operators, it shows up in the list.

Best wishes.

RE: Rotated lon-lat grid - Added by Karin Meier-Fleischer over 3 years ago

Hi Catriona,

which version are you using? Current version is 1.9.9

cdo -V

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

try adding the option '-f nc' right after 'cdo'

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Karin, I am using version 1.9.9 (cdo -V returned)
Climate Data Operators version 1.9.9rc1 (https://mpimet.mpg.de/cdo)

Ralf Adding the '-f nc' worked a treat. One final question if you don't mind?
I identified the max and min lat and lon from the regular Lat Lon grids in my Cordex file and used them to set the outer bounds of the latlon box selected. I also used 'Global_1 to increase the resolution:
cdo -f nc -sellonlatbox,-45,65,22,73 -topo,global_1 test.nc

Then I used as you suggested, the following:
cdo -remapbil,test.nc myinputfile.nc europe_output.nc

Is there another option rather than '-topo,global_1' to specify the number of Lon and Lat cells in the grid while simultaneously keeping the latlon box specified? I see from the documentation link you sent that it is possible to use the grid description from another datafile ('1.3.2.2. Grids from data files') or alternatively, can I simply specify the 'xsize*ysize' of the curvilinear grid (which refers to 'ncell' in '1.3.2.4. CDO grids')? I tried:
cdo -f nc -sellonlatbox,-45,65,22,73 -topo,r106x103 test.nc but this is referring to degrees as opposed to the number of cells/gridbox length.

Many thanks for your advice.

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

Catriona Duffy wrote:

Is there another option rather than '-topo,global_1' to specify the number of Lon and Lat cells in the grid while simultaneously keeping the latlon box specified? I see from the documentation link you sent that it is possible to use the grid description from another datafile ('1.3.2.2. Grids from data files') or alternatively, can I simply specify the 'xsize*ysize' of the curvilinear grid (which refers to 'ncell' in '1.3.2.4. CDO grids')? I tried:
cdo -f nc -sellonlatbox,-45,65,22,73 -topo,r106x103 test.nc but this is referring to degrees as opposed to the number of cells/gridbox length.

-topo is a global topography field. so the parameter of topo set the global resolution.

If you have a data file that already has the target grid you are looking for, you can use is for remapping your input data:

cdo -remapbil,dataOnTargetGrid.nc <ifile> <ofile>

you can also setup the target grid as a textfile like I showed before

gridtype  = lonlat
gridsize  = 80000
xsize     = 200
ysize     = 400
xname     = lon
xlongname = "longitude" 
xunits    = "degrees_east" 
yname     = lat
ylongname = "latitude" 
yunits    = "degrees_north" 
xfirst    = -45
xinc      = 0.05
yfirst    = 22
yinc      = 0.001

you have to adopt the yinc and xinc to set the corners of the area correctly.

Many thanks for your advice.

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

Hi Ralf,

If you have a data file that already has the target grid you are looking for, you can use is for remapping your input data:

I don't want to copy the grid exactly, as it is in rotated Lat Lon, but the nc file also has the regular grid on it.

you can also setup the target grid as a textfile like I showed before

I have a textfile called:gridtest.txt in which I have included the following information:

gridtype = lonlat
xsize = 106
ysize = 103
xfirst = -44.75
xinc = 0.5
yfirst = 21.75
yinc = 0.5

I then used this command:
cdo griddes -sellonlatbox,-45,65,21.5,73.5 -topo,gridtest.txt

I tweaked the Lat Lons specified in the above command, as the grid being output wasn't 106x103 like I wanted, but rather 106x102 when I used the exact Maximum and Minimum Lat and Lon from the regular grid in the original .nc file. This command created the grid, but now I'm not entirely sure how to use it? I think I need to apply it to an nc file (i.e. test.nc), which I can then use in this command: cdo -remapbil,test.nc myinputfile.nc europe_output.nc Or, can I refer to the grid in another way (i.e. not assign it to 'test.nc', but rather just use the name of the grid directly?)
Perhaps I'm missing something obvious here? Apologies, as I'm new to cdos.
Many thanks.

RE: Rotated lon-lat grid - Added by Cat Fitz over 3 years ago

I tried adding the 'test.nc' at the end:
cdo -f nc -sellonlatbox,-45,65,21.5,73.5 -topo,gridtest.txt test.nc

and then:

cdo -remapbil,test.nc input.nc europe_output.nc

But in Panoply, the Longitude only ranges from -44.75 to 7.75 (Image won't attach for some reason). The latitudes were correct.

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

hi Cat!

Instead of using test.nc you can also use the gridtest.txt as a parameter for remapbil.

created with

cdo -f nc topo,grid t.nc
where grid is a text file with the content from above. does this look ok for your with respect to the region it covers?

RE: Rotated lon-lat grid - Added by Ralf Mueller over 3 years ago

for showing an uploaded image, you need to mention it with exclamation marks around like

!image.png!

    (1-22/22)