Project

General

Profile

Problems to treat a NetCDF file / remapcon on transverse mercator grid

Added by Sven Kotlarski almost 11 years ago

Hi,

I do have a NetCDF file with an observed precipitation grid (variable "rr") that I can display using ncview, but issuing some cdo command on it (e.g. cdo info) would produce the following error message:

-1 : Date Time Param Level Size Miss : Minimum Mean Maximum

cdf_get_vara_double : ncid = 65536 varid = 7

Error (cdf_get_vara_double) : NetCDF: Start+count exceeds dimension bound

The header of the file (ncdump -h) looks as follows:

netcdf rr24hNOgrd1957on_2004_11_08_org {

dimensions:

proj = 1 ;

Xc = 1195 ;

Yc = 1550 ;

time = 1 ;

variables:

double proj(proj) ;

proj:units = " " ;

char UTM33_grid(proj) ;

UTM33_grid:units = " " ;

UTM33_grid:missing_value = ;

UTM33_grid:grid_mapping_name = "transverse_mercator" ;

UTM33_grid:scale_factor_at_central_meridian = "0.9996" ;

UTM33_grid:longitude_of_central_meridian = "15" ;

UTM33_grid:latitude_of_projection_origin = "0" ;

UTM33_grid:false_northing = "0" ;

UTM33_grid:false_easting = "0" ;

UTM33_grid:semi_major_axis = "6378137" ;

UTM33_grid:inverse_flattening = "298.257223563" ;

double Xc(Xc) ;

Xc:units = "m" ;

Xc:axis = "X" ;

Xc:long_name = "X-coordinate in UTM33 system" ;

Xc:standard_name = "projection_x_coordinate" ;

double Yc(Yc) ;

Yc:units = "m" ;

Yc:axis = "Y" ;

Yc:long_name = "Y-coordinate in UTM33 system" ;

short lon(Yc, Xc) ;

lon:units = "degrees_east" ;

lon:missing_value = -999s ;

lon:long_name = "longitude" ;

lon:standard_name = "longitude" ;

lon:scale_factor = 0.01f ;

lon:add_offset = 0.f ;

short lat(Yc, Xc) ;

lat:units = "degrees_north" ;

lat:missing_value = -999s ;

lat:long_name = "latitude" ;

lat:standard_name = "latitude" ;

lat:scale_factor = 0.01f ;

lat:add_offset = 0.f ;

double time(time) ;

time:units = "days since 1900-01-01 00:00:00" ;

time:standard_name = "time" ;

short rr(Yc, Xc, time) ;

rr:units = "mm/day" ;

rr:missing_value = -999s ;

rr:long_name = "daily precipitation" ;

rr:standard_name = "lwe_precipitation_rate" ;

rr:grid_mapping = "UTM33_grid" ;

rr:coordinates = "lat lon" ;

rr:scale_factor = 0.1f ;

rr:add_offset = 0.f ;

I'm also attaching the file. I guess it's some problem with the dimensions or coordinate variable names (e.g. Xc, Yc) or attributes, but cannot sort it out. Maybe the file doesn't obey CF Conventions? Could anybody help?

My second question concerning this file: The grid is a transverse mercator grid and I would like to conservatively remap it to a rotated lat/lon grid. remapcon and remapcon2, however, seem to not work on such grids ("grid1 corner missing"). Is there any solution?

Thanks a lot! Sven


Replies (4)

RE: Problems to treat a NetCDF file / remapcon on transverse mercator grid - Added by Sven Kotlarski almost 11 years ago

OK, sorry for the confusion. I found the problem in meantime: The dimensions Yc, Xc and time for the variable rr have to rearranged in a way that time varies first (use "ncpdq -a time,Yc,Xc rr24hNOgrd1957on_2004_11_08.nc" in this particular case). The second problem concerning remapcon is, howver, not solved and I'd be happy about any hint.

Thanks! Sven

RE: Problems to treat a NetCDF file / remapcon on transverse mercator grid - Added by Jaison-Thomas Ambadan almost 11 years ago

I think cdo needs the "xbounds" and "ybounds" for conservative remapping (?)

You could use nearest neighbour (remapnn) instead of remapcon OR simply use "setgrid", for eg, here is my equivalent lonlat grid description of your file:

gridtype  = lonlat
xsize     = 1195
ysize     = 1550
xfirst    = -1.30189
xinc      = 0.0283019
yfirst    = 57.7733
yinc      = 0.0092393
cdo -setgrid,mygrid rr24hNOgrd1957on_2004_11_08.nc ofile

ncview of ofile.nc looks fine to me but I may be wrong. Include the appropriate "xnpole" and "ynpole" if you want the rotation.

Cheers,
J

RE: Problems to treat a NetCDF file / remapcon on transverse mercator grid - Added by Sven Kotlarski almost 11 years ago

Hi Jaison

Thanks very much. remapnn is unfortunately not an option, since the target grid is at much coarser resolution and the target grid cells should contain something like the mean of all smaller grid cells of the original grid. remapbil would work, but this is not conservative.

The second solution you proposed (setgrid) is also not an option, as the original grid is not regular in lat/lon and the setgrid command screws up the entire grid. You can see that easily in the figure below (obtained by ncview on the new rotated target grid): Left panel -> output after using remapbil on the original file, Right panel -> output after setting the grid as you suggested and then remapcon. The fields should at least be similar (remapbil vs. remapcon), but the entire grid is distorted by re-setting the grid usind setgrid.

Maybe remapcon is then not possible for grids defined in the UTM projection. Would be a pity though ...

Thanks anyway! Sven

RE: Problems to treat a NetCDF file / remapcon on transverse mercator grid - Added by Jaison-Thomas Ambadan almost 11 years ago

Did you compare the ncview of your original file with the output of "setgrid" (WITHOUT ANY remap). To me it was similar (WITHOUT remap) but may be the geographic projection causing the problem during remaping (actually I didn't visualize after remap). But as you said it is distorted after remap.

The fields should at least be similar (remapbil vs. remapcon), but the entire grid is distorted by re-setting the grid usind setgrid.

if you compare the remapbil AFTER setgrid (just like remapcon after setgrid) - they are similar (the difference in your figure is because the remap is from two different projections)

Anyway, I don't have any other ideas; may be Uwe can help you!

Cheers,
J

    (1-4/4)