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

Use AllowedValue to constrain indicator arguments to the positive domain #124

Open
huard opened this issue Apr 22, 2020 · 5 comments
Open
Assignees

Comments

@huard
Copy link
Collaborator

huard commented Apr 22, 2020

Description

For example, see arguments in

  • Wet Days
  • Simple Daily Intensity Index
  • Heat Wave Total length
  • Heat Wave
  • Heat Wave Frequency (nombre de jours toujours positif)
  • Maximum Number of Consecutive Wet Days
  • Cold Spell Duration
  • Cold Spell Days
  • Maximum Number of Consecutive Dry Days
@huard
Copy link
Collaborator Author

huard commented Apr 22, 2020

@dbyrns In the climatedata.ca frontend, the fact some parameters could be given negative values even if it makes no sense was flagged as a potential issue. I'm wondering if this is something that should be fixed upstream, either in Finch or even in xclim. Thoughts ? PyWPS has an AllowedValue class that we could use, but ideally the Finch wrapper would take instructions from xclim.

@dbyrns
Copy link

dbyrns commented Apr 23, 2020

In Finch, the AllowedValue could indeed specify a range with a minimum value of 0.
Since Finch create the pywps inputs by parsing attributes of xclim function (

# Ideally this would be based on the Parameters docstring section rather than name conventions.
) we could build on the naming convention or explore the docstring proposition...

@dbyrns
Copy link

dbyrns commented Apr 23, 2020

I cannot set an assignee, but @matprov could look at this.

@huard
Copy link
Collaborator Author

huard commented Apr 23, 2020

See Ouranosinc/xclim#364 (comment) for ideas on how to specify those constraints right from xclim, and then propagate them downstream. Comment and suggestions welcome.

@matprov matprov self-assigned this Apr 23, 2020
@aulemahal
Copy link
Collaborator

I'm doing a survey of all those stale issues.

Here, the last comments seem to point to xclim's kind mechanism on indicator arguments to obtain information about the allowed values. Currently the (stable) mechanism in xclim does not provide much information about this. Example : it has the "Number" kind, which doesn't tell anything about the allowed range.
Moreover, quantities (value + unit) are passed as strings and only parsed within xclim : pywps' AllowedValue can't do much here.

I'm not convinced xclim needs a strict input validator, so we could do that here, but it would need something more complex than filling AllowedValue. For example:

if kind is NUMBER and name == ''window":
    # ensure positive integer
elif kind is QUANTITY and units.diemsionality == "[precipitation]":
    # ensure positive
# etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants