interpolation to a grid with missing data on it
Added by joao ferreira about 1 year ago
Hi
I have a netcdf file with 2000 unstructured points, 1800 of them have missing data and only 200 have data on it. (in.nc)
I want to create a regular lat lon grid and for that I use:
cdo -remapdis,grid.txt,4 in.nc grid.nc
the problem is that remap considers a missing value point as a valid point to interpolate and if all the 4 nearest points are missing value, it puts missing value in the interpolated grid point.
The only way I can avoid this, is to convert all the 2000 values to text, remove the 1800 nodata values, and convert the 200 good values to netcdf again, which is not a smart way to do it...
Is there a way to remove the missing data from the netcdf, or teach remap not to use missing data in the interpolation?
Regards
Joao
Replies (7)
RE: interpolation to a grid with missing data on it - Added by Karin Meier-Fleischer about 1 year ago
What about setting the missing values to zero before remapping?
cdo -remapdis,grid.txt,4 -setmisstoc,0 infile outfile
RE: interpolation to a grid with missing data on it - Added by joao ferreira about 1 year ago
I cannot change missing data to 0 as you suggest... There is no physical reason to put precipitation=0 on those points... The resulting interpolation grid would have those 0 ingested everywhere...
RE: interpolation to a grid with missing data on it - Added by Karin Meier-Fleischer about 1 year ago
Maybe you have to set the environment REMAP_EXTRAPOLATE='off' (default is True) before you call cdo (see https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.12.4).
export REMAP_EXTRAPOLATE='off' cdo -remapdis,grid.txt,4 infile outfile
Without the data and grid file I can only guess.
RE: interpolation to a grid with missing data on it - Added by joao ferreira about 1 year ago
thanks
I don't believe it's a extrapolation problem...
I'm sending the files for a smaller area (73 points on which 50 of them are missing data)
The problem is the same...
When someone performs an interpolation to obtain a grid, it does not make much sense to obtain missing data on the interior of that grid...
Of course, if I do:
cdo -remapdis,grid.txt,73 input.nc output.nc
ncatted -a featureType,global,d,, output.nc
I won't have missing data in the output file, but I don't think this is the correct way to proceed...
RE: interpolation to a grid with missing data on it - Added by Karin Meier-Fleischer about 1 year ago
export REMAP_EXTRAPOLATE='off' export CDO_GRIDSEARCH_RADIUS=0.001 cdo remapdis,grid.txt,4 input.nc output.nc
RE: interpolation to a grid with missing data on it - Added by Karin Meier-Fleischer about 1 year ago
Btw, the grid.txt file does not contain the area of all stations in input.nc.
The grid defined in grid.txt is the area where x- and y-axis grid lines both are drawn. The upper right where cut off.
RE: interpolation to a grid with missing data on it - Added by joao ferreira about 1 year ago
The data outside the domain is not important
export CDO_GRIDSEARCH_RADIUS=0.001
what do you mean?
I don't think this is correct...
Only search in a 0.001 degrees radius? Like that I won't find any valid data...
what i did was:
cdo -setmisstoc,-999 input.nc dumb_nomiss.nc
cdo -f nc -gtc,0 dumb_nomiss.nc mask.nc
cdo -reducegrid,mask.nc dumb_nomiss.nc input_nomiss.nc
cdo -remapdis,grid.txt,4 input_nomiss.nc out.nc