Project

General

Profile

how to specify dimensions if lat and lon are arrays

Added by Michelle Irizarry about 3 years ago

Hi there,

I am trying to use remapcon to interpolate data on a regular lat-lon grid to a target grid that is regular in NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901 (resolution of 2 mi x 2 mi so lat and lon vary with lon and lat). Is this possible with remapcon or remapnn?
I have lat and lon as arrays for the 2 mi x 2 mi target grid. And they are function of dimensions row and column, respectively.
My main variable, rainfall, is a function of dimensions col, row, and time.

When I try to run remapcon on it, I get:
cdo remapcon (Abort): Unsupported target grid type (generic)!

Does this mean I have to make my rainfall variable have lon, lat, and time dimensions instead? How, if my lon and lat are arrays?

This is the output of R's RNetCDF print.nc on my target grid:

netcdf classic {
dimensions:
timestamps = 37621 ;
cells = 4830 ;
col = 70 ;
row = 119 ;
pair = 2 ;
variables:
NC_FLOAT timestamps(timestamps) ;
NC_CHAR timestamps:long_name = "Time in days" ;
NC_CHAR timestamps:units = "minutes since 1914-01-01 00:00:00" ;
NC_INT cells(cells) ;
NC_CHAR cells:long_name = "ID of GRIDIO cells" ;
NC_CHAR cells:units = "Index number" ;
NC_INT col(col) ;
NC_CHAR col:long_name = "GRIDIO column number" ;
NC_CHAR col:units = "Index number" ;
NC_INT row(row) ;
NC_CHAR row:long_name = "GRIDIO row number" ;
NC_CHAR row:units = "Index number" ;
NC_INT roco(pair, cells) ;
NC_CHAR roco:long_name = "Row/Column of GRIDIO cells" ;
NC_CHAR roco:units = "Index number" ;
NC_FLOAT coords(pair, cells) ;
NC_CHAR coords:long_name = "XY cordinates of GRIDIO cell centroid" ;
NC_CHAR coords:units = "State Plane Coordinates (ft)" ;
NC_CHAR coords:Project Coordinate System = "NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901" ;
NC_CHAR coords:Projection = "Transverse Mercator" ;
NC_CHAR coords:False_Easting = "656166.66666700" ;
NC_CHAR coords:False_Northing = "0.00000000" ;
NC_CHAR coords:Central Meridian = "-81.00000000" ;
NC_CHAR coords:Scale_Factor = "0.99994100" ;
NC_CHAR coords:Latitude_Of_Origin = "24.33333300" ;
NC_CHAR coords:Linear Unit = "US Foot" ;
NC_FLOAT dxdy(pair, cells) ;
NC_CHAR dxdy:long_name = "Column/row width of GRIDIO cell" ;
NC_CHAR dxdy:units = "Linear ft" ;
NC_FLOAT area(cells) ;
NC_CHAR area:long_name = "Area of GRIDIO cell" ;
NC_CHAR area:units = "ft^2" ;
NC_FLOAT rainfall(col, row, timestamps) ;
NC_CHAR rainfall:long_name = "Rainfall" ;
NC_CHAR rainfall:units = "inches" ;
NC_FLOAT lat(col, row) ;
NC_CHAR lat:units = "degreeN" ;
NC_FLOAT lon(col, row) ;
NC_CHAR lon:units = "degreeE" ;

// global attributes:
NC_CHAR :Version = "Rainfall v4.7 1914-2016" ;
NC_CHAR :Description = "QA/QC rainfall gauge data using TIN-10 method from 1914 to May 2002. June 2002 to December 2016 use NEXRAD." ;

Thanks for any assistance,

Michelle


Replies (9)

RE: how to specify dimensions if lat and lon are arrays - Added by Karin Meier-Fleischer about 3 years ago

Hi Michelle,

I do not have any experience with your target grid. Can you upload the input file and the target grid file?

-Karin

RE: how to specify dimensions if lat and lon are arrays - Added by Michelle Irizarry about 3 years ago

Hi Karin,

Attached is the first timestep of my target grid: target_grid.nc
and the file I am trying to regrid with remapcon: macav2livneh_pr_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily_rx5day.nc

cdo remapcon,target_grid.nc macav2livneh_pr_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily_rx5day.nc out_macav2livneh_pr_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily_rx5day.nc

I was able to make remapcon work by adding the bounds for all the cells, but my variable precipitation ends up with infinite values only.
I also noticed that the dimension nv (number of vertices) is renamed to col_2 in the output nc file. Not sure why...

Thanks,
Michelle

RE: how to specify dimensions if lat and lon are arrays - Added by Michelle Irizarry about 3 years ago

I am using Climate Data Operators version 1.9.9rc1 on Ubuntu

RE: how to specify dimensions if lat and lon are arrays - Added by Karin Meier-Fleischer about 3 years ago

The remapping with remapcon results in NaNs. You can use remapbil, remapnn, or remapdis.

RE: how to specify dimensions if lat and lon are arrays - Added by Michelle Irizarry about 3 years ago

Oh, is there a reason why? I've used it with other datasets without issue.

Thanks Karin!

RE: how to specify dimensions if lat and lon are arrays - Added by Karin Meier-Fleischer about 3 years ago

I wonder about that, too. But I'm no expert in the remapping routines under the hood either.

RE: how to specify dimensions if lat and lon are arrays - Added by Brendan DeTracey about 3 years ago

Um, the dimension order of your target grid vertices are incorrect. Should be (row,col,nv) not (nv,row,col). CF Metadata conventions. Odd that it passed cdo verifygrid and an online CF-checker(https://cfconventions.org/compliance-checker.html)
Use NCO to fix the dimension order.

$ ncpdq -a row,col,nv target_grid.nc target_grid_edit.nc
$ cdo remapcon,target_grid_edit.nc macav2livneh_pr_BNU-ESM_r1i1p1_historical_1950_2005_CONUS_daily_rx5day.nc test.nc

Make sure you understand the following from the cdo manual for remapcon:
Environment Variables:
CDO_REMAP_NORM: This variable is used to choose the normalization of the conservative interpolation.
By default CDO_REMAP_NORM is set to ’fracarea’. ’fracarea’ uses the sum of
the non-masked source cell intersected areas to normalize each target cell field
value. This results in a reasonable flux value but the flux is not locally conserved.
The option ’destarea’ uses the total target cell area to normalize each
target cell field value. Local flux conservation is ensured, but unreasonable flux
values may result.
REMAP_AREA_MIN: This variable is used to set the minimum destination area fraction. The default
of this variable is 0.0.

RE: how to specify dimensions if lat and lon are arrays - Added by Michelle Irizarry about 3 years ago

This is great! Thanks so much Karin and Brendan!

RE: how to specify dimensions if lat and lon are arrays - Added by Karin Meier-Fleischer about 3 years ago

Oops, I overlooked that. Thanks Brendan!

    (1-9/9)