Open JiaweiZhuang opened 6 years ago
@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!
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:![input](https://user-images.githubusercontent.com/25473287/37116471-6b73c9ac-221c-11e8-8a21-b10f846095ca.png)
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).![default](https://user-images.githubusercontent.com/25473287/37116480-6e910276-221c-11e8-8068-f0ea96a27883.png)
The other option (not in xESMF yet) will normalize boundary cells so they are not "diluted":![normed](https://user-images.githubusercontent.com/25473287/37116483-710dbad0-221c-11e8-86fc-ec097c4912b8.png)
The two options are only different at boundaries:![diff](https://user-images.githubusercontent.com/25473287/37117543-904aca98-221f-11e8-972c-9f47bf5ed43c.png)
(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.