NCAS-CMS / NCAS-CMS/cf-python

How to group by actual winter season

Open
#939 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

I recently discovered the function

field.collapse('T: mean',group=cf.djf())

However, I've discovered that rather than grouping by actual winter season, I think what it's doing is grouping by the Jan, Feb and Dec of the same calendar year.  Or at least, what it's producing is definitely not right!
Is there a way of doing this so that it actually gets the D,J,F from the same season?
What I've always done in the past is something along the lines of:

field_dec = field.subspace(time = cf.month(12))
field_jan = field.subspace(time = cf.month(1))
field_feb = field.subspace(time = cf.month(2))

field_djf = field_dec.copy()
field_djf.data[:-1] = (field_dec.data[:-1]+field_jan.data[1:]+field_feb.data[1:])/3.

But I'm wondering if there is a more efficient way of doing this, without manipulating the data itself?

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

Reproduce the issue with field.collapse('T: mean', group=cf.djf()) and compare its grouping with the explicit December, January and February subspace example. Trace the seasonal grouping behavior from cf.djf() through field.collapse; done means December is paired with the following January and February without directly manipulating field.data. The issue names no files or tests, so those entry points are the starting scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.