Open dcherian opened 1 year ago
SeasonGrouper(["JF", "MAM", "JJAS", "OND"])
SeasonGrouper(["DJFM", "MAMJ", "JJAS", "SOND"])
The list would be used as expected_groups
so the output is in the right order.
Here's an interesting thread on SeasonGrouper
design: https://github.com/xCDAT/xcdat/issues/416
ds.temporal.group_average(
'pr',
freq='season',
season_config={
'dec_mode': 'DJF',
'drop_incomplete_djf': True, # Or drop_incomplete_season
'custom_seasons': ['Nov', 'Dec', 'Jan', 'Feb', 'Mar']
}
)
All of this is a factorizing problem, I like the idea of custom Grouper objects with custom factorization
Some prior art: from polars
Group based on a time value (or index value of type Int32, Int64).
Time windows are calculated and rows are assigned to windows. Different from a normal group by is that a row can be member of multiple groups. By default, the windows look like:
[start, start + period)
[start + every, start + every + period)
[start + 2*every, start + 2*every + period)
…
where start is determined by start_by, offset, and every (see parameter descriptions below).
We need ~more discussion of strategies to label groups or perhaps just~ more convenient Grouper objects
QuantileBinGrouper?
SeasonGrouper?
JF,MAM,JJAS,OND
SeasonResampler:
https://github.com/pydata/xarray/discussions/7502
ResampleGrouper to complement TimeResampleGrouper: https://github.com/pydata/xarray/issues/4008 : ?
DayofYearGrouper:
dayofyear
with leap years is also a common issue: https://stackoverflow.com/questions/68677362/daily-climatology-in-xarray-with-leap-years-accounted-for