Skip to content

Fix ERA5 native6 fix to handle single monthly-averaged NetCDF files.#2512

Merged
bouweandela merged 25 commits into
mainfrom
era5_native6_monthly
Nov 14, 2025
Merged

Fix ERA5 native6 fix to handle single monthly-averaged NetCDF files.#2512
bouweandela merged 25 commits into
mainfrom
era5_native6_monthly

Conversation

@rbeucher

Copy link
Copy Markdown
Contributor

Description

Modifies the get_frequency function in ERA5 native6 fix to handle case where monthly-averaged data are stored in single NetCDF file (one file per month) and have thus a time dimension length of 1.

Closes #2511

Link to documentation:


Before you get started

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:

@rbeucher

Copy link
Copy Markdown
Contributor Author

Hi @schlunma, @valeriupredoi,

Could someone please take a moment to review this for me? Thanks!

R

@codecov

codecov Bot commented Nov 25, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.42%. Comparing base (cbb23dc) to head (0b6af74).
⚠️ Report is 98 commits behind head on main.

Files with missing lines Patch % Lines
esmvalcore/cmor/_fixes/native6/era5.py 91.30% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2512      +/-   ##
==========================================
- Coverage   95.46%   95.42%   -0.04%     
==========================================
  Files         260      260              
  Lines       15526    15513      -13     
==========================================
- Hits        14822    14804      -18     
- Misses        704      709       +5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@valeriupredoi valeriupredoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looking good @rbeucher - and biy did you have to wait for a review - sorry 🍺 @schlunma @sloosvel maybe we can squeeze this one in 2.12?

@schlunma schlunma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This currently breaks support for daily ERA5 data that has been added in #2178.

@github-actions

github-actions Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

In order to maintain a backlog of relevant pull requests, we automatically label them as stale after 180 days of inactivity.

If this pull request is still important to you, please comment below to remove the stale label. Otherwise, this pull request will be automatically closed in 60 days. If this pull request only suffers from a lack of reviewers, please tag the @ESMValGroup/technical-lead-development-team so they can help you find a suitable reviewer.

@github-actions github-actions Bot added the Stale label Sep 2, 2025
@flicj191

Copy link
Copy Markdown
Contributor

I will look into this again to fix the single monthly files

@github-actions github-actions Bot removed the Stale label Sep 16, 2025
@flicj191

Copy link
Copy Markdown
Contributor

@schlunma @valeriupredoi @ESMValGroup/esmvaltool-developmentteam
Can we get this re-checked please?
FYI @rbeucher

@bouweandela

Copy link
Copy Markdown
Member

We discussed this feature in the associated issue, and there I suggested #2511 (comment). Does that not work?

@flicj191

flicj191 commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

We discussed this feature in the associated issue, and there I suggested #2511 (comment). Does that not work?

Ah I missed that sorry, I'll test it out and found that it still runs the get_frequency each time for class AllVars here:

self._fix_monthly_time_coord(cube)

def _fix_monthly_time_coord(cube):
"""Set the monthly time coordinates to the middle of the month."""
if get_frequency(cube) == "monthly":

I can change this part in this PR

@flicj191

Copy link
Copy Markdown
Contributor

@bouweandela I've updated, let me know what you think. thanks!

@bouweandela bouweandela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fine now. I wonder if we could completely get rid of the get_frequency function?

It would be nice to add a unit test, could you do that?

Comment thread esmvalcore/cmor/_fixes/native6/era5.py Outdated

@flicj191 flicj191 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing get_frequency I had to parse the frequency to fix_hourly_time_coordinate and fix_accumulated_units which I think works, similar to _fix_monthly_time_coord but the tests are failing, not sure what i'm missing? the fixes aren't applied? @bouweandela

Comment thread esmvalcore/cmor/_fixes/native6/era5.py
@flicj191

flicj191 commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

I have reverted the changes of removing the get_frequency function, more testing was showing that it wasn't working if frequency wasn't defined first in the dataset which doesn't seem to be common practise so would still be useful to have.

@bouweandela

Copy link
Copy Markdown
Member

@flicj191 In #2855 I've changed the test so it is more realistic and you can see that a frequency keyword argument is now always supplied.

@bouweandela bouweandela dismissed schlunma’s stale review November 14, 2025 17:03

Pull request has changed since review and @schlunma is currently on leave.

@bouweandela bouweandela merged commit 7b4a097 into main Nov 14, 2025
3 of 4 checks passed
@bouweandela bouweandela deleted the era5_native6_monthly branch November 14, 2025 17:04
@schlunma schlunma added the fix for dataset Related to dataset-specific fix files label Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix for dataset Related to dataset-specific fix files

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

ERA5 Native6 Fix cannot handle single monthly-averaged files

5 participants