Skip to content

Commit

Permalink
rebase master, shortened code
Browse files Browse the repository at this point in the history
  • Loading branch information
smuellr committed Nov 14, 2015
1 parent 080777a commit f4079b3
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions urbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,28 +1640,19 @@ def plot(prob, com, sit, timesteps=None, power_unit='MW', energy_unit='MWh'):
if not created[col].any() and len(created.columns) > 1:
if col not in consumed.columns or not consumed[col].any():
created.pop(col)

# sorting plot elements
# calculate standard deviation possibly normed by mean value, takes ~10-100ms
if len(created.columns) > 1:
std = pd.DataFrame(np.zeros_like(created.tail(1)),
index=created.index[-1:]+1, columns=created.columns)
for col in std.columns:
std[col] = np.std(created[col])
# sort created ascencing with std i.e. base load first
created = created.append(std)
new_columns = created.columns[created.ix[created.last_valid_index()].argsort()]
created = created[new_columns][:-1]

if len(consumed.columns) > 1:
std = pd.DataFrame(np.zeros_like(consumed.tail(1)),
index=consumed.index[-1:]+1, columns=consumed.columns)
for col in std.columns:
std[col] = np.std(consumed[col])
# sort consumed ascencing with std i.e. base load first
consumed = consumed.append(std)
new_columns = consumed.columns[consumed.ix[consumed.last_valid_index()].argsort()]
consumed = consumed[new_columns][:-1]
for elements in [created,consumed]:
if len(elements.columns) > 1:
# calculate standard deviation
std = pd.DataFrame(np.zeros_like(elements.tail(1)),
index=elements.index[-1:]+1, columns=elements.columns)
for col in std.columns:
std[col] = np.std(elements[col])
# sort created/consumed ascencing with std i.e. base load first
elements = elements.append(std)
new_columns = elements.columns[elements.ix[elements.last_valid_index()].argsort()]
elements = elements[new_columns][:-1]

# PLOT CREATED
ax0 = plt.subplot(gs[0])
Expand Down

0 comments on commit f4079b3

Please sign in to comment.