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

Losing attributes of coords when using weights in ensemble stats #1232

Closed
2 tasks done
juliettelavoie opened this issue Nov 10, 2022 · 0 comments · Fixed by #1234
Closed
2 tasks done

Losing attributes of coords when using weights in ensemble stats #1232

juliettelavoie opened this issue Nov 10, 2022 · 0 comments · Fixed by #1234
Labels
bug Something isn't working

Comments

@juliettelavoie
Copy link
Contributor

juliettelavoie commented Nov 10, 2022

Setup Information

  • Xclim version: '0.38.1-beta'
  • Python version: 3.9
  • Operating System: mac

Description

When I add the weights argument to ensemble statistics, I lose the attributes of my coordinates.

I think this is related to the fact that the weights dataset only has a realization coord.

Steps To Reproduce

with weights:

datasets = pcat.search(processing_level= 'delta-+1.5C').to_dataset_dict(
                        xarray_open_kwargs={'decode_timedelta':False})

weights = xs.ensembles.generate_weights(datasets=datasets)
ens = xc.ensembles.create_ensemble(datasets)
stats= xc.ensembles.ensemble_mean_std_max_min(ens, weights=weights)
print(stats.horizon.attrs)
>>> {}

without weights:

datasets = pcat.search(processing_level= 'delta-+1.5C').to_dataset_dict(
                        xarray_open_kwargs={'decode_timedelta':False})
ens = xc.ensembles.create_ensemble(datasets)
stats= xc.ensembles.ensemble_mean_std_max_min(ens)
print(stats.horizon.attrs)
>>> {'baseline': '1850-1900'}

Additional context

This is also an issue for ensemble_percentiles.

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
@juliettelavoie juliettelavoie added the bug Something isn't working label Nov 10, 2022
@Zeitsperre Zeitsperre changed the title loosing attributes of coords when using weights in ensemble stats Losing attributes of coords when using weights in ensemble stats Nov 10, 2022
@juliettelavoie juliettelavoie mentioned this issue Nov 10, 2022
5 tasks
juliettelavoie added a commit that referenced this issue Nov 14, 2022
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #1232 
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] HISTORY.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

### What kind of change does this PR introduce?

* fixes 1232. Keeps coordinates attributes when using `weights` in `
ensemble_mean_std_max_min` and ` ensemble_percentiles`.

### Does this PR introduce a breaking change?
no

### Other information:
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.

1 participant