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

Conditions to match ref.time & hist.time, and also ref.time.size & sim.time.size #1995

Merged
merged 32 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
561f812
check_matching_time method: ref & hist must match
coxipi Nov 13, 2024
85f4f9f
add pull number
coxipi Nov 13, 2024
7dc378e
Merge branch 'main' into check_matching_times
coxipi Nov 18, 2024
553716b
Merge branch 'main' into check_matching_times
coxipi Nov 19, 2024
60cd830
add new class attr
coxipi Nov 25, 2024
bb69de3
Merge branch 'main' of https://github.com/Ouranosinc/xclim into check…
coxipi Nov 25, 2024
d42044f
Adjust can modify sim time if needed
coxipi Nov 25, 2024
90053c5
add tests
coxipi Nov 25, 2024
c037542
add skip if OT not installed
coxipi Nov 26, 2024
7ed51be
clearer attrs, more checks
coxipi Nov 27, 2024
ac12ab5
update CHANGELOG
coxipi Nov 27, 2024
4c873fe
typo
coxipi Nov 27, 2024
1a11cb6
more checks in many classes
coxipi Nov 27, 2024
e1aca56
LOCI check calendars
coxipi Nov 27, 2024
57ccf19
forgot to refactor in tests
coxipi Nov 27, 2024
e4a1a40
more refactoring to pass on and add new test
coxipi Nov 27, 2024
60a920b
second test has a more general signature
coxipi Nov 27, 2024
e9ea021
fix conda (from :pull:1988)
coxipi Nov 27, 2024
c8caced
remove defaults, remove conda.anaconda.com override from lint
Zeitsperre Nov 28, 2024
7846418
allow connections to conda.anaconda.org
Zeitsperre Nov 26, 2024
c7241a7
use load_dataset with xr.tutorial
coxipi Nov 28, 2024
f55c64b
Merge branch 'check_matching_times' of https://github.com/Ouranosinc/…
coxipi Nov 28, 2024
68cbb8d
temp deactivate time_size checks for OTC/dOTC
coxipi Nov 28, 2024
6331679
remove test_different_times for now
coxipi Nov 28, 2024
d385c2e
change nan handling in dOTC
coxipi Nov 28, 2024
d17489c
Merge branch 'check_matching_times' of https://github.com/Ouranosinc/…
coxipi Nov 28, 2024
5278a0e
remove test print
coxipi Nov 28, 2024
6584953
Fix nan handling in dOTC (#2005)
coxipi Nov 28, 2024
ddba143
add fix nan handling description
coxipi Nov 28, 2024
880f98c
refactor var name
coxipi Nov 28, 2024
066d3f3
add training with different times possibility
coxipi Dec 9, 2024
58f0ada
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog

v0.54.0 (unreleased)
--------------------
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`).
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Éric Dupuis (:user:`coxipi`).

Breaking changes
----------------
Expand All @@ -17,6 +17,7 @@ Bug fixes
Internal changes
^^^^^^^^^^^^^^^^
* Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`).
* Using different time for `ref` and `hist` is now explicitly forbidden in many bias adjustment methods (e.g. `EmpiricalQuantileMapping`). (:issue:`1903`, :pull:`1995`)

v0.53.2 (2024-10-31)
--------------------
Expand Down
11 changes: 11 additions & 0 deletions xclim/sdba/adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ def __convert_units_to(_input_da, _internal_dim, _internal_target):
convert_units_to(inda, target, context="infer") for inda in inputs
), target

@classmethod
def _check_matching_time(cls, ref, hist):
"""Raise an error ref and hist times don't match."""
if all(ref.time == hist.time) is False:
raise ValueError("`ref` and `hist` should have the same time arrays.")

@classmethod
def _train(cls, ref, hist, **kwargs):
raise NotImplementedError()
Expand Down Expand Up @@ -258,6 +264,9 @@ def train(cls, ref: DataArray, hist: DataArray, **kwargs) -> TrainAdjust:
else:
train_units = ""

if cls._allow_diff_calendars is False:
cls._check_matching_time(ref, hist)

coxipi marked this conversation as resolved.
Show resolved Hide resolved
ds, params = cls._train(ref, hist, **kwargs)
obj = cls(
_trained=True,
Expand Down Expand Up @@ -1737,6 +1746,8 @@ class MBCn(TrainAdjust):
Only "time" and "time.dayofyear" (with a suitable window) are implemented as possible values for `group`.
"""

_allow_diff_calendars = False

@classmethod
def _train(
cls,
Expand Down
Loading