Skip to content

Commit

Permalink
Support indexer in schema.yml, add usage example in example.yml (#1561
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:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #1522 
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] CHANGES.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?

* Adds indicator in example.yml with indexer parameter.
* Adds desription in schema for indexer parameter. 

### Does this PR introduce a breaking change?


### Other information:
Not sure this is all legit, or whether the test suite exercises the
computation of that new indicator.
  • Loading branch information
huard authored Jan 11, 2024
2 parents 784b418 + d84f460 commit b658876
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Added uncertainty partitioning method `lafferty_sriver` from Lafferty and Sriver (2023), which can partition uncertainty related to the downscaling method. (:issue:`1497`, :pull:`1529`).
* Validate YAML indicators description before trying to build module. (:issue:`1523`, :pull:`1560`).
* Support ``indexer`` keyword in YAML indicator description. (:issue:`1522`, :pull:`1561`).
* New ``xclim.core.calendar.stack_periods`` and ``unstack_periods`` for performing ``rolling(time=...).construct(..., stride=...)`` but with non-uniform temporal periods like years or months. They replace ``xclim.sdba.processing.construct_moving_yearly_window`` and ``unpack_moving_yearly_window`` which are deprecated and will be removed in a future release.

Breaking changes
Expand Down
6 changes: 6 additions & 0 deletions docs/notebooks/example/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ indicators:
freq:
default: YS
references: ETCCDI
spring_fd:
compute: frost_days
parameters:
freq: AS-DEC
indexer:
month: [ 12, 1, 2 ]
R95p:
compute: extreme_precip_accumulation_and_days
cf_attrs:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ values = [
"release"
]


[tool.codespell]
skip = 'xclim/data/*.json,docs/_build,docs/notebooks/xclim_training/*.ipynb,docs/references.bib,__pycache__,*.nc,*.png,*.gz,*.whl'
ignore-words-list = "absolue,astroid,bloc,bui,callendar,degreee,environnement,hanel,inferrable,lond,nam,nd,ressources,vas"
Expand Down
12 changes: 10 additions & 2 deletions xclim/data/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ indicator:
missing_options: map(key=str(), required=False)
notes: str(required=False)
cf_attrs: any(list(include('cf_attrs')), include('cf_attrs'), required=False)
parameters: map(str(), num(), bool(), null(), include('parameter'), key=str(), required=False)
parameters: map(str(), num(), bool(), null(), include('parameter'), include('indexer'), key=str(), required=False)
realm: str(required=False)
references: str(required=False)
title: str(required=False)
Expand All @@ -29,10 +29,18 @@ cf_attrs: map(str(), key=str(), required=False)

parameter:
description: str(required=False)
default: any(str(), num(), bool(), null(), required=False)
default: any(str(), num(), bool(), null(), include('indexer'), required=False)
choices: list(str(), required=False)
units: str(required=False)

indexer:
drop: bool(required=False)
month: any(int(), list(int()), required=False)
season: any(str(), list(str()), required=False)
doy_bounds: list(int(), required=False, maxItems=2)
date_bounds: list(str(), required=False, maxItems=2)
include_bounds: any(bool(), list(bool(), bool()), required=False, maxItems=2)

variable:
canonical_units: str(required=True)
cell_methods: str(required=False)
Expand Down

0 comments on commit b658876

Please sign in to comment.