Skip to content

Commit

Permalink
add context='infer' (#1299)
Browse files Browse the repository at this point in the history
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [ ] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #xyz
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] HISTORY.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

### What kind of change does this PR introduce?

* Adding 'infer' context in the unit conversion of the training of
ExtremeValues. The goal is to be able to pass a threshold in mm d-1 even
if the ref is in kg m-2 s-1.

### Does this PR introduce a breaking change?
A threshold in mm d-1 used to work, then it didn't with the addition of
the `context` arg, but now it works again!

### Other information:
ExtremeValues is often used with precipitation data.
  • Loading branch information
juliettelavoie committed Feb 24, 2023
2 parents a30d903 + 118702c commit 7f87c4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Internal changes
* Added `[radiation]` (`[power] / [area]`) to list of defined acceptable units. (:pull:`1271`).
* Updated testing data used to generate the `atmosds` dataset to use more reproducibly-converted ERA5 data, generated with the `miranda` Python package. (:pull:`1269`).
* Updated testing dependencies to use `pytest-xdist>=3.2`, allowing for the new `--dist=worksteal` scheduler for distributing the pool of remaining tests across workers after individual workers have exhausted their own queues. (:pull:`1235`).
* Adding infer context to the unit conversion in of the training of ExtremeValues. (:pull:`1299`).

0.40.0 (2023-01-13)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion xclim/sdba/adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def _train(
ref_params: xr.Dataset = None,
q_thresh: float = 0.95,
):
cluster_thresh = convert_units_to(cluster_thresh, ref)
cluster_thresh = convert_units_to(cluster_thresh, ref, context="infer")

# Approximation of how many "quantiles" values we will get:
N = (1 - q_thresh) * ref.time.size
Expand Down

0 comments on commit 7f87c4f

Please sign in to comment.