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

Support indexer in schema.yml, add usage example in example.yml #1561

Merged
merged 10 commits into from
Jan 11, 2024
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