Skip to content

Support rechunking to seasonal frequency with SeasonalResampler #10425

Open
@dcherian

Description

@dcherian

Is your feature request related to a problem?

This doesn't work today

from xarray.groupers import SeasonResampler

ds.chunk(time=SeasonResampler(["DJF", "MAMJ", "JAS", "ON"]))

with an obscure error because TimeResampler is special-cased:

xarray/xarray/core/dataset.py

Lines 2515 to 2522 in 8796d55

chunks_mapping_ints: Mapping[Any, T_ChunkDim] = {
name: (
_resolve_frequency(name, chunks)
if isinstance(chunks, TimeResampler)
else chunks
)
for name, chunks in chunks_mapping.items()
}

That is a good thing because SeasonResampler sets drop_incomplete=True by default.

We should

  1. Raise a better error
  2. Probably add another method (memo-ized) to Resampler objects that takes an input tuple of chunks and returns a tuple of chunks, so that SeasonResampler will ignore the drop_incomplete kwarg, and not silently drop data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions