Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for 'biomass' and 'other' generators, slight refactor #55

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
Copy link
Collaborator

@merrielle merrielle Dec 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding me onto the review. Since you're adding dfo and biomass to analyze_pg then you should put them in SCENARIO_RESOURCE_TYPES.

Now that I think about it, ADDITIONAL_RESOURCE_TYPES is a relic from my original spot check code and I need to remove it.

Also we should eventually take type2label and type2color out of analyze_pg so we don't have to have duplicates like this.

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