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

Allow timestep to be set when XIOS handler is created #750

Merged
merged 7 commits into from
Dec 10, 2024

Conversation

jwallwork23
Copy link
Contributor

@jwallwork23 jwallwork23 commented Dec 4, 2024

Refinement of #751

Allow timestep to be set when XIOS handler is created

This PR makes a few minor modifications to the Xios handler object:

  • Improve clarity of docstrings related to configuration.
  • Allow the user to set the timestep, calendar type and context ID when creating the Xios instance.
  • Set the calendar origin and start as part of the configuration.
  • Update tests accordingly.

These steps should make it easier to set up XIOS and reduce the amount of additional boilerplate when using it to drive I/O rather than the existing approach.

@jwallwork23 jwallwork23 added the enhancement New feature or request label Dec 4, 2024
@jwallwork23 jwallwork23 self-assigned this Dec 4, 2024
Comment on lines 128 to 130
// Set default calendar origin and start // TODO: Pick something sensible
setCalendarOrigin(TimePoint("2020-01-23T00:08:15Z"));
setCalendarStart(TimePoint("2023-03-17T17:11:00Z"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any thoughts on suitable default calendar origin and start times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the start will be read from the config file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The time classes in the rest of nextSIM use the Unix epoch as their calendar origin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, now addressed in 542da5b.

Comment on lines 150 to 152
std::string _calendarType;
std::string _contextId;
Duration _timestep;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless this is an XIOS convention, I'd discourage leading underscores in nextSIM code, since we generally try to align with the WebKit coding standard (albeit imperfectly).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, addressed in 197d747.

Copy link
Collaborator

@timspainNERSC timspainNERSC left a comment

Choose a reason for hiding this comment

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

Some suggested changes.

Comment on lines 51 to 53
REQUIRE(xios_handler.getCalendarTimestep().seconds() == doctest::Approx(3600.0)); // Default
Duration timestep("P0-0T01:30:00");
REQUIRE(timestep.seconds() == doctest::Approx(5400.0));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that testing floating point values can be imprecise, but I'd suggest that if we don't get back the exact integer values of 3600 and 5400, that should also be a test failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - fixed in 2eec43f.

@jwallwork23
Copy link
Contributor Author

I also provided the option to set the calendar start upon creating an Xios instance.

@jwallwork23
Copy link
Contributor Author

I just pushed a couple of small commits:

  • cd35f66 throws errors if the getter for a calendar attribute is called before it's been set.
  • 0eae60a fixes a minor bug in the pre-commit.

@jwallwork23
Copy link
Contributor Author

@timspainNERSC please could you re-review this? I think I addressed all your concerns.

.pre-commit Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to merge these changes as part of this PR, rather than in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd figured it was a very small change so didn't know if it warranted it's own PR. But yeah, it'd be better practice to put it in a separate PR. I'll do that now.

Copy link
Collaborator

@timspainNERSC timspainNERSC left a comment

Choose a reason for hiding this comment

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

All looks good. But just make sure that the changes to .per-commit are best added as part of this PR.

@jwallwork23
Copy link
Contributor Author

All looks good. But just make sure that the changes to .per-commit are best added as part of this PR.

Thanks @timspainNERSC!

@jwallwork23 jwallwork23 merged commit 225adcf into develop Dec 10, 2024
4 checks passed
@jwallwork23 jwallwork23 deleted the init-timestep branch December 10, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants