CDO remaping with EUR11-grid
Added by ray kettaren almost 2 years ago
Hello all,
I have a question regarding the remapping data. I have data downloaded from Cordex project with domain EUR-11 with rotated coordinate.
Then, I want to remap it to be usual coordinate. Firstly I use this :
cat > EUR11-grid << EOR
gridtype = lonlat
gridtype = lonlat
xsize = 1000
ysize = 480
xfirst = -44.82
xinc = 0.11
yfirst = 21.78
yinc = 0.11
EOR #######################################################
Then I type this command:
cdo remapdis,EUR11-grid timmean_prhadgem_76-05.nc remap_pr_hadgem_76-05.nc
But there is an error message said that
cdo remapdis (Abort): xsize undefined!
If you have any idea about it let me know.
Thank you very much.
Regards,
Ray
Replies (14)
RE: CDO remaping with EUR11-grid - Added by Karin Meier-Fleischer almost 2 years ago
First, your grid description file for CORDEX EUR-11 is wrong, it seems that you have taken the rotated values and the gridsize and grid mapping info are missing. If you do not know much about CORDEX EUR-11 domain you can google it.
CORDEX EUR-11 domain taken from https://py-cordex.readthedocs.io/en/stable/domains.html shows the CORDEX domains.
cx.domain_info("EUR-11") {'short_name': 'EUR-11', 'region': 4, 'long_name': 'Europe', 'nlon': 424, 'nlat': 412, 'll_lon': -28.375, 'ur_lon': 18.155, 'll_lat': -23.375, 'ur_lat': 21.835, 'dlon': 0.11, 'dlat': 0.11, 'pollon': -162.0, 'pollat': 39.25}
Now, you can write the CDO grid description file, named here gridfile.txt:
gridtype = lonlat gridsize = 174688 xsize = 424 ysize = 412 xname = lon xlongname = "longitude" xunits = "degrees_east" yname = lat ylongname = "latitude" yunits = "degrees_north" xfirst = -28.375 xinc = 0.11 yfirst = -23.375 yinc = 0.11 grid_mapping = rotated_pole grid_mapping_name = rotated_latitude_longitude grid_north_pole_latitude = 39.25 grid_north_pole_longitude = -162.
cdo remapbil,gridfile.txt infile outfile
It is the same way as already said in https://code.mpimet.mpg.de/boards/1/topics/13907
BTW, you have 3 forum entries with more or less the same question. One is enough, you can add additional questions related to the first one to it at any time. We will see it.
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Karin!
Thank you for the solution. I will try it first.
Sorry for the redundant question.
Regards,
ray
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Karin!
I have further question. I have tried using this command cdo remapbil,gridfile.txt original/DJF_pr_hadgemhirham_76-05.nc djf-hadgem-remapbil.nc
With the specification gridfile.txt. I don't know why the output is nan.
In order to get the same size for obtaining the bias difference with EOBS and CRU dataset, I have done this but still it doesn't work. If you have any suggestion to solve this problem.
Thanks in advance.
RE: CDO remaping with EUR11-grid - Added by Estanislao Gavilan almost 2 years ago
Hi Ray,
can you upload a single time step? It difficult to know the problem without the file
Kind regards,
Estanislao
RE: CDO remaping with EUR11-grid - Added by Karin Meier-Fleischer almost 2 years ago
And we need your gridfile.txt to be sure.
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Karin and Estanislao!
This is the file that I used for input before remapping:- DJF_pr_hadgemhirham_76-05.nc : DJF precipitation average from 1976 to 2005 using Hadgem-Hirham RCM single time step
cdo remapbil,gridfile.txt infile outfile
- djf-hadgem-remapbil.nc
Moreover this is the gridfile.txt, using correct EUR11 description gridtype = lonlat
gridsize = 174688
xsize = 424
ysize = 412
xname = lon
xlongname = "longitude"
xunits = "degrees_east"
yname = lat
ylongname = "latitude"
yunits = "degrees_north"
xfirst = -28.375
xinc = 0.11
yfirst = -23.375
yinc = 0.11
grid_mapping = rotated_pole
grid_mapping_name = rotated_latitude_longitude
grid_north_pole_latitude = 39.25
grid_north_pole_longitude = -162.
Thank you for your help.
Regards,
Ray
DJF_pr_hadgemhirham_76-05.nc (3.37 MB) DJF_pr_hadgemhirham_76-05.nc | |||
djf-hadgem-remapbil.nc (721 KB) djf-hadgem-remapbil.nc | |||
gridfile.txt (442 Bytes) gridfile.txt |
RE: CDO remaping with EUR11-grid - Added by Estanislao Gavilan almost 2 years ago
Hi Ray,
I think the problem is that your file has too many coordinates, and some of them are not compatible with cdo. The dimensions of your file are:
time = 1
bnds = 2
rlon = 424
rlat = 412
Then you have the coordiantes and the variable
lon
Size: 424x412
Dimensions: rlon,rlat
lat
Size: 424x412
Dimensions: rlon,rlat
rlon
Size: 424x1
Dimensions: rlon
rlat
Size: 412x1
Dimensions: rlat
pr
Size: 424x412x1
Dimensions: rlon,rlat,time
lat,lon and pr have dimensions of rlon,rlat which are vectors. I think cdo does not recognize rlon and rlat as coordiantes. The file should be like this
time = 1
bnds = 2
lon = 424
lat = 412
lon
Size: 424x412
Dimensions: lon,lat
lat
Size: 424x412
Dimensions: lon,lat
pr
Size: 424x412x1
Dimensions: lon,lat,time
or
time = 1
bnds = 2
x = 424
y = 412
lon
Size: 424x412
Dimensions: x,y
lat
Size: 424x412
Dimensions: x,y
pr
Size: 424x412x1
Dimensions: x,y,time
or maybe like this (I am not sure if this can work because cdo has problems with rlon and rlat)
time = 1
bnds = 2
rlon = 424
rlat = 412
lon
Size: 424x412
Dimensions: rlon,rlat
lat
Size: 424x412
Dimensions: rlon,rlat
pr
Size: 424x412x1
Dimensions: rlon,rlat,time
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Estanislao!
Thank you for the feedback.
In order to solve it, do I need to remap it first with this command to convert it to lonlat:cdo remapbil,r360x180
Furthermore, I will do remap for RCMs model, EOBS and CRU to get the same grid size with this script:./regrid.sh infile(RCMs/CRU/EOBS) 21.78,74.58,0.11 -44.82,65.18,0.11 dis
My question is this step valid for obtaining the same grid size for all my data?
Thank in advance!
Regards,
Ray
RE: CDO remaping with EUR11-grid - Added by Estanislao Gavilan almost 2 years ago
Hi Ray,
if the problem is what I am saying (not 100% sure), you need to remove your rlan and rlon vectors from your input file. I do not know if cdo or other software can directly do this. You can use python or matlab to open the file and create a new netcdf file following the cf convection. Maybe another admin can give you more feedback.
Kind regards,
Estanislao
RE: CDO remaping with EUR11-grid - Added by Karin Meier-Fleischer almost 2 years ago
Ok, here I have to say STOP. Don't delete the rlon and rlat or lon and lat coordinates offhandedly.
Before all others you have to understand the grid of CORDEX files (or any other data files).
If you are a newbie to CORDEX read the CORDEX documentation. CORDEX uses a 'rotated grid' which is a curvilinear grid with 2D longitude (lon) and 2D latitude (lat) coordinate arrays. The variables uses the more simple rotated grid with the 1D longitude (rlon) and 1D latitudes (rlat) on a rotated grid. The variable rotated_pole contains the information about the coordinates of the rotated pole. The variables points with the attribute grid_mapping to it.
You can see it with CDO's sinfo operator:
cdo sinfon DJF_pr_hadgemhirham_76-05.nc
File format : NetCDF4 classic -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v instant 1 1 174688 1 F32 : pr Grid coordinates : 1 : curvilinear : points=174688 (424x412) lon : -44.59386 to 64.96438 degrees_east lat : 21.98783 to 72.585 degrees_north mapping : rotated_latitude_longitude rlon : -28.375 to 18.155 by 0.11 degrees rlat : -23.375 to 21.835 by 0.11 degrees Vertical coordinates : 1 : surface : levels=1 Time coordinate : time : 1 step RefTime = 1949-12-01 00:00:00 Units = days Calendar = 360_day 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 1991-01-01 00:00:00
Or if you do a ncdump:
ncdump -h DJF_pr_hadgemhirham_76-05.nc
netcdf DJF_pr_hadgemhirham_76-05 { dimensions: time = UNLIMITED ; // (1 currently) bnds = 2 ; rlon = 424 ; rlat = 412 ; variables: double time(time) ; time:standard_name = "time" ; time:long_name = "time" ; time:bounds = "time_bnds" ; time:units = "days since 1949-12-01 00:00:00" ; time:calendar = "360_day" ; time:axis = "T" ; double time_bnds(time, bnds) ; double lon(rlat, rlon) ; lon:standard_name = "longitude" ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; lon:_CoordinateAxisType = "Lon" ; double lat(rlat, rlon) ; lat:standard_name = "latitude" ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; lat:_CoordinateAxisType = "Lat" ; double rlon(rlon) ; rlon:standard_name = "projection_x_coordinate" ; rlon:long_name = "longitude in rotated-pole grid" ; rlon:units = "degrees" ; rlon:axis = "X" ; double rlat(rlat) ; rlat:standard_name = "projection_y_coordinate" ; rlat:long_name = "latitude in rotated-pole grid" ; rlat:units = "degrees" ; rlat:axis = "Y" ; char rotated_pole ; rotated_pole:grid_mapping_name = "rotated_latitude_longitude" ; rotated_pole:grid_north_pole_latitude = 39.25 ; rotated_pole:grid_north_pole_longitude = -162. ; float pr(time, rlat, rlon) ; pr:standard_name = "precipitation_flux" ; pr:long_name = "Precipitation" ; pr:units = "kg m-2 s-1" ; pr:grid_mapping = "rotated_pole" ; pr:coordinates = "lat lon" ; pr:_FillValue = 1.e+20f ; pr:missing_value = 1.e+20f ; pr:cell_methods = "time: mean" ; ...
CDO can handle these rotated grid coordinates if everything is there. The nans are caused by the wrong chosen reagion in the gridfile, unfortenuately I wrote the rlon and rlat start values but it has to be the lon and lat start values.
gridfile.txt:
gridtype = lonlat gridsize = 174688 xsize = 424 ysize = 412 xname = lon xlongname = "longitude" xunits = "degrees_east" yname = lat ylongname = "latitude" yunits = "degrees_north" xfirst = -44.59386 xinc = 0.11 yfirst = 21.98783 yinc = 0.11 grid_mapping = rotated_pole grid_mapping_name = rotated_latitude_longitude grid_north_pole_latitude = 39.25 grid_north_pole_longitude = -162.
cdo -remapbil,gridfile.txt DJF_pr_hadgemhirham_76-05.nc outfile.nc
cdo remapbil: Bilinear weights from curvilinear (424x412) to lonlat (424x412) grid cdo remapbil: Processed 174688 values from 1 variable over 1 timestep [0.12s 59MB].
cdo sinfon outfile.nc
File format : NetCDF4 classic -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v instant 1 1 174688 1 F32 : pr Grid coordinates : 1 : projection : points=174688 (424x412) mapping : rotated_latitude_longitude lon : -44.59386 to 1.93614 by 0.11 degrees_east lat : 21.98783 to 67.19783 by 0.11 degrees_north Vertical coordinates : 1 : surface : levels=1 Time coordinate : time : 1 step RefTime = 1949-12-01 00:00:00 Units = days Calendar = 360_day 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 1991-01-01 00:00:00
ncdump -h outfile.nc
netcdf outfile { dimensions: time = UNLIMITED ; // (1 currently) bnds = 2 ; lon = 424 ; lat = 412 ; variables: double time(time) ; time:standard_name = "time" ; time:long_name = "time" ; time:bounds = "time_bnds" ; time:units = "days since 1949-12-01 00:00:00" ; time:calendar = "360_day" ; time:axis = "T" ; double time_bnds(time, bnds) ; double lon(lon) ; lon:standard_name = "longitude" ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; lon:axis = "X" ; double lat(lat) ; lat:standard_name = "latitude" ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; lat:axis = "Y" ; int rotated_pole ; rotated_pole:grid_mapping_name = "rotated_latitude_longitude" ; rotated_pole:grid_north_pole_latitude = 39.25 ; rotated_pole:grid_north_pole_longitude = -162. ; float pr(time, lat, lon) ; pr:standard_name = "precipitation_flux" ; pr:long_name = "Precipitation" ; pr:units = "kg m-2 s-1" ; pr:grid_mapping = "rotated_pole" ; pr:_FillValue = 1.e+20f ; pr:missing_value = 1.e+20f ; pr:cell_methods = "time: mean" ;
cdo infon outfile.nc
-1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1991-01-01 00:00:00 0 174688 75428 : 1.0058e-09 4.5276e-05 0.00059484 : pr
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Dear Karin,
Thank you very much for your help. So I need to change the xfirst and yfirst depend on my RCM's grid description right.
I really appreciate it.
Regards,
Ray
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Karin!
Sorry, I have further issue. First, I want to show you the result of the remapping using the new description of gridfile.txt.
First of all, this is the same result as outfile.nc that you already processed:
Then the problem is occurred when I checked using ncview. The domain is incorrect.
This is the result of the remapping using this new gridfile.txt
gridtype = lonlat gridsize = 174688 xsize = 424 ysize = 412 xname = lon xlongname = "longitude" xunits = "degrees_east" yname = lat ylongname = "latitude" yunits = "degrees_north" xfirst = -44.59386 xinc = 0.11 yfirst = 21.98783 yinc = 0.11 grid_mapping = rotated_pole grid_mapping_name = rotated_latitude_longitude grid_north_pole_latitude = 39.25 grid_north_pole_longitude = -162.
Thank you.
Regards,
Ray
RE: CDO remaping with EUR11-grid - Added by Karin Meier-Fleischer almost 2 years ago
Another approach is to do it without the gridfile:
cdo -sellonlatbox,-44.59386,64.96438,21.98783,72.585 -remapbil,r3600x1800 DJF_pr_hadgemhirham_76-05.nc o.nc
RE: CDO remaping with EUR11-grid - Added by ray kettaren almost 2 years ago
Hi Karin!
Thank yo very much for the solution.
Regards,
Ray