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

refactor: move code snippets to files #302

Merged
merged 2 commits into from
May 28, 2021
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
12 changes: 12 additions & 0 deletions docs/code/capacity_vs_cf_solar_western_scatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from powersimdata import Scenario
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_scatter_capacity_vs_capacity_factor import (
plot_scatter_capacity_vs_capacity_factor,
)

with PrintManager():
scenario = Scenario(1171)
plot_scatter_capacity_vs_capacity_factor(
scenario, "Western", "solar", percentage=True
)
10 changes: 10 additions & 0 deletions docs/code/capacity_vs_cost_curve_slope_coal_eastern_scatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from powersimdata import Scenario
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_scatter_capacity_vs_cost_curve_slope import (
plot_scatter_capacity_vs_cost_curve_slope,
)

with PrintManager():
scenario = Scenario(3287)
plot_scatter_capacity_vs_cost_curve_slope(scenario, "Eastern", "coal")
10 changes: 10 additions & 0 deletions docs/code/capacity_vs_curtailment_solar_western_scatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from powersimdata import Scenario
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_scatter_capacity_vs_curtailment import (
plot_scatter_capacity_vs_curtailment,
)

with PrintManager():
scenario = Scenario(3287)
plot_scatter_capacity_vs_curtailment(scenario, "Western", "solar", percentage=True)
15 changes: 15 additions & 0 deletions docs/code/capacity_vs_generation_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_bar_generation_vs_capacity import (
plot_bar_generation_vs_capacity,
)

with PrintManager():
plot_bar_generation_vs_capacity(
areas=["CA", "Western"],
scenario_ids=[2497, 3101],
scenario_names=[
"Western 90% clean and 10% nuclear",
"Western 90% clean and 10% nuclear with transmission upgrade",
],
)
15 changes: 15 additions & 0 deletions docs/code/capacity_vs_generation_pie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_pie_generation_vs_capacity import (
plot_pie_generation_vs_capacity,
)

with PrintManager():
plot_pie_generation_vs_capacity(
areas=["WA", "Western"],
scenario_ids=[2497, 3101],
scenario_names=[
"Western 90% clean and 10% nuclear",
"Western 90% clean and 10% nuclear \n with transmission upgrade",
],
)
21 changes: 21 additions & 0 deletions docs/code/curtailment_eastern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import matplotlib.pyplot as plt
from powersimdata import Scenario

from postreise.plot.plot_curtailment_ts import plot_curtailment_time_series

scenario = Scenario(403)

t2c = {"wind_curtailment": "blue", "solar_curtailment": "blue"}

plot_curtailment_time_series(
scenario,
"Eastern",
["wind", "solar"],
time_freq="D",
t2c=t2c,
label_fontsize=30,
title_fontsize=35,
tick_fontsize=25,
legend_fontsize=25,
)
plt.show()
21 changes: 21 additions & 0 deletions docs/code/curtailment_usa_heatmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from powersimdata import Scenario

from postreise.analyze.generation.curtailment import calculate_curtailment_time_series
from postreise.plot.plot_heatmap import plot_heatmap

scenario = Scenario(3287)
curtailment = calculate_curtailment_time_series(scenario).sum(axis=1)

plot_heatmap(
curtailment,
cmap="PiYG_r",
scale=1e-3,
cbar_label="GW",
vmin=0,
vmax=250,
cbar_tick_values=[0, 50, 100, 150, 200, 250],
cbar_tick_labels=["0", "50", "100", "150", "200", "≥250"],
time_zone="ETC/GMT+6",
time_zone_label="(CST)",
contour_levels=[250],
)
24 changes: 24 additions & 0 deletions docs/code/emission_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from powersimdata import Scenario
from powersimdata.utility.helpers import PrintManager

from postreise.plot.plot_carbon_bar import plot_carbon_bar

scenarioA = Scenario(2497)
scenarioB = Scenario(3101)

with PrintManager():
scenarioA = Scenario(2497)
scenarioB = Scenario(3101)

plot_carbon_bar(
scenarioA,
scenarioB,
labels=[
"Western" + "\n" + "90% clean and 10% nuclear",
"Western"
+ "\n"
+ "90% clean and 10% nuclear"
+ "\n"
+ "with transmission upgrade",
],
)
11 changes: 11 additions & 0 deletions docs/code/emission_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from bokeh.io import show
from powersimdata import Scenario

from postreise.plot.plot_carbon_map import map_carbon_emission_generator

scenario = Scenario(3287)

emission_map = map_carbon_emission_generator(
scenario, coordinate_rounding=0, scale_factor=0.75
)
show(emission_map)
12 changes: 12 additions & 0 deletions docs/code/emission_map_carbon_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from bokeh.io import show
from powersimdata import Scenario

from postreise.plot.plot_carbon_map import map_carbon_emission_difference

scenarioA = Scenario(2497)
scenarioB = Scenario(3101)

emission_difference_map = map_carbon_emission_difference(
scenarioA, scenarioB, coordinate_rounding=0
)
show(emission_difference_map)
8 changes: 8 additions & 0 deletions docs/code/energy_emission_stack_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from powersimdata import Scenario

from postreise.plot.plot_energy_carbon_stack import plot_n_scenarios

scenarioA = Scenario(2497)
scenarioB = Scenario(3101)

plot_n_scenarios(scenarioA, scenarioB)
65 changes: 65 additions & 0 deletions docs/code/generation_stack_western_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from powersimdata import Scenario

from postreise.plot.plot_generation_ts_stack import plot_generation_time_series_stack

t2c = {
"nuclear": "#173FA5",
"hydro": "#0090FF",
"geothermal": "#CC67F3",
"other": "#8B36FF",
"dfo": "#31E8CB",
"coal": "#37404C",
"ng": "#72818F",
"solar": "#FFBB45",
"wind": "#78D911",
"solar_curtailment": "#FFBB45",
"wind_curtailment": "#78D911",
}

t2l = {
"nuclear": "Nuclear",
"hydro": "Hydro",
"geothermal": "Geothermal",
"other": "Other",
"dfo": "Distillate Fuel Oil",
"coal": "Coal",
"ng": "Natural Gas",
"solar": "Solar",
"wind": "Wind",
"wind_offshore": "Wind Offshore",
"biomass": "Biomass",
"storage": "Storage",
"solar_curtailment": "Solar Curtailment",
"wind_curtailment": "Wind Curtailment",
"wind_offshore_curtailment": "Offshore Wind Curtailment",
}

t2hc = {"solar_curtailment": "#996100", "wind_curtailment": "#4e8e0b"}

scenario = Scenario(1171)

resources = [
"nuclear",
"coal",
"hydro",
"geothermal",
"other",
"dfo",
"ng",
"solar",
"wind",
"storage",
"solar_curtailment",
"wind_curtailment",
]

plot_generation_time_series_stack(
scenario,
"Western",
resources,
time_freq="D",
normalize=True,
t2c=t2c,
t2l=t2l,
t2hc=t2hc,
)
10 changes: 10 additions & 0 deletions docs/code/interconnection_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from bokeh.io import show
from powersimdata import Scenario

from postreise.plot.plot_interconnection_map import map_interconnections

scenario = Scenario(3287)
grid = scenario.get_grid()

transmission_map = map_interconnections(grid)
show(transmission_map)
9 changes: 9 additions & 0 deletions docs/code/lmp_usa_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from bokeh.io import show
from powersimdata import Scenario

from postreise.plot.plot_lmp_map import map_lmp

scenario = Scenario(3287)

lmp_map = map_lmp(scenario)
show(lmp_map)
13 changes: 13 additions & 0 deletions docs/code/pf_snapshot_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pandas as pd
from bokeh.io import show
from powersimdata import Scenario

from postreise.plot.plot_powerflow_snapshot import plot_powerflow_snapshot

scenario = Scenario(3287)
grid = scenario.get_grid()

pf_map = plot_powerflow_snapshot(
scenario, pd.Timestamp(2016, 11, 2, 22), legend_font_size=20
)
show(pf_map)
25 changes: 25 additions & 0 deletions docs/code/shortfall_nv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import inspect
import os

from powersimdata.design.generation.clean_capacity_scaling import load_targets_from_csv
from powersimdata.utility.helpers import PrintManager

import postreise
from postreise.plot.plot_bar_shortfall import plot_bar_shortfall

data = os.path.join(os.path.dirname(inspect.getfile(postreise)), "data")
target = load_targets_from_csv(
os.path.join(data, "2030_USA_Clean_Energy_Regular_Targets.csv")
)
with PrintManager():
plot_bar_shortfall(
"Nevada",
[2497, 3101],
target,
scenario_names=[
"Western 90% clean and 10% nuclear",
"Western 90% clean and 10% nuclear" + "\n" + "with transmission upgrade",
],
baseline_scenario=2497,
baseline_scenario_name="Western 90% clean and 10% nuclear",
)
8 changes: 8 additions & 0 deletions docs/code/utilization_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from bokeh.io import show
from powersimdata import Scenario

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems I forgot to declare scenario. Can you add scenario = Scenario("3287"). Sorry

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No problem - done

from postreise.plot.plot_utilization_map import map_utilization

scenario = Scenario("3287")
util_map = map_utilization(scenario, plot_states_kwargs={"background_map": False})
show(util_map)
Loading