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

Fix LFRic time coordinate metadata #1117

Merged
merged 16 commits into from
Feb 13, 2025
Merged

Fix LFRic time coordinate metadata #1117

merged 16 commits into from
Feb 13, 2025

Conversation

jwarner8
Copy link
Contributor

@jwarner8 jwarner8 commented Feb 4, 2025

Fixes LFRic coordinate metadata, by adding forecast_period and forecast_reference_time, summarised in #1113

Contribution checklist

Aim to have all relevant checks ticked off before merging. See the developer's guide for more detail.

  • Documentation has been updated to reflect change.
  • New code has tests, and affected old tests have been updated.
  • All tests and CI checks pass.
  • Ensured the pull request title is descriptive.
  • Conda lock files have been updated if dependencies have changed.
  • Attributed any Generative AI, such as GitHub Copilot, used in this PR.
  • Marked the PR as ready to review.

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Coverage

Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

A small observation. Let me know when you want a proper review on this.

src/CSET/operators/read.py Outdated Show resolved Hide resolved
@jwarner8
Copy link
Contributor Author

jwarner8 commented Feb 6, 2025

A small observation. Let me know when you want a proper review on this.

THanks, did you say you were working off this branch for a more general cube time merge fix?

@jwarner8 jwarner8 self-assigned this Feb 6, 2025
@jwarner8 jwarner8 requested a review from jfrost-mo February 6, 2025 15:39
@jfrost-mo
Copy link
Member

I'll get this reviewed and merged first.

Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

Looks good to me. The comments are minor formatting things, and I'm happy for you to merge after addressing them.

src/CSET/operators/read.py Outdated Show resolved Hide resolved
src/CSET/operators/read.py Outdated Show resolved Hide resolved
src/CSET/operators/read.py Show resolved Hide resolved
@jfrost-mo jfrost-mo self-requested a review February 7, 2025 14:54
Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

Some additional tests are needed.

@jwarner8 jwarner8 requested a review from jfrost-mo February 11, 2025 14:05
@jwarner8
Copy link
Contributor Author

Update 11/02: Have added tests, but some are not raising the correct errors as expected by pytest.

@jwarner8
Copy link
Contributor Author

I have fixed the tests, weirdly the LFRic cube (slammed_lfric_cube_readonly) already had forecast_reference_time and forecast_period. Anyway, ready for review now @jfrost-mo and to base your merge nc/pp fixes from.

@jwarner8
Copy link
Contributor Author

jwarner8 commented Feb 12, 2025

I have significantly rewritten the callback to use more conditionals rather than try except blocks, as read will take various data with missing coords and we dont want to keep raising keyerrors. So its more of a defensive function that tests if coords exist before proceeding to next step. cube.attributes returns empty list if no attributes, so shouldn't throw up errors in if "time_origin" in tcoord.attributes:

Now ready to review now this is more defensive

Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

Overall looking sensible. A couple code changes suggested, mainly to the tests.

src/CSET/operators/read.py Outdated Show resolved Hide resolved
tests/operators/test_read.py Outdated Show resolved Hide resolved
tests/operators/test_read.py Outdated Show resolved Hide resolved
@jwarner8 jwarner8 requested a review from jfrost-mo February 13, 2025 14:08
Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

LGTM

@jfrost-mo
Copy link
Member

There are some conflicts though. Are you happy to fix them or shall I?

@jwarner8
Copy link
Contributor Author

This branch has no conflicts with the base branch

Hmm, I see "This branch has no conflicts with the base branch"

@jfrost-mo
Copy link
Member

Strange. Try merging it; hopefully it is just on my end.

@jwarner8 jwarner8 merged commit 466fb74 into main Feb 13, 2025
8 checks passed
@jwarner8 jwarner8 deleted the time_callback branch February 13, 2025 14:29
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.

2 participants