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

AttributeError: 'Dataset' object has no attribute 'get_axis_num' When use xclim.core.calendar.percentile_doy #1521

Closed
1 task done
CGL5230 opened this issue Nov 11, 2023 · 2 comments

Comments

@CGL5230
Copy link

CGL5230 commented Nov 11, 2023

Generic Issue

Hi,all
I got a error when I try to use the xclim.core.calendar.percentile_doy to calculate the R95P.

Here is the information for the dataset. It's daily precipitation of the CMIP6.
image

I used the following command to calculate the R95P, but the frist line got error as I mentioned.
ssp126_p95 = xclim.core.calendar.percentile_doy(pr_AWI_CM_ssp126,per=95)
AWI_CM_ssp126_R95P = xclim.indicators.icclim.R95p(pr='pr',pr_per=ssp126_p95,freq='YS',ds=pr_AWI_CM_ssp126)
image

Code of Conduct

  • I agree to follow this project's Code of Conduct
@CGL5230
Copy link
Author

CGL5230 commented Nov 12, 2023

I maybe know the issue... THE dataset I used don't choose the variable 'pr'.

But I got other question: I calculate the percentile_doy is very long time cost. Any idea?

@CGL5230 CGL5230 closed this as completed Nov 12, 2023
@aulemahal
Copy link
Collaborator

aulemahal commented Nov 13, 2023

Indeed, the initial issue might simply be that you are passing the dataset instead of the variable directly. Usually in xclim functions, when a variable is expected, the DataArray should be passed. I suggest you do the same for the second line, simply for clarity.

ssp126_p95 = xclim.core.calendar.percentile_doy(pr_AWI_CM_ssp126.pr, per=95)
AWI_CM_ssp126_R95P = xclim.indicators.icclim.R95p(pr=pr_AWI_CM_ssp126.pr, pr_per=ssp126_p95, freq='YS')

As for the performance, the percentile_doy process is indeed a bit heavy and your dataset is large. I see you are not using dask to parallelize the compuation, that's the first step I would recommend to accelerate the process. The data preparation happens at the xarray-level, but xclim is meant to be fully compatible with dask array. Xarray has a page to explain how it works : https://docs.xarray.dev/en/stable/user-guide/dask.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants