Skip to content

Commit

Permalink
Refactor read_timeseries to reuse more code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermorgan committed Mar 19, 2024
1 parent e4f436f commit 626c5ff
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions reView/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,6 @@ def read_timeseries(file, gids=None, nsteps=None):
if "bespoke" not in str(file):
# Break down time entries
time = [t.decode() for t in ds["time_index"][:nsteps]]
dtime = [dt.datetime.strptime(t, TIME_PATTERN) for t in time]
minutes = [t.minute for t in dtime]
hours = [t.hour for t in dtime]
days = [t.timetuple().tm_yday for t in dtime]
weeks = [t.isocalendar().week for t in dtime]
months = [t.month for t in dtime]

# Process generation data
cf = ds["rep_profiles_0"][:nsteps, idx]
Expand Down Expand Up @@ -524,15 +518,16 @@ def read_timeseries(file, gids=None, nsteps=None):

# This will only take the average across the year
time = [t.decode() for t in time]
dtime = [dt.datetime.strptime(t, TIME_PATTERN) for t in time]
days = [t.timetuple().tm_yday for t in dtime]
weeks = [t.isocalendar().week for t in dtime]
months = [t.month for t in dtime]
hours = [t.hour for t in dtime]
minutes = [t.minute for t in dtime]

ds.close()

dtime = [dt.datetime.strptime(t, TIME_PATTERN) for t in time]
minutes = [t.minute for t in dtime]
hours = [t.hour for t in dtime]
days = [t.timetuple().tm_yday for t in dtime]
weeks = [t.isocalendar().week for t in dtime]
months = [t.month for t in dtime]

data = pd.DataFrame({
"time": time,
"minute": minutes,
Expand Down

0 comments on commit 626c5ff

Please sign in to comment.