pydata / pydata/xarray

Can Resample dim be spatial and not just datetime?

Open
#4,008 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement topic-groupby
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Hi, I'll go ahead and preface that I know very little about xarray source code, but I do use xarray often in my work. I hope someone can provide insight into an answer for my question.

Essentially, I have a 2D DataArray with dimensions lat and lon that I want to spatially coarsen to a lower resolution. I have the coarsened 1D coordinates that I would want my grid to be coarsened to, and I was wanting to use the DataArray.resample function and then use .mean() to get my coarsened array. The documentation notes that the resampled dim can only be of type datetime. Is there a particular reason that this the case? Why is there not a capability to resample spatially with lat and lon coordinates? Maybe there is a good reason that is beyond my little knowledge of xarray source code, but I'm curious to know why that is the case or if there is work ongoing to get a capability of resampling how I mentioned?

If there is a specific reason why one can't resample along a dim like lat and lon, is there another type of xarray function that would work well for my needs? Would groupby_bins be something that would work better for what I'm wanting? And can anyone post or guide me to a good example of spatially coarsening an array using groupby_bins?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the DataArray.resample documentation and the groupby_bins API mentioned in the issue, then inspect how resampling restricts dimensions to datetime coordinates. Determine whether spatial resampling belongs in resample or another interface, and document or test the intended behavior for lat/lon coarsening.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.