Skip to content

Adding fix for ORAS5#2422

Open
jmalles wants to merge 46 commits into
mainfrom
oras5
Open

Adding fix for ORAS5#2422
jmalles wants to merge 46 commits into
mainfrom
oras5

Conversation

@jmalles

@jmalles jmalles commented May 17, 2024

Copy link
Copy Markdown
Contributor

Description

Fix for ORAS5. It includes the option to make the 'irregular' (2d) grid 'unstructured' (1d) and UGRID-compliant. To do so, one needs to add the extra facet 'make_unstructured: true' and/or 'ugrid: true' in the recipe.

The mesh description ('horizontal_grid' in the recipe) needs to be read from a file (oras5_mesh.zip), which is based on a file that can be downloaded here. Since ORAS5 data is on the ORCA025 (Arakawa-C grid), there are different mesh files for tracers (T), and zonal/meridional velocities (u/v).

An example recipe for ORAS5 can be found here.

Some already downloaded data are stored here:
/work/bd1083/b382555/extraobsraw/Tier2/ORAS5/data

(for 3D data in all_levels so far usually only short time periods are downloaded, due to their size)

The grid files are also stored on Levante:
/work/bd1083/b382555/extraobsraw/Tier2/ORAS5/grids

Link to documentation: https://esmvaltool--2422.org.readthedocs.build/projects/ESMValCore/en/2422/quickstart/find_data.html#oras5


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:

@codecov

codecov Bot commented Dec 2, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.14%. Comparing base (6d1872e) to head (557e03a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2422      +/-   ##
==========================================
- Coverage   96.18%   96.14%   -0.05%     
==========================================
  Files         271      272       +1     
  Lines       15913    16089     +176     
==========================================
+ Hits        15306    15468     +162     
- Misses        607      621      +14     

☔ View full report in Codecov by Harness.
📢 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.

@jmalles jmalles requested a review from bettina-gier December 5, 2024 09:58
@jmalles jmalles marked this pull request as ready for review December 5, 2024 10:14
@bettina-gier

Copy link
Copy Markdown
Contributor

Tried with the example recipe and it looks good, output seems as expected. Fast look through the code looks good. I'll do a more detailed review when I have more time.

@schlunma

Copy link
Copy Markdown
Contributor

Hi @jmalles, thanks for contributing!

To start the review process and finalize this, we need tests (see e.g., here) and some documentation (see e.g, here). Thanks!!

Jan-Hendrik Malles and others added 2 commits December 2, 2025 13:31
@katjaweigel katjaweigel added this to the v2.14.0 milestone Dec 11, 2025
@schlunma

Copy link
Copy Markdown
Contributor

Hello, this pull request has been marked with the v2.14.0 milestone. The release of version 2.14.0 is currently scheduled for February 2026. To get this into the new release, it would be great to get this merged by the end of January.

If you won't be able to finish this in time, don't worry - just unassign the milestone v2.14.0. If you need any support, ping myself (@schlunma; the release manager for v2.14.0) or the @ESMValGroup/technical-lead-development-team. Please note that I won't be available until the beginning of February, though.

@jmalles jmalles requested a review from valeriupredoi January 20, 2026 15:02
@schlunma

schlunma commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

I am sorry, it looks like this pull request won't make it into v2.14.0. If there are strong objections, please let me know. Moving this to v2.15.0.

@schlunma schlunma modified the milestones: v2.14.0, v2.15.0 Feb 3, 2026
@CLAassistant

CLAassistant commented May 20, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

✅ jmalles
✅ katjaweigel
✅ valeriupredoi
❌ Jan-Hendrik Malles


Jan-Hendrik Malles seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rbeucher

Copy link
Copy Markdown
Contributor

Hi all, a quick note for the ESMValCore v2.15.0 release: the planned code freeze date is 19 June 2026.

This PR is currently included in the v2.15.0 milestone. Could you please confirm whether it is still intended for this release and what needs to happen before it can be merged?

@flicj191 tagging you for release planning visibility.

@jmalles

jmalles commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Hello, I will try to get the code coverage to 100% today or tomorrow. Then someone would need to review it, I suppose.

@bettina-gier

Copy link
Copy Markdown
Contributor

@ghossh Hey Supriyo, Jan has updated the tests now to increase the coverage. Can you have a look and do a review please? <3

@ghossh

ghossh commented Jun 12, 2026

Copy link
Copy Markdown

Hi @bettina-gier , I'm going on holiday after today and coming back on 28th Jun. I'll take a look afterward.

@bettina-gier

Copy link
Copy Markdown
Contributor

ah nvm then, that's after the core feature freeze where we want to have this in. I'll see if I can do it next week instead then..

Comment thread esmvalcore/config-developer.yml
jmalles added 2 commits June 18, 2026 09:01
Removed instructions for placing data files in specific subdirectories.

@bettina-gier bettina-gier 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.

It runs, results look fine. Might be nice to add a sample config for the filename even if it's in a flat folder.

@alistairsellar Is it possible to do some sort of manual CLA override? Jan signed on the github account but most commits are under a faulty config that can't sign. Otherwise we would have to somehow rebase the commits.

@alistairsellar

alistairsellar commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Is it possible to do some sort of manual CLA override?

Hi @bettina-gier. There's no way to override the CLA list of signatories if GitHub doesn't think that a commit is linked to a GitHub account. What I would suggest is that if you know for certain that all commits in a PR have been made by people who have signed the CLA (like in this case), then you can temporarily switch off the branch protection that looks at the CLA check. (This aligns with the spirit of why we need the CLA.) And then switch the rule back on again after the PR is merged.

Happy to do the switch-off when you're ready to merge, though I expect you've got permissions to change rules?

@bettina-gier

Copy link
Copy Markdown
Contributor

I personally don't have permissions for that I believe. I'll ask for a quick final tech review before merge!

@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 good! To wrap it up, could you please add a bit more documentation about the various facets that can be used from the recipe to control the grid and remove code that was copy/pasted from the ICON fix but does not apply to ORAS5?

cube: iris.cube.Cube
Cube for which the ORS5 horizontal grid is retrieved. If the facet
`horizontal_grid` is not specified by the user, it raises a
NotImplementedError.

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.

typically you would use a KeyError for this, or possibly a ValueError. NotImplementedError is for things that have not (yet) been implemented.

Comment on lines +133 to +135
raise NotImplementedError(
msg,
)

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.

Suggested change
raise NotImplementedError(
msg,
)
raise NotImplementedError(msg)


# Predetermine how to handle grid
make_unstructured = self.extra_facets.get("make_unstructured", False)
u_grid = self.extra_facets.get("ugrid", False)

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.

I see that there are multiple facets that may be specified in the recipe to make this data work. Could you please add documentation for those?

Comment on lines +332 to +334
raise ValueError(
msg,
)

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.

Suggested change
raise ValueError(
msg,
)
raise ValueError(msg)

Comment on lines +466 to +467
the ORAS5 fix is located `here
<https://github.com/ESMValGroup/ESMValCore/blob/main/esmvalcore/cmor/_fixes/native6/oras5.py>`__,

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.

Suggested change
the ORAS5 fix is located `here
<https://github.com/ESMValGroup/ESMValCore/blob/main/esmvalcore/cmor/_fixes/native6/oras5.py>`__,

these are intended as examples, there is no need to list everything and three examples seems a bit much


def test_get_mesh_not_cached_from_facet(monkeypatch, tmp_path):
"""Test fix."""
session = CFG.start_session("my session")

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.

Please use the session fixture instead.

Comment on lines +142 to +143
"horizontal_grid",
"Horizontal grid file",

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.

Please add documentation on how to use these facets


def fix_metadata(self, cubes: CubeList) -> CubeList:
"""Fix metadata."""
cubes = self.add_additional_cubes(cubes)

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.

Is this feature needed for ORAS5?


def test_add_coord_from_grid_fail_no_unnamed_dim(cubes_2d):
"""Test fix."""
# Remove latitude from tas cube to test automatic addition

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.

This comment appears multiple times throughout this file but does not seem to be related to the test it is part of. Is it a result of copy/pasting another test and modifying that?

fix = get_allvars_fix("Omon", "tos")
fix.extra_facets["frequency"] = frequency

fix._shift_time_coord(cube, time_coord)

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.

This test appears to have been copy/pasted from

# Test _shift_time_coord
@pytest.mark.parametrize(
("frequency", "dt_in", "dt_out", "bounds"),
[
(
"dec",
[(2000, 1, 1)],
[(1995, 1, 1)],
[[(1990, 1, 1), (2000, 1, 1)]],
),
(
"yr",
[(2000, 1, 1), (2001, 1, 1)],
[(1999, 7, 2, 12), (2000, 7, 2)],
[[(1999, 1, 1), (2000, 1, 1)], [(2000, 1, 1), (2001, 1, 1)]],
),
(
"mon",
[(2000, 1, 1)],
[(1999, 12, 16, 12)],
[[(1999, 12, 1), (2000, 1, 1)]],
),
(
"mon",
[(2000, 11, 30, 23, 45), (2000, 12, 31, 23)],
[(2000, 11, 16), (2000, 12, 16, 12)],
[[(2000, 11, 1), (2000, 12, 1)], [(2000, 12, 1), (2001, 1, 1)]],
),
(
"day",
[(2000, 1, 1, 12)],
[(2000, 1, 1)],
[[(1999, 12, 31, 12), (2000, 1, 1, 12)]],
),
(
"6hr",
[(2000, 1, 5, 14), (2000, 1, 5, 20)],
[(2000, 1, 5, 11), (2000, 1, 5, 17)],
[
[(2000, 1, 5, 8), (2000, 1, 5, 14)],
[(2000, 1, 5, 14), (2000, 1, 5, 20)],
],
),
(
"3hr",
[(2000, 1, 1)],
[(1999, 12, 31, 22, 30)],
[[(1999, 12, 31, 21), (2000, 1, 1)]],
),
(
"1hr",
[(2000, 1, 5, 14), (2000, 1, 5, 15)],
[(2000, 1, 5, 13, 30), (2000, 1, 5, 14, 30)],
[
[(2000, 1, 5, 13), (2000, 1, 5, 14)],
[(2000, 1, 5, 14), (2000, 1, 5, 15)],
],
),
],
)
def test_shift_time_coord(frequency, dt_in, dt_out, bounds):
"""Test ``_shift_time_coord``."""
cube = Cube(0, cell_methods=[CellMethod("mean", "time")])
datetimes = [datetime(*dt) for dt in dt_in]
time_units = Unit("days since 1950-01-01", calendar="proleptic_gregorian")
time_coord = DimCoord(
time_units.date2num(datetimes),
standard_name="time",
var_name="time",
long_name="time",
units=time_units,
)
fix = get_allvars_fix("Amon", "tas")
fix.extra_facets["frequency"] = frequency
fix._shift_time_coord(cube, time_coord)
dt_out = [datetime(*dt) for dt in dt_out]
bounds = [[datetime(*dt1), datetime(*dt2)] for (dt1, dt2) in bounds]
np.testing.assert_allclose(
time_coord.points,
time_coord.units.date2num(dt_out),
)
np.testing.assert_allclose(
time_coord.bounds,
time_coord.units.date2num(bounds),
)
. Since the _shift_time_coord method is only defined on the base class and not modified in the file oras5.py, there is no need to test it again. To keep the code easy to maintain, I would suggest removing it here. The same goes for the other copy/pasted tests further down that do not apply to the oras5.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.