Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Modify extract_season to return only "full" seasons upon request #2597

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

k-a-webb
Copy link

@k-a-webb k-a-webb commented Nov 29, 2024

Description

Related issue: #2591

Include a parameter full (I'm open to this being a different word) which triggers extract_season to only return "complete" seasons. For example, "DJF" and never just "JF". Invokes extract_time to clip the time vector prior to season extraction

Closes #issue_number


Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


To help with the number pull requests:

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.97%. Comparing base (bd617f5) to head (e5c5336).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2597   +/-   ##
=======================================
  Coverage   94.96%   94.97%           
=======================================
  Files         253      253           
  Lines       14701    14716   +15     
=======================================
+ Hits        13961    13976   +15     
  Misses        740      740           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@valeriupredoi valeriupredoi marked this pull request as draft December 3, 2024 17:16
@valeriupredoi
Copy link
Contributor

many thanks @k-a-webb - it's always good practice to have a Draft PR when not ready for review, as you mentioned in the PR title (so I went ahead and made it a Draft for you 👍 )

@k-a-webb k-a-webb marked this pull request as ready for review December 30, 2024 19:59
@k-a-webb
Copy link
Author

@valeriupredoi, could you please help me understand why the pre-commit.ci check is failing?

Copy link
Contributor

@malininae malininae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @k-a-webb for your contribution. I left big picture comments, they are mostly recommendations rather than requirements, so feel free to ignore them.

@@ -341,6 +341,9 @@ def extract_season(cube: Cube, season: str) -> Cube:
season:
Season to extract. Available: DJF, MAM, JJA, SON
and all sequentially correct combinations: e.g. JJAS
full:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add more documentation or maybe context. I know what the issue is, but I think a person without context might get confused.

full_season_coord, data_dims=result.coord_dims("time")
)

result = result.extract(iris.Constraint(full_season=1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference, rather than need, but I would add a logger message in the debug format which months have been removed. Also on a similar note, in case the values are existing in a timeseries, but have been masked out, as far as I understand they won't be removed. I would recommend to add this information somewhere.

@@ -631,6 +631,18 @@ def test_get_jf(self):
with assert_raises(iris.exceptions.CoordinateNotFoundError):
self.cube.coord("season_year")

def test_get_djf_full(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, personal preference, rather than requirement, but I would add a second test when you provide a cube, where the season is captured fully (let's say from Dec to Nov) with the keyword full=True and check that the returned cube is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preprocessor extract_season does not return complete seasons
3 participants