-
Setup Information
ContextHello 👋 What I would like:
This throws an error because it wants to calculate the percentiles itself. However, even if the full data is provided, the following issues arose for me:
Does anyone have any pointer as to what could be the issue, or what I am misunderstanding here? Cheers Steps To ReproduceNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! I'm afraid I can't reproduce your errors. However, one potential issue I see is that Anyway, so you can test on your end, this code for the import xarray as xr
import xclim as xc
# Get test data, 6-hourly air temp on North America
ds = xr.tutorial.open_dataset("air_temperature")
# Get a daily array with proper units
tasmin = ds.air.rename('tasmin').resample(time='D').mean().assign_attrs(units='K')
# The 10th percentile taken for each day of year, using a rolling 15-day window
tasmin_per = xc.core.calendar.percentile_doy(tasmin, window=15, per=10)
# The number of days in a year that are colder than the 10th percentile for that particular day of year
out = xc.atmos.tn10p(tasmin, tasmin_per) There is another way to compute what you want. In most indicators, if you see an input annotated as "Quantified" in the docstring and signature, this means it will accept any of the following : a string representing a quantity with units (the most common case), a # A much simpler 10th percentile over all days
tasmin_per = tasmin.quantile(0.1, 'time').assign_attrs(units='K')
# The number of days in a year that are colder than the thresh, i.e. then the all-time 10th percentile
xc.atmos.tn_days_below(tasmin=tasmin, thresh=tasmin_per) Of course, the attributes here will be a bit more vague as the "10th percentile" information won't be noted anywhere, maybe you'll want to edit them after. But this looks like the computation you want ? |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick answer! With the limitation/intended use of only allowing it on a Using |
Beta Was this translation helpful? Give feedback.
Hi! I'm afraid I can't reproduce your errors. However, one potential issue I see is that
tn10p
expects to get atasmin_per
for each day of the year. Thus,tasmin_per
should have adayofyear
dimension (instead oftime
). I am surprised how unclear this is in the docstring, I think there was a time when we wanted the "percentile" indicator to accept both the "dayofyear" version and the "flat" one (the one you want), but I guess the changes were not completed correctly ?Anyway, so you can test on your end, this code for the
tn10p
computed over eachdayofyear
works for me: