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

clip_timerange gives the wrong end date if ending not on the 31st of December #2489

Open
malininae opened this issue Jul 24, 2024 · 1 comment
Labels
bear at a dinner party Something very unexpected bug Something isn't working preprocessor Related to the preprocessor

Comments

@malininae
Copy link
Contributor

While working on #2304, I've discovered that clip_timerange would give you a wrong end date if the end_day and end_month aren't the 31st of December. Example, I need to process ERA5 data for the current year which ends on the 18th of July of 2024. Out of fun I'm passing the 17th of July 2024 as an end date, example:

documentation:
  title: test extract_time.
  description: test extract_time.
  authors:
  - malinina_elizaveta

preprocessors:  
  preproc_regions:
    custom_order: true
    extract_time:
        start_year: 2024
        start_month: 3
        start_day: 1
        end_year: 2024
        end_month: 7
        end_day: 14
    convert_units:
      units: degrees_C

datasets:
- dataset: ERA5
  project: OBS6
  type: reanaly
  version: v1
  tier: 3

diagnostics:
  heatwave:
    description: just a test
    variables:
      current:
        short_name: tasmax
        start_year: 2024
        start_month: 1
        start_day: 1
        end_year: 2024
        end_month: 7
        end_day: 17
        mip: day
        preprocessor: preproc_regions
    scripts: null

Now, what I would expect, the cube to be cropped to 2024-01-01 - 2024-07-17, but because the timerange that gets passed into the clip_timerange(cube: Cube, timerange: str) is 2024/2024, the cube gets to be clipped to 2024-01-01 - 2025-01-01. While I can see that the described use case might be more on a rare side, I think it's still important to be fixed.

Pinging @bouweandela, since he wrote a bunch of time preprocessors.

@malininae malininae added bug Something isn't working preprocessor Related to the preprocessor bear at a dinner party Something very unexpected labels Jul 24, 2024
@bouweandela
Copy link
Member

You can achieve this with something like:

documentation:
  title: test extract_time.
  description: test extract_time.
  authors:
  - malinina_elizaveta

preprocessors:  
  preproc_regions:
    custom_order: true
    convert_units:
      units: degrees_C

datasets:
- dataset: ERA5
  project: OBS6
  type: reanaly
  version: v1
  tier: 3

diagnostics:
  heatwave:
    description: just a test
    variables:
      current:
        short_name: tasmax
        timerange: '20240102/20240717'
        mip: day
        preprocessor: preproc_regions
    scripts: null

See here and here #2048 for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bear at a dinner party Something very unexpected bug Something isn't working preprocessor Related to the preprocessor
Projects
None yet
Development

No branches or pull requests

2 participants