ndcube icon indicating copy to clipboard operation
ndcube copied to clipboard

NDCube.fill

Open DanRyanIrish opened this issue 8 months ago • 2 comments

Describe the feature

A method that allows users to replace masked data values with a custom value, an alter associated uncertainty and mask values.

Possible API:

def fill(fill_value, unmask=False, uncertainty_fill_value=None, fill_in_place=False):
    """
    Replaces masked data values with input value.

    Returns a new instance or alters values in place.

    Parameters
    ----------
    fill_value: `numbers.Number` or scalar `astropy.unit.Quantity`
        The value to replace masked data with.
    unmask: `bool`, optional
        If True, the newly filled masked values are unmasked. If False, they remain masked
        Default=False
    uncertainty_fill_value: `numbers.Number` or scalar `astropy.unit.Quantity`, optional
        The value to replace masked uncertainties with.
    fill_in_place: `bool`, optional
        If `True`, the masked values are filled in place.  If `False`, a new instance is returned
        with masked values filled.  Default=False.
    """
    # ...code implementation here.

Proposed solution

No response

DanRyanIrish avatar Mar 10 '25 19:03 DanRyanIrish

We could call it fillna

nabobalis avatar Mar 10 '25 19:03 nabobalis

The method should not be named just fill(), because users will assume that the entire array will be filled. The analogue in numpy.ma is filled(), but that's not a sufficiently distinctive name. I suggest fill_masked().

ayshih avatar Mar 14 '25 23:03 ayshih

Reolved by #829

DanRyanIrish avatar Jun 20 '25 13:06 DanRyanIrish