Ouranosinc / xscen

A climate change scenario-building analysis framework.
https://xscen.readthedocs.io/
Apache License 2.0
15 stars 2 forks source link

Stricter build_path / better end_of_period #237

Closed aulemahal closed 1 year ago

aulemahal commented 1 year ago

Pull Request Checklist:

What kind of change does this PR introduce?

Two different things, but that I both realized when updating the catalogs.

Stricter build_path

When I migrated from miranda, I relaxed the "structure" code because it felt too restricting and I wanted to simplify the logic. However, this wasn't a good idea. When moving the ESPO-R5-E5L indicators, I forgot to include the "experiment" field somewhere and used build_path to copy the files. Result : one scenario overwrote the other, I lost half of the data.

This PR changes the things a bit, the main change being : All facets, except those marked optional, are necessary. build_path will FAIL if any is missing.

And:

Better end_of_period

When I updated pandas to 2, I modified date_parser and it changed how the "end_of_period" was handled.

date_parser('2020', end_of_period=True)
# Initial xscen: "2020-12-31 23:00"
# Current xscen : "2020-12-31 00:00:00"
# This PR: "2020-12-31 23:59:59"

Thus, when searching for a coverage, the error due to the hour of the period end will be reduced.

Does this PR introduce a breaking change?

build_path is now always strict.

Other information:

Do you agree?

I could re-implement strict=False if needed. It would mark all fields as optional on-the-fly. The default would stay "True".