xESMF
xESMF copied to clipboard
Option to normalize conservative regridding result by overlapping area
There are actually two types of conservative regridding, controlled by the NormType option in ESMPy.
Say that's the input data covering a limited region:
The option currently used by xESMF's conservative regridding will "dilute" the boundary cells. That's because the cell on the input grid's boundary are "averaged" with non-existing "cells" outside the boundary (which are assumed to have zero values).
The other option (not in xESMF yet) will normalize boundary cells so they are not "diluted":
The two options are only different at boundaries:
(Full code available in this gist, which was about an already-fixed bug)
I chose the first option mainly for multi-tile grids (regrid one by one and add up). The second option perhaps makes more sense for single-tile grids, but will double count the boundary cells in multi-tile grids. If the second option is useful I can add a new 'conservative_normed'
method.
@JiaweiZhuang Yes. This is useful. Here's the example of regridding WRF pressure:
If I use conservative_normed
method and set ignore_degenerate=True
, I would get this error:
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/xesmf/frontend.py", line 236, in __init__
self._write_weight_file()
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/xesmf/frontend.py", line 280, in _write_weight_file
ignore_degenerate=self.ignore_degenerate)
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/xesmf/backend.py", line 290, in esmf_regrid_build
ignore_degenerate=ignore_degenerate)
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/ESMF/util/decorators.py", line 64, in new_func
return func(*args, **kwargs)
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/ESMF/api/regrid.py", line 150, in __init__
dstFracField=dst_frac_field)
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/ESMF/util/decorators.py", line 52, in new_func
return func(*args, **kwargs)
File "/home/xin/miniconda3/envs/satpy/lib/python3.7/site-packages/ESMF/interface/cbindings.py", line 2148, in ESMP_FieldRegridStoreFile
'. '+constants._errmsg)
ValueError: ESMC_FieldRegridStoreFile() failed with rc = 506. Please check the log files (named "*ESMF_LogFile").
@JiaweiZhuang Any suggestion on this situation? Thanks!