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

Allow formatting to parse the inputs' attributes #975

Open
aulemahal opened this issue Jan 11, 2022 · 0 comments
Open

Allow formatting to parse the inputs' attributes #975

aulemahal opened this issue Jan 11, 2022 · 0 comments
Labels
enhancement New feature or request support Questions and help for users/developers

Comments

@aulemahal
Copy link
Collaborator

In #967, we are implementing a new kind of indices for computing statistical properties of sdba outputs and inputs. In opposition to the conventional indices of the core library, they are unit-independent. The same function is meant to be used with any of the normal variables (tasmin, tasmax, pr, etc). As such, it's not possible to write a proper long name (and other attributes) on the generic indicator. For example, we can't write "Annual cycle amplitude of tasmax", because we don't know the variable name in advance and the formatter function doesn't look into the inputs' attributes.

I'm not sure how to go forward here.

The easiest idea could be to make the variable attributes accessible to the format string. For example, an indicator declared with long_name="Annual cycle amplitude of {da[name]}'. The Indicator.format function would send the attributes dict for each input variables, using the same names as in the indicator's signature. And it could add the variable's name to the dict, defaulting to the signature's name if the DataArray has no name (da.name or key). This way, we can't ensure the "name" field is always present.

However, this is prone to errors because we can't ensure the presence of any attributes (except "name").

Thoughts?

@aulemahal aulemahal added enhancement New feature or request question labels Jan 11, 2022
@Zeitsperre Zeitsperre added support Questions and help for users/developers and removed question labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request support Questions and help for users/developers
Projects
None yet
Development

No branches or pull requests

2 participants