Skip to content

Commit

Permalink
convert: Fix heat demand hourshift for xarray 0.15.1 (#63)
Browse files Browse the repository at this point in the history
From xarray version 0.15.1, .values cannot be assigned. You should
use the .assign_coords() method instead.

See release notes for xarray 0.15.1 "breaking changes":

http://xarray.pydata.org/en/stable/whats-new.html#v0-15-1-23-mar-2020
  • Loading branch information
nworbmot authored and FabianHofmann committed Jun 3, 2020
1 parent 5eb54b4 commit a7537f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions atlite/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def soil_temperature(cutout, **params):
def convert_heat_demand(ds, threshold, a, constant, hour_shift):
# Temperature is in Kelvin; take daily average
T = ds['temperature']
T.coords['time'].values += np.timedelta64(dt.timedelta(hours=hour_shift))
T = T.assign_coords(time=(T.coords['time'] + np.timedelta64(dt.timedelta(hours=hour_shift))))

T = ds['temperature'].resample(time="1D").mean(dim='time')
T = T.resample(time="1D").mean(dim='time')
threshold += 273.15
heat_demand = a * (threshold - T)

Expand Down

0 comments on commit a7537f1

Please sign in to comment.