NetCDF variables contain non-matching latitudes

227 Views Asked by At

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"
2

There are 2 best solutions below

1
On

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.

2
On

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.