Help with setgrid
Added by Alex Petkov about 5 years ago
I have data which is referenced with longitudes b/n 220 and 300 deg on a regular 0.25 deg grid. I would like to set the grid to -140 to -60 lon range
The data has its grid defined as follows:
cdo griddes ../data/gfs/TMP/gfs.t00z.pgrb2.0p25.f003.grb2
#
# gridID 1
#
gridtype = lonlat
gridsize = 40125
xsize = 321
ysize = 125
xname = lon
xlongname = "longitude"
xunits = "degrees_east"
yname = lat
ylongname = "latitude"
yunits = "degrees_north"
xfirst = 220
xinc = 0.25
yfirst = 22
yinc = 0.25
As I understand, changing xfirst to -140 should accomplish what I need, but the grid remains unchanged (even changed xunits = degrees_west):
cat mygrid
#
# gridID 1
#
gridtype = lonlat
gridsize = 40125
xname = lon
xlongname = longitude
xunits = degrees_west
yname = lat
ylongname = latitude
yunits = degrees_north
xsize = 321
ysize = 125
xfirst = -140
xinc = 0.25
yfirst = 22
yinc = 0.25
cdo -setgrid,mygrid ../data/gfs/TMP/gfs.t00z.pgrb2.0p25.f003.grb2 out.grb
cdo sinfon out.grb
...
Grid coordinates :
1 : lonlat : points=40125 (321x125)
lon : 220 to 300 by 0.25 degrees_east
lat : 22 to 53 by 0.25 degrees_north
...
Any ideas? The file in question is attached.
Thank you very much in advance!!
Alex
Replies (2)
RE: Help with setgrid - Added by Karin Meier-Fleischer about 5 years ago
Hi Alex,
it seems to be a GRIB2 issue because GRIB1 and netCDF don't have problems setting the longitudes to negative values. But I'm not a GRIB expert.
cdo -copy -setgrid,mygrid.txt gfs.t00z.pgrb2.0p25.f003.grb2 outfile.grb2
cdo sinfon outfile.grb2 File format : GRIB2 -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : NCEP unknown v instant 1 1 40125 1 P9 : 2t Grid coordinates : 1 : lonlat : points=40125 (321x125) lon : 220 to 300 by 0.25 degrees_east lat : 22 to 53 by 0.25 degrees_north Vertical coordinates : 1 : height : levels=1 height : 2 m Time coordinate : 1 step RefTime = 2019-09-20 00:00:00 Units = hours Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 2019-09-20 03:00:00 cdo sinfon: Processed 1 variable over 1 timestep [0.05s 33MB]
cdo -f grb -copy -setgrid,mygrid.txt gfs.t00z.pgrb2.0p25.f003.grb2 outfile.grb
cdo sinfon outfile.grb File format : GRIB -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : NCEP unknown v instant 1 1 40125 1 P9 : var0 Grid coordinates : 1 : lonlat : points=40125 (321x125) lon : -140 to -60 by 0.25 degrees_east lat : 22 to 53 by 0.25 degrees_north Vertical coordinates : 1 : height : levels=1 height : 2 m Time coordinate : 1 step RefTime = 2019-09-20 00:00:00 Units = hours Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 2019-09-20 03:00:00 cdo sinfon: Processed 1 variable over 1 timestep [0.05s 24MB]
cdo -f nc -copy -setgrid,mygrid.txt gfs.t00z.pgrb2.0p25.f003.grb2 outfile.nc
cdo sinfon outfile.nc File format : NetCDF2 -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : NCEP unknown v instant 1 1 40125 1 F32 : 2t Grid coordinates : 1 : lonlat : points=40125 (321x125) lon : -140 to -60 by 0.25 degrees_east lat : 22 to 53 by 0.25 degrees_north Vertical coordinates : 1 : height : levels=1 height : 2 m Time coordinate : 1 step RefTime = 2019-09-20 00:00:00 Units = hours Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 2019-09-20 03:00:00 cdo sinfon: Processed 1 variable over 1 timestep [0.00s 22MB]
-Karin
RE: Help with setgrid - Added by Alex Petkov about 5 years ago
Thank you Karin for your help!!
I will switch to nc format and see how it goes--the data is to be served through Geoserver.