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

Possibility of a meta context=="hydro" #44

Open
1 task
coxipi opened this issue Dec 9, 2024 · 0 comments · May be fixed by #57
Open
1 task

Possibility of a meta context=="hydro" #44

coxipi opened this issue Dec 9, 2024 · 0 comments · May be fixed by #57
Labels
enhancement New feature or request

Comments

@coxipi
Copy link
Contributor

coxipi commented Dec 9, 2024

Addressing a Problem?

In xclim, we explicit define the "hydro" context.

hydro = pint.Context("hydro")
hydro.add_transformation(
    "[mass] / [length]**2",
    "[length]",
    lambda ureg, x: x / (1000 * ureg.kg / ureg.m**3),
)
...
units.add_context(hydro)

and then in lower levels, we have code snippets like:

    with units.context("hydro"):
       # perform operation

in various contexts.

I think we could support contexts explictly, maybe also define them in units, and then if users want a specific context, then can globally set:

with xsdba.units.units.context("hydro"): 
    xsdba.DetrendedQuantileMapping(...)

For xclim/xsdba users that are used to have context="hydro" activated presently, that would be useful.

Potential Solution

No response

Additional context

No response

Contribution

  • I would be willing/able to open a Pull Request to contribute this feature.
@coxipi coxipi added the enhancement New feature or request label Dec 9, 2024
@aulemahal aulemahal linked a pull request Jan 10, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant