Skip to content

Enable linear regridding to ignore masked source cells and still produce unmasked destination cells #949

@davidhassell

Description

@davidhassell

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestregriddingRelating to regridding operations

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions