Skip to content

A very small error #95

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

Closed
aierfulz opened this issue May 8, 2024 · 2 comments
Closed

A very small error #95

aierfulz opened this issue May 8, 2024 · 2 comments
Labels
Bug Something isn't working

Comments

@aierfulz
Copy link

aierfulz commented May 8, 2024

core.py Line 148-149

  if kwargs.get("group", None) is None:
       return apply_ufunc(method, obs, simh, simp, **kwargs).to_dataset()

must be rename a dataarray object befor it be converted to dataset. so the L149 should be pass a name (for example, 'tas') and rewrite as return apply_ufunc(method, obs, simh, simp, **kwargs).rename('tas').to_dataset().

@aierfulz aierfulz added the Bug Something isn't working label May 8, 2024
@btschwertfeger
Copy link
Owner

@aierfulz, thank you for sharing your idea! Indeed I never thought about applying these techniques to xarray.Dataarrays that don't provide a name. For named dataarrays, the name provided by simp is taken - so no need to apply rename.

To make this complete, here is an example of the error using the loaded data sets as shown in https://github.com/btschwertfeger/python-cmethods/blob/v2.2.2/examples/examples.ipynb:

qdm_result = adjust(
    method = "quantile_delta_mapping",
    obs = obsh["tas"].rename(None),
    simh = simh["tas"].rename(None),
    simp = simp["tas"].rename(None),
    n_quantiles = 1000,
    kind = "+", 
)

... which will raise the following error:

ValueError: unable to convert unnamed DataArray to a Dataset without providing an explicit name

IMO the error is very clear and could be avoided by adding a proper name to the input data sets. Extending the implementation as you suggested would add more complexity which is only needed in rare cases - and solved easier by adding a proper name. I don't see any actions to do here.

@aierfulz
Copy link
Author

thank you for your detailed reply!😊

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

No branches or pull requests

2 participants