-
Notifications
You must be signed in to change notification settings - Fork 13
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
docs/code/capacity_vs_cost_curve_slope_coal_eastern_scatter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
docs/code/capacity_vs_curtailment_solar_western_scatter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from bokeh.io import show | ||
from powersimdata import Scenario | ||
|
||
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 addscenario = Scenario("3287"). Sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem - done