xCDAT / xcdat

An extension of xarray for climate data analysis on structured grids.
https://xcdat.readthedocs.io/en/latest/
Apache License 2.0
119 stars 12 forks source link

Add weight threshold option for spatial averaging #672

Open pochedls opened 4 months ago

pochedls commented 4 months ago

Description

This PR adds an optional argument that requires a minimum fraction of data be available to perform a spatial average. The initial PR is for spatial averaging only (it would need to be expanded to handle temporal averaging).

Checklist

If applicable:

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (27396e5) to head (9331a02).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #672 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 15 15 Lines 1609 1634 +25 ========================================= + Hits 1609 1634 +25 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

tomvothecoder commented 3 months ago

I'm going to open a separate PR to address this enhancement with the temporal APIs because those require more work and we can merge this earlier when it is ready.

tomvothecoder commented 3 months ago

I started PR #683 for temporal operations. I used some of your code and split them up into reusable functions. We can think about making these functions generalizable across the spatial and temporal classes.

Check them out here: https://github.com/xCDAT/xcdat/pull/683/files

tomvothecoder commented 2 months ago

I've created general functions for weight thresholds here. You can copy them over to utils.py in your branch and then use them in the SpatialAccessor class as needed.

tomvothecoder commented 2 months ago

Rebased this branch on latest main and pushed commit 34b570d (#672) with code review updates (refer to commit message for list of changes).