Skip to content

Commit

Permalink
feat: support for 'biomass' and 'other' generators, slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Jan 9, 2020
1 parent 0e73ac4 commit 3311cc6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
2 changes: 2 additions & 0 deletions postreise/plot/analyze_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def __init__(self, scenario, time, zones, resources, kind,
'ng': 'Natural Gas',
'solar': 'Solar',
'wind': 'Wind',
'biomass': 'Biomass',
'other': 'Other',
'storage': 'Storage Discharging'}

# Check parameters
Expand Down
38 changes: 14 additions & 24 deletions postreise/plot/analyze_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from powersimdata.scenario.scenario import Scenario
from postreise.plot.multi import constants

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -97,14 +98,9 @@ def fraction(scenarios, zone):
type as columns.
"""

r2l = {'nuclear': 'Nuclear',
'hydro': 'Hydro',
'coal': 'Coal',
'ng': 'Natural Gas',
'solar': 'Solar',
'wind': 'Wind',
'dfo': 'Fuel Oil',
'geothermal': 'Geothermal'}
plotted_resources = ('nuclear', 'hydro', 'coal', 'ng', 'solar', 'wind',
'dfo', 'geothermal', 'biomass', 'other')
r2l = {r: constants.RESOURCE_LABELS[r] for r in plotted_resources}

thermal_gen_types = ['dfo', 'geothermal', 'nuclear', 'hydro', 'coal', 'ng']

Expand Down Expand Up @@ -195,22 +191,18 @@ def generation(scenarios, zone, grid_type=0):
allotment = []
title = []

analyzed_types = ['nuclear', 'hydro', 'coal', 'ng', 'solar', 'wind']

for key, files in scenarios.items():
f = files[grid_type]
if f:
scenario = Scenario(f)
grid = scenario.state.get_grid()
pg = scenario.state.get_pg()
allotment_scenario = pd.DataFrame(columns=['nuclear', 'hydro',
'coal', 'ng', 'solar',
'wind'], index=zone)
allotment_scenario = pd.DataFrame(
columns=analyzed_types, index=zone)
for z in zone:
r2l = {'nuclear': 'Nuclear',
'hydro': 'Hydro',
'coal': 'Coal',
'ng': 'Natural Gas',
'solar': 'Solar',
'wind': 'Wind'}
r2l = {r: constants.RESOURCE_LABELS[r] for r in analyzed_types}
plant_id = get_plant_id(grid, z)
pg_tmp = pg[plant_id]

Expand All @@ -234,14 +226,12 @@ def generation(scenarios, zone, grid_type=0):
ax.tick_params(labelsize=20)
ax.set_ylabel('Generation [GWh]', fontsize=22)

colors = [grid.type2color[r]
for r in ['nuclear', 'hydro', 'coal', 'ng', 'solar', 'wind']]
colors = [grid.type2color[r] for r in analyzed_types]
for df in allotment:
ax = df.rename(columns={'nuclear': 'Nuclear', 'hydro': 'Hydro',
'coal': 'Coal', 'ng': 'Natural Gas',
'solar': 'Solar', 'wind': 'Wind'}).plot(
kind="bar", linewidth=0, stacked=True,
ax=ax, color=colors, label=True, alpha=0.7)
rename_dict = {r: constants.RESOURCE_LABELS[r] for r in analyzed_types}
ax = df.rename(columns=rename_dict).plot(
kind="bar", linewidth=0, stacked=True, ax=ax, color=colors,
label=True, alpha=0.7)
ax.set_ylim(0, ax.get_ylim()[1])
ax.ticklabel_format(axis='y', useOffset=False, style='plain')

Expand Down
11 changes: 7 additions & 4 deletions postreise/plot/multi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
}
SCENARIO_RESOURCE_TYPES = ['wind', 'solar', 'ng',
'coal', 'nuclear', 'geothermal', 'hydro']
ALL_RESOURCE_TYPES = SCENARIO_RESOURCE_TYPES + ['other inc. biomass']
ADDITIONAL_RESOURCE_TYPES = ['dfo', 'other inc. biomass', 'other', 'biomass']
ALL_RESOURCE_TYPES = SCENARIO_RESOURCE_TYPES + ADDITIONAL_RESOURCE_TYPES
RESOURCE_LABELS = {'wind': 'Wind', 'solar': 'Solar', 'ng': 'Natural Gas', \
'coal': 'Coal', 'nuclear': 'Nuclear',
'coal': 'Coal', 'dfo': 'Fuel Oil', 'nuclear': 'Nuclear',
'geothermal': 'Geothermal', 'hydro': 'Hydro', \
'other inc. biomass': 'Other inc. Biomass'}
'other inc. biomass': 'Other inc. Biomass',
'other': 'Other', 'biomass': 'Biomass'}
RESOURCE_COLORS = {
'wind': sns.xkcd_rgb["green"],
'solar': sns.xkcd_rgb["amber"],
Expand All @@ -25,7 +27,8 @@
'dfo': sns.xkcd_rgb["royal blue"],
'storage': sns.xkcd_rgb["orange"],
'other inc. biomass': 'rebeccapurple',
'other': 'royalblue'
'other': sns.xkcd_rgb["melon"],
'biomass': sns.xkcd_rgb["dark green"],
}
SHADOW_PRICE_COLORS = ['darkmagenta' ,'blue', '#66bd63', '#d9ef8b', 'gold', '#fdae61', '#f46d43', '#d73027', 'darkred']
BASELINES = {
Expand Down

0 comments on commit 3311cc6

Please sign in to comment.