issues: 375627070
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
375627070 | MDU6SXNzdWUzNzU2MjcwNzA= | 2527 | Undesired automatic conversion of 'dtype' based on variable units 'days'? | 22454970 | closed | 0 | 2 | 2018-10-30T18:14:38Z | 2018-10-31T16:04:08Z | 2018-10-31T16:04:08Z | NONE | ```python import xarray as xr from glob import os import numpy as np import urllib.request xr.set_options(enable_cftimeindex=True) url = 'https://github.com/Ouranosinc/xclim/raw/master/tests/testdata/NRCANdaily/nrcan_canada_daily_tasmax_1990.nc' infile = r'~/nrcan_canada_daily_tasmax_1990.nc' urllib.request.urlretrieve(url,infile) freqs = ['MS'] # , 'QS-DEC', 'YS'] ds = xr.open_dataset(infile) su = (ds.tasmax > 25.0+273.15) * 1.0 for f in freqs:
``` Problem descriptionI am calculating a climate index 'summer days' ('su') from daily maximum temperatures. Everything goes fine but when I reread a newly created output .nc file my 'su' dtype has changed from float to timedelta64. This seems to be due to the units ('days') that I assign to my newly created variable which when read by xarray must trigger an automatic conversion? If I alter the units to 'days>25C' everything is ok. Is there a way to avoid this behavior and still keep my units as 'days' which is the CF_standard for this climate index calculation? (note there a large number of cases such as this - wet days, dry-days etc etc all of which have 'days' as the expected unit |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2527/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |