Project

General

Profile

Convert curvilinear/rotated grid into regular grid

Added by sara Abdelaziz about 2 years ago

Hi, originally I have 2D NumPy array [606,484] (with no time dimnsion) that has been extracted from curvilinear/rotated grid and has similar specification to the grid in the file (wsgmax_wsgmax10m_rcp85_land-cpm_uk_2.2km_01_1hr_20610701-20610730_mask.nc). I tried different methods to regrid this NumPy array to a regular grid but none of them worked, finally, I decided to use CDO, so I converted my 2D array to NetCDF file (myfile.nc) and tried to apply:
cdo -remapnn,gridfile.txt myfile.nc mask_lonlat.nc

but I get error:
Warning (find_time_vars): Time variable >time< not found!

cdo remapnn (Abort): Unsupported generic coordinates (Variable: myvar)!

please can you assist? the mentioned files are in these links:
myfile.nc is in:
(https://drive.google.com/file/d/1ukG2EmLlaWNufw5ybati9atzKPSwChK_/view?usp=sharing)
wsgmax_wsgmax10m_rcp85_land-cpm_uk_2.2km_01_1hr_20610701-20610730_mask.nc is in:
(https://drive.google.com/file/d/1BHdWdBSmbAhPyZlyWJjbhflV_ldA3gVY/view?usp=sharing)

The gridfile.txt

gridtype = lonlat
gridsize = 293304
xsize = 484
ysize = 606
xname = longitude
xlongname = "longitude"
xunits = "degrees_east"
yname = latitude
ylongname = "latitude"
yunits = "degrees_north"
xfirst = -14.60127
xinc = 0.042931
yfirst = 47.42323
yinc = 0.021712


Replies (3)

RE: Convert curvilinear/rotated grid into regular grid - Added by Karin Meier-Fleischer about 2 years ago

Hi Abdelaziz,

the warning message tells you what is wrong - time is missing. But also the coordinate variables lon and lat do not have units attributes (like degrees_east and degrees_north). The best would be to write a correct netCDF file with your Python script (with time coordinate and all needed attributes), I recommend to use xarray.

You can can do theses things on the command line too, but it would be more effort and not sustainable.

-Karin

RE: Convert curvilinear/rotated grid into regular grid - Added by sara Abdelaziz about 2 years ago

Dear Karin,

Thank you for your reply,

I actually fixed the error that occurred when using:
cdo -remapnn,gridfile.txt myfile6.nc mask_lonlat.nc
but the result is completely unsatisfying, I am not sure where the problem is, can you assist, please?

Sara

RE: Convert curvilinear/rotated grid into regular grid - Added by Karin Meier-Fleischer about 2 years ago

I think your input data coordinates are wrong or the gridfile is wrong. The data doesn't fit to the gridfile lonlat range.
I can see Great Britain set around lon=0.0/lat=0.0 (looks like rotated grid).

cdo sinfon myfile6.nc 
   File format : NetCDF4
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  c instant       1   1    293304   1  F64  : myvar         
   Grid coordinates :
     1 : lonlat                   : points=293304 (484x606)
                              lon : 353.9359 to 364.3055 degrees east
                              lat : -4.682749 to 8.062849 degrees north
   Vertical coordinates :
     1 : surface                  : levels=1
cdo remapnn,gridfile.txt myfile6.nc mask_lonlat.nc
cdo sinfon mask_lonlat.nc 
   File format : NetCDF4
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  c instant       1   1    293304   1  F64  : myvar         
   Grid coordinates :
     1 : lonlat                   : points=293304 (484x606)
                        longitude : -14.60127 to 6.134403 by 0.042931 degrees_east
                         latitude : 47.42323 to 60.55899 by 0.021712 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
    (1-3/3)