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

Check presence of time bounds and guess them if needed #849

Merged
merged 25 commits into from
Mar 2, 2021

Conversation

sloosvel
Copy link
Contributor

@sloosvel sloosvel commented Oct 28, 2020

A check for the presence of time bounds has been added. If they are required but they are not present, they are guessed with the following criteria:

  • hourly, 3hourly, 6hourly and daily data: the bounds are set considering the corresponding delta time.

  • Monthly data: the minimum bound is set at the first day of the month at 00h. The maximum bound is set at the first day of the next month at 00h.

  • Yearly data: the minimum bound is set at the first day of the year at 00h. The maximum bound is set at the first day of the next year at 00h.

  • Decadal data: the minimum bound is set at the first day of the year at 00h. The maximum bound is set at the first day of the next ten years at 00h.
    Before you start, please read our contribution guidelines.

Tasks

  • Create an issue to discuss what you are going to do, if you haven't done so already (and add the link at the bottom)
  • This pull request has a descriptive title that can be used in a changelog
  • Add unit tests
  • Public functions should have a numpy-style docstring so they appear properly in the API documentation. For all other functions a one line docstring is sufficient.
  • If writing a new/modified preprocessor function, please update the documentation
  • Circle/CI tests pass. Status can be seen below your pull request. If the tests are failing, click the link to find out why.
  • Codacy code quality checks pass. Status can be seen below your pull request. If there is an error, click the link to find out why. If you suspect Codacy may be wrong, please ask by commenting.
  • Please use yamllint to check that your YAML files do not contain mistakes
  • If you make backward incompatible changes to the recipe format, make a new pull request in the ESMValTool repository and add the link below

If you need help with any of the tasks above, please do not hesitate to ask by commenting in the issue or pull request.


Closes #802 , closes #803

@sloosvel sloosvel added the cmor Related to the CMOR standard label Oct 28, 2020
@bouweandela bouweandela requested a review from Peter9192 January 22, 2021 17:06
@Peter9192
Copy link
Contributor

Hi @sloosvel let's see if we can get this merged. I can do a round of review (already had a quick look, seems good). But before I continue with testing etc., can you

  • merge master and see if there are any remaining failing tests, and
  • see if you can address the codacy issues?

In general, I think your approach at guessing the bounds looks very decent. Actually, another place in the code where we guess time bounds is in the regrid time preprocessor:

cube.coord('time').guess_bounds()

I'd say your approach here looks better, and I wonder if we could/should somehow make them consistent and at the same time avoid code duplication. Any thoughts on that?

@sloosvel
Copy link
Contributor Author

I'd say your approach here looks better, and I wonder if we could/should somehow make them consistent and at the same time avoid code duplication. Any thoughts on that?

I guess some lines could be moved as functions to either _time.py or _shared.py?

@sloosvel
Copy link
Contributor Author

I don't think I can fix the remaining Codacy issues.

@Peter9192
Copy link
Contributor

Great, now the tests pass :-)

I guess some lines could be moved as functions to either _time.py or _shared.py?

Yes, a _guess_time_bounds function in _time.py sounds like a great feature to me. I think that'll also solve the 1001-line codacy complaint, and the others are indeed not new so I'm okay with leaving those.

Copy link
Contributor

@Peter9192 Peter9192 left a comment

Choose a reason for hiding this comment

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

Hey @sloosvel,
This PR does what it says, so in principle I'm already convinced we should merge it. I just have a few remaining questions that I'm hoping you could help me with, especially regarding the tests.

@sloosvel
Copy link
Contributor Author

Is there anything left to address here? I added new tests as requested.

@Peter9192 Peter9192 self-requested a review February 26, 2021 09:18
@Peter9192
Copy link
Contributor

I'll try to have another look today or otherwise early next week. Last time I checked I wasn't sure if you were still working on it.

@sloosvel
Copy link
Contributor Author

No problem! I kind of put it aside because of things I had pending for the release.

@Peter9192
Copy link
Contributor

Looks good! All tests pass locally. I just merged master to verify that they also pass on CI with the most recent changes.

@Peter9192
Copy link
Contributor

Okay just one more thing: could you have another look at the codacy issue? I don't see the circular imports if I try to move it to the top. All greens would help to get it merged :-)

@Peter9192
Copy link
Contributor

Thanks @sloosvel happy to see this merged :-)

@bouweandela bouweandela merged commit 68196fe into master Mar 2, 2021
@bouweandela bouweandela deleted the dev_check_time_bounds branch March 2, 2021 10:29
@bouweandela bouweandela mentioned this pull request Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmor Related to the CMOR standard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better time bounds in regrid_time preprocessor CMOR check for time bounds
4 participants