-1

I have two netcdf data (precipitation and potential evapotranspiration). I have clipped both data based on bounding box, so both has same dimension. I try to do simple calculation, but receiving an error Precipitation and PET variables contain non-matching latitudes

I have manually check the data through ArcGIS and found that PET - red color do not cover as much as precipitation - blue color data. How to solve this problem? I am sure this is will always happen if we are dealing with various data from different provider.

enter image description here

Should I re-gridding both data, so the coverage is adjusted well? If yes, how to do that using CDO or NCO, or maybe using other tools?

** Edit question following feedback from Adrian and Charlie

My both data (precip and evapo) has same resolution 0.05 deg/pixel, also the dimension is 2400 x 1470 (checked via ndcump -h).

I have try recommendation using CDO and NCO, and produce same result. See picture below NCO is green and CDO is orange. And both result still not what I expected.

enter image description here

NCO also generate warning during the process

Grid(src): /var/folders/3r/mp8dt34s0ggc9fqt3_tn_rv40000gn/T/ncremap_tmp_grd_src.nc.pid30743
Grid(dst): /var/folders/3r/mp8dt34s0ggc9fqt3_tn_rv40000gn/T/ncremap_tmp_grd_dst.nc.pid30743
Map/Wgt  : /var/folders/3r/mp8dt34s0ggc9fqt3_tn_rv40000gn/T/ncremap_tmp_map_esmf_bilinear.nc.pid30743
ncks: WARNING NC_DOUBLE version of "_FillValue" attribute for pet_thornthwaite fails isfinite(), value is NaN, which can cause unpredictable results.
HINT: If arithmetic results (e.g., from regridding) fails or values seem weird, retry after first converting _FillValue to normal number with, e.g., "ncatted -a _FillValue,pet_thornthwaite,m,f,1.0e36 in.nc out.nc"
user97103
  • 235
  • 1
  • 7
  • Does this answer your question? [Change grid size of a netCDF file](https://stackoverflow.com/questions/55746419/change-grid-size-of-a-netcdf-file) – ClimateUnboxed Nov 30 '20 at 17:18
  • the underlying datasets have different definitions of the land-sea mask (sea points set to missing), hence some lack of correspondence. But both datasets are on the same grid now and can be combined which was the original question. If you want to handle the missing data to be consistent there are function in nco and cdo that can do this, but best to ask in a separate question rather than updating an existing one to change the question. – ClimateUnboxed Dec 01 '20 at 10:40

2 Answers2

0

you can regrid one file to match the resolution of the other using cdo in this way:

cdo remapbil,precip.nc evapo.nc evapo_regridded.nc 

this will map the evapo.nc to the precip file's resolution, using bilinear interpolation ("bil") - other options are conservative remapping ("con" and "con2" for second order), nearest neighbour ("nn") for example.

Please see this related question for more details.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • I have try using `remapbil`, it quite fast. Processing large coverage with file size 5.76GB only takes 55s. Unfortunately the result still not what I expected. See edited question above, I have attached the result. – user97103 Dec 01 '20 at 00:50
0

The explanation for the NCO commands is, as Adrian points to, here

ncremap -d precip.nc evapo.nc evapo_regridded.nc             # Conservative
ncremap -a bilinear -d precip.nc evapo.nc evapo_regridded.nc # Bilinear

In answer to the question below, NCO invokes the ESMF algorithm for bilinear regridding, which apparently is slower than CDO. The conservative algorithm is pure NCO and may, who knows, be faster. Try it and see. The warning NCO prints is pretty informative. I suggest you read it and the HINT and investigate any anomalies before asking others to do it for you.

Charlie Zender
  • 5,929
  • 14
  • 19
  • I have try using NCO solution you provided, with `bilinear` option, With large coverage area and 5.76GB of file size, it takes 7m 8s compare to CDO solution only 55s. Usually NCO always win on the speed and size of the output. NCO also generate a warning (see attached picture in edited question above). Any other recommendation that I should follow? – user97103 Dec 01 '20 at 00:56
  • Thank you for this code snippet, which might provide some limited, immediate help. A [proper explanation](https://meta.stackexchange.com/q/114762/349538) would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – wscourge Dec 01 '20 at 07:02