You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enable linear regridding to ignore masked source cells and still produce unmasked destination cells #949
To date (cf<=v3.20.0), linear regridding (just linear, not other methods) has always produced a masked destination grid cell if any of the contributing source grid cells are masked. This approach is not always desirable, as it can produce too-large mismatches between the source grid mask and the mask of the regridded data on the destination grid.
We should have an option to specify how many masked source grid cells can be ignored for each destination grid cell, allowing a numerical value to be calculated. When this occurs, the weights of the remaining non-masked source cells need to be adjusted so that they still sum to 1.0.
I propose a non-negative integer-valued max_masked keyword parameter to cf.Field.regrids and cf.Field.regridc. This defines the maximum number of masked source grid cells which will be ignored for each destination grid cell. If the number of masked source grid cells exceeds this number then the destination grid cell will always be masked.
The default value is 0, which provides the current behaviour - i.e. any masked source cell leads to a masked destination cell.
>>>new=f.regrids(g, method='linear', max_masked=0) # Equivalent to f.regrids(g, method='linear')>>>new=f.regrids(g, method='linear', max_masked=2)
Activity
davidhassell commentedon Jun 23, 2026
Updated to use
mtolinstead ofmax_masked. See #950 (comment)davidhassell commentedon Jun 23, 2026
@CheeseFace - this will be in cf v3.21.1, due for release later this week.