Skip to content

Commit

Permalink
Merge pull request #161 from bird-house/add-cf-and-data-options
Browse files Browse the repository at this point in the history
Add CFcompliance and data_validation to the process options
  • Loading branch information
aulemahal authored Mar 25, 2021
2 parents 1c3566b + 7a2e440 commit cdb13ce
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 203 deletions.
230 changes: 91 additions & 139 deletions docs/source/notebooks/dap_subset.ipynb

Large diffs are not rendered by default.

109 changes: 49 additions & 60 deletions docs/source/notebooks/finch-usage.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion finch/processes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
RequestInputs = Dict[str, Deque[PywpsInput]]

# These are parameters that set options. They are not `compute` arguments.
INDICATOR_OPTIONS = ['check_missing', 'missing_options']
INDICATOR_OPTIONS = ['check_missing', 'missing_options', "cf_compliance", "data_validation"]


def log_file_path(process: Process) -> Path:
Expand Down
8 changes: 7 additions & 1 deletion finch/processes/wps_bccaqv2_heatwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ def __init__(self):
inputs = [
i
for i in self.indices_process.inputs
if i.identifier not in ["tasmin", "tasmax"]
if i.identifier not in ["tasmin", "tasmax", "data_validation"]
]

# For BCCAQv2, relaxe data validation strictness.
data_valid = wpsio.data_validation.clone()
data_valid.data = 'warn'

inputs += [
wpsio.lon,
wpsio.lat,
Expand All @@ -63,6 +68,7 @@ def __init__(self):
data_type="integer",
min_occurs=0,
),
data_valid,
wpsio.output_format_netcdf_csv,
]

Expand Down
8 changes: 7 additions & 1 deletion finch/processes/wps_xclim_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ def __init__(self):
wpsio.output_metalink,
]

common = [wpsio.check_missing, wpsio.missing_options, wpsio.variable_any]
common = [
wpsio.check_missing,
wpsio.missing_options,
wpsio.cf_compliance,
wpsio.data_validation,
wpsio.variable_any
]

super().__init__(
self._handler,
Expand Down
31 changes: 30 additions & 1 deletion finch/processes/wpsio.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@

from pywps import FORMATS, ComplexInput, ComplexOutput, LiteralInput
from pywps.inout.literaltypes import AnyValue
from xclim.core.options import CHECK_MISSING, MISSING_METHODS, MISSING_OPTIONS, OPTIONS
from xclim.core.options import (
CHECK_MISSING,
CF_COMPLIANCE,
DATA_VALIDATION,
_LOUDNESS_OPTIONS,
MISSING_METHODS,
MISSING_OPTIONS,
OPTIONS
)

from .constants import ALL_24_MODELS, ALLOWED_MODEL_NAMES
from .utils import PywpsInput, PywpsOutput
Expand Down Expand Up @@ -186,6 +194,27 @@ def copy_io(
abstract="JSON representation of dictionary of missing method parameters.",
default=json.dumps(OPTIONS[MISSING_OPTIONS][OPTIONS[CHECK_MISSING]]),
supported_formats=[FORMATS.JSON],
min_occurs=0,
)


cf_compliance = LiteralInput(
"cf_compliance",
"Strictness level for CF-compliance input checks.",
abstract="Whether to log, warn or raise when inputs have non-CF-compliant attributes.",
data_type="string",
default=OPTIONS[CF_COMPLIANCE],
allowed_values=['log', 'warn', 'raise'],
)


data_validation = LiteralInput(
"data_validation",
"Strictness level for data validation input checks.",
abstract="Whether to log, warn or raise when inputs fail data validation checks.",
data_type="string",
default=OPTIONS[DATA_VALIDATION],
allowed_values=['log', 'warn', 'raise'],
)


Expand Down
2 changes: 2 additions & 0 deletions tests/test_wps_xclim_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def test_indicators_processes_discovery(indicator):
parameters = set([k for k in sig.parameters.keys() if k != "phase"])
parameters.add("check_missing")
parameters.add("missing_options")
parameters.add("cf_compliance")
parameters.add("data_validation")
parameters.add("variable")
if "indexer" in parameters:
parameters.remove("indexer")
Expand Down

0 comments on commit cdb13ce

Please sign in to comment.