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

Generic indicators not recognized as "core xclim indicator" in the registry. #1423

Closed
2 tasks done
aulemahal opened this issue Jul 24, 2023 · 0 comments · Fixed by #1424
Closed
2 tasks done

Generic indicators not recognized as "core xclim indicator" in the registry. #1423

aulemahal opened this issue Jul 24, 2023 · 0 comments · Fixed by #1424
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aulemahal
Copy link
Collaborator

Setup Information

  • Xclim version: master
  • Python version: all
  • Operating System: all

Description

When creating a new indicator in a "virtual" module, and pointing the "base" indicator to one of the "xclim.generic.*" indicators, constructing the module fails with:

ValueError: Requested base class stats is neither in the indicators registry nor in base classes registry.

Steps To Reproduce

The following yaml module specification builds "QMOY" from xclim.generic.stats.

realm: land
indicators:
  JQ1MAXHP:
    base: doy_qmax
    input:
      da: discharge
    parameters:
      indexer: {month: [12, 1, 2, 3, 4, 5]}
  QMOY:
    base: stats
    input:
      da: discharge
    parameters:
      op: mean

into test.yml.

import xclim as xc
xc.build_indicator_module_from_yaml('test.yml')

Additional context

This is because of

if submodule not in ["atmos", "land", "ocean", "seaIce"]:
, where "generic" is absent. Moreover, all "generic" indicators are declared by instantiation of base classes imported from xclim.core.indicator. Which means the module assigned by the interpreter will be xclim.core.indicators, which will fail the test linked above anyway.

The way we decide which indicator is "core" and which isn't should be changed. For reference, the only difference between both is that "core" indicator are referred to in the registry by their identifier, while the others have a module name prepended (ex: "cf.TMMEAN", "anuclim.P1_ANNMEANTEMP" vs "TG_MEAN"). The registry key is what must be written in the "base:" field of a virtual module.

The short-term solution is to write "xclim.core.indicator.STATS" to use the generic "stats" indicator.

Contribution

  • I would be willing/able to open a Pull Request to address this bug.

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants