selecting only a latitude grid cell (no longitude info)
Added by Kyle Clem about 3 years ago
Hello CDO users,
I have a netcdf file (attached) containing data spanning only in the latitudinal direction (-90 to 90) with no longitude. I want to select a grid cell, e.g. grid cell 19 (63degS), but can't seem to find a way to do this with CDO without having a longitudinal value.
Does anyone know how to do this with CDO?
Thank you!!
Kyle
amp_zw1_day.nc (7.27 MB) amp_zw1_day.nc |
Replies (2)
RE: selecting only a latitude grid cell (no longitude info) - Added by Karin Meier-Fleischer about 3 years ago
Hi Kyle,
first you have to add the longitude coordinate to the file. You can supplement the griddes output as follows
cdo griddes amp_zw1_day.nc > gridfile.txt
Add the longitude settings to gridfile.txt
# # gridID 1 # gridtype = lonlat gridsize = 121 datatype = float xsize = 1 xname = longitude xlongname = "longitude" xunits = "degrees_east" xfirst = 0 ysize = 121 yname = latitude ylongname = "latitude" yunits = "degrees_north" yfirst = -90 yinc = 1.5
Add the longitude dimension to input file and write it to a new file
cdo -setgrid,gridfile.txt amp_zw1_day.nc amp_zw1_day_with_lon.nc
Select the data for grid cell nearest lon=0/lat=63
cdo -remapnn,lon=0./lat=-63. amp_zw1_day_with_lon.nc amp_zw1_day_cell_0_63.nc
-Karin
RE: selecting only a latitude grid cell (no longitude info) - Added by Kyle Clem about 3 years ago
Hi Karin,
Thank you very much for your reply. This works brilliantly. I now know that CDO needs a longitude value, and your steps to add this worked perfectly. Thank you so much!!
Best wishes,
Kyle