pydata / pydata/xarray

CDO-like convenience methods to select times

Open
#557 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I feel like the time selecting features of xray can be improved. Currently, some common operations are too involved or verbose, like selecting the data in a group of months that are not a standard season (e.g. the monsoon season in india JJAS), or in non consecutive years (e.g. El Niño years). I think it would be great to implement (and easy), some methods inspired in the widely used Climate Data Operators https://code.zmaw.de/projects/cdo For example: selyear, selmon, selday and selhour.

Then we could easily do a composite of JJAS seasons in El Niño years like this:

pr_dataset = xray.open(my_precipitation_dataset)
elnino_years = [year list here...]
pr_dataset.selyear(elnino_years).selmon([6, 7, 8, 9]).mean('time')

This would make me very happy. The way to go would be to write methods that call grouby, then select the years/months, merge them, and return the corresponding dataset/dataarray, but I am not sure about what is the most efficient way to do this.

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

No files or tests are named. Start by reading xarray's existing groupby and time-selection entry points, then compare the proposed selyear, selmon, selday, and selhour behavior with the CDO operations. Done means agreeing on the API and semantics for non-consecutive years and month groups, implementing the methods, and covering the El Niño and JJAS examples with tests.

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
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.