Value Error when using bilinear interpolation method
See original GitHub issueHi! I was using the bilinear
method and kept encountering an error message:
import gcsfs
import xarray as xr
import xesmf as xe
fs = gcsfs.GCSFileSystem(token='anon', access='read_only')
mapper = fs.get_mapper('gs://cmip6/CMIP6/CMIP/MPI-M/MPI-ESM1-2-HR/historical/r1i1p1f1/Omon/thetao/gn/v20190710/')
ds = xr.open_zarr(mapper, consolidated=True)
target_grid = xe.util.grid_global(1,1)
regridder = xe.Regridder(ds, target_grid, 'bilinear')
var_regrid = regridder(ds)
Error:
ValueError: ESMC_FieldRegridStore failed with rc = 506. Please check the log files (named "*ESMF_LogFile").
Fortunately @jbusecke guided me to a solution:
regridder = xe.Regridder(ds, target_grid, 'bilinear', ignore_degenerate=True)
I was wondering if the error message could be edited to reflect that adding the kwarg ignore_degenerate=True
resolves it? Its difficult to work out how to resolve the issue with the existing ValueError
message. Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ERROR IN LINEAR INTERPOLATION
when interpolating in a table of given function values (e.g. log10 x). The quantity ... would have an error comparable to a table...
Read more >Bilinear Interpolation - an overview ... - ScienceDirect.com
This error is affected by the interpolation method. Empirically, we find that bilinear interpolation works better than quartic interpolation in terms of ...
Read more >Bilinear interpolation - Wikipedia
In mathematics, bilinear interpolation is a method for interpolating functions of two variables (e.g., x and y) using repeated linear interpolation.
Read more >Image Processing – Bilinear Interpolation | TheAILearner
In this blog, we will discuss Bi-linear interpolation method in detail. ... Linear interpolation means we estimate the value using linear ...
Read more >Confidence intervals for bilinear interpolation - Cross Validated
I have 4 data points which I am using to interpolate a query point using bilinear interpolation. Each of the 4 data points...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @jdldeauna ,
this problem is caused by the data having been published on a grid which still contains the grid halo (rows or columns of duplicated grid cells), which is required during the model run. The grid halo cells are often not properly defined and are collapsing to lines or points and are only sharing the cell centers with their original, which then leads to this
ValueError
in ESMF (see #109).This problem exists for quite a few CMIP ocean models. What you can usually do (besides using
ignore_degenerated=True
), is to remove the grid halo before creating remapping weights with xesmf or other tools. Beware that not removing the grid halo can lead to incorrect results when using the conservative remapping method. Also beware that data not defined on the grid cell centers, but rather on the vertices / edges, require special treatment.Here is an example with CDOs (Climate Data Operators): https://wiki.mpimet.mpg.de/doku.php?id=analysis:postprocessing_mpiesm:regridding (here, GR15 corresponds to MPI-ESM1-2-LR MPIOM; TP04 to MPI-ESM1-2-HR MPIOM)
And here an example for xarray, for MPI-ESM1-2-LR/HR (see also #109 or this notebook):
I just wanted to chime in and say that this could be very helpful for the broader community. Since I found the workaround at some point in the past, I have interacted with many folks who experienced this issue.
Also many thanks for raising this issue @jdldeauna!