Replies: 1 comment
-
I'm not sure I fully understand your issue here, but I see two answers that might solve it. Floats instead of integersAre you surprised that This is because xarray and xclim have special checks for missing values. If your data had missing values (for example if it stopped in november instead of december) then the incomplete periods would be flagged as invalid. Xclim would put a NaN in the output to indicate that. But NaNs are only available when your data has a float dtype. Thus, xclim (and xarray underneath) always return floats in any case where missing data is a possibility. Timedelta instead of numbersIf instead you meant that when you open the netcdf again, you see "timedelta64[ns]" as the dtype instead of a normal number dtype (float, int), this is because xarray thinks it is smart. To avoid that open the netCDF with |
Beta Was this translation helpful? Give feedback.
-
Setup Information
Context
I'm trying to calculate the number of dry days using xclim.indicators.atmos.dry_days but I get the results as float64 (e.g., 15 days, 193 days, etc.). Is that how it supposed to be?
Steps To Reproduce
models = ['ACCESS-CM2','BCC-CSM2-MR', 'CMCC-CM2-SR5', 'CMCC-ESM2', 'CNRM-ESM2-1', 'FGOALS-g3', 'GFDL-ESM4', 'INM-CM5-0', 'KACE-1-0-G', 'MIROC6', 'MIROC-ES2L','MPI-ESM1-2-LR', 'MRI-ESM2-0']
ssps = ['historical','ssp245','ssp370','ssp585']
for model in models:
for ssp in ssps:
print(model, ssp)
#ds=xr.open_dataset('pr/daily/pr_day_'+model+''+ssp+'.nc')
ds=xr.open_dataset('pr/daily/pr_day'+model+''+ssp+'.nc')
#ds1 = units.convert_units_to(ds.pr, "mm")
ndd = xclim.indicators.atmos.dry_days(ds.pr, thresh = '0.1 mm/d', freq = 'YS')
ndd.to_netcdf('pr/daily/ndd/ndd_annual'+model+'_'+ssp+'.nc')
Beta Was this translation helpful? Give feedback.
All reactions