Skip to content

[Feature]: skipna parameter for averager #582

Closed
@lee1043

Description

@lee1043

Is your feature request related to a problem?

skipna=None parameter is being used in xarray's mean function to allow user to decide whether skip NaN values in averaging (thus average will be calculated using non-NaN values) or just return NaN for average when there are any NaN values used.

https://docs.xarray.dev/en/stable/generated/xarray.DataArray.mean.html

Describe the solution you'd like

Convey skipna key to here:

weighted_mean = data_var.cf.weighted(weights).mean(dim=dim)

Similar to temporal average functions when .mean being used.

Describe alternatives you've considered

No response

Additional context

It would be even more helpful if users could set some criteria. For example, letting the user decide the fraction of NaN values.

Let's say, I have 10 values, which include 2 NaNs. I want to get an average with skipna=True. But when having 3 NaN values, I want to average to be NaN.

This is going to help the obs4MIPs process when handling with time-varying NaN values due to missed observation points.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions