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

Update PowerSimData version #346

Merged
merged 5 commits into from
Aug 17, 2022
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: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bokeh = "~=2.0"
matplotlib = "~=3.3"
numpy = "~=1.20"
pandas = "~=1.4.0"
powersimdata = "~=0.5.0"
powersimdata = "~=0.5.4"
pyproj = "~=3.0"

[dev-packages]
Expand Down
973 changes: 517 additions & 456 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions postreise/analyze/generation/curtailment.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def calculate_curtailment_time_series_by_resources(scenario, resources=None):
)
else:
resources = _check_resources_are_renewable_and_format(
resources, grid_model=scenario.info["grid_model"]
resources, mi=grid.model_immutables
)

curtailment_by_resources = decompose_plant_data_frame_into_resources(
Expand Down Expand Up @@ -154,7 +154,7 @@ def calculate_curtailment_time_series_by_areas_and_resources(
)
else:
resources = _check_resources_are_renewable_and_format(
resources, grid_model=scenario.info["grid_model"]
resources, mi=grid.model_immutables
)

curtailment_by_areas_and_resources = (
Expand Down Expand Up @@ -195,7 +195,7 @@ def calculate_curtailment_time_series_by_resources_and_areas(
)
else:
resources = _check_resources_are_renewable_and_format(
resources, grid_model=scenario.info["grid_model"]
resources, mi=grid.model_immutables
)

curtailment_by_resources_and_areas = (
Expand Down
5 changes: 2 additions & 3 deletions postreise/analyze/generation/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ def summarize_hist_gen(
:return: (*pandas.DataFrame*) -- historical generation per resource.
"""
_check_data_frame(hist_gen_raw, "PG")
filtered_colnames = _check_resources_and_format(
all_resources, grid_model=grid_model
)

mi = ModelImmutables(grid_model)

filtered_colnames = _check_resources_and_format(all_resources, mi=mi)
result = hist_gen_raw.copy()

# Interconnection
Expand Down
2 changes: 1 addition & 1 deletion postreise/plot/plot_bar_generation_max_min_actual.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def plot_bar_generation_max_min_actual(
)
all_actual_gen = sum_generation_by_state(scenario)[gen_type] * 1000
else:
zone_list = mi.zones["interconnect2loadzone"][interconnect]
zone_list = list(mi.zones["interconnect2loadzone"][interconnect])
all_max_min = plant.groupby("zone_name")[["Pmax", "Pmin"]].sum() * hour_num
all_actual_gen = (
sum_generation_by_type_zone(scenario)
Expand Down
4 changes: 2 additions & 2 deletions postreise/plot/plot_bar_generation_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def plot_bar_generation_stack(
patches = []
fuels = []
bottom = 0
loadzone_set = area_to_loadzone(s.info["grid_model"], area, area_type)
zone_list = list(area_to_loadzone(s.info["grid_model"], area, area_type))
data = (
all_loadzone_data[scenario_ids[ind]]
.loc[loadzone_set]
.loc[zone_list]
.sum()
.divide(1e6)
.astype("float")
Expand Down
8 changes: 4 additions & 4 deletions postreise/plot/plot_bar_generation_vs_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ def plot_bar_generation_vs_capacity(
}
for area, area_type in zip(areas, area_types):
for sid in scenario_ids:
loadzone_set = area_to_loadzone(
scenario_data[sid]["grid_model"], area, area_type
zone_list = list(
area_to_loadzone(scenario_data[sid]["grid_model"], area, area_type)
)
scenario_data[sid]["gen"]["data"][area] = (
all_loadzone_data[sid]["gen"][loadzone_set]
all_loadzone_data[sid]["gen"][zone_list]
.sum(axis=1)
.divide(1e6)
.astype("float")
.round(2)
.to_dict()
)
scenario_data[sid]["cap"]["data"][area] = (
all_loadzone_data[sid]["cap"][loadzone_set]
all_loadzone_data[sid]["cap"][zone_list]
.sum(axis=1)
.divide(1e3)
.astype("float")
Expand Down
9 changes: 3 additions & 6 deletions postreise/plot/plot_bar_renewable_max_profile_actual.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
_check_resources_are_in_grid_and_format,
_check_resources_are_renewable_and_format,
)
from powersimdata.network.model import ModelImmutables
from powersimdata.scenario.check import _check_scenario_is_in_analyze_state

from postreise.analyze.generation.summarize import (
Expand Down Expand Up @@ -50,13 +49,11 @@ def plot_bar_renewable_max_profile_actual(
raise TypeError("fontsize must be either a int or a float")

grid = scenario.get_grid()
mi = grid.model_immutables
_check_resources_are_in_grid_and_format(gen_type, grid)
_check_resources_are_renewable_and_format(
gen_type, grid_model=scenario.info["grid_model"]
)
_check_resources_are_renewable_and_format(gen_type, mi=mi)

plant = grid.plant[grid.plant.type == gen_type]
mi = ModelImmutables(scenario.info["grid_model"])
if interconnect not in mi.zones["interconnect"]:
raise ValueError(
f"interconnect must be one of {sorted(mi.zones['interconnect'])}"
Expand Down Expand Up @@ -88,7 +85,7 @@ def plot_bar_renewable_max_profile_actual(
total_capacity = plant.groupby(group_criteria)["Pmax"].sum() * hour_num
actual_gen = sum_generation_by_state(scenario)[gen_type] * 1000
else:
zone_list = mi.zones["interconnect2loadzone"][interconnect]
zone_list = list(mi.zones["interconnect2loadzone"][interconnect])
profile_gen = profile.groupby(plant.zone_name).sum().rename("profile")
total_capacity = plant.groupby("zone_name")["Pmax"].sum() * hour_num
actual_gen = (
Expand Down
2 changes: 1 addition & 1 deletion postreise/plot/plot_curtailment_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def plot_curtailment_time_series(
"""
_check_scenario_is_in_analyze_state(scenario)
resources = _check_resources_and_format(
resources, grid_model=scenario.info["grid_model"]
resources, mi=ModelImmutables(scenario.info["grid_model"])
)

mi = ModelImmutables(scenario.info["grid_model"])
Expand Down
3 changes: 2 additions & 1 deletion postreise/plot/plot_scatter_capacity_vs_curtailment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
from powersimdata.input.check import _check_resources_are_renewable_and_format
from powersimdata.input.helpers import get_plant_id_for_resources_in_area
from powersimdata.network.model import ModelImmutables

from postreise.analyze.generation.capacity import get_capacity_by_resources
from postreise.analyze.generation.curtailment import calculate_curtailment_time_series
Expand Down Expand Up @@ -64,7 +65,7 @@ def plot_scatter_capacity_vs_curtailment(
if title is not None and not isinstance(title, str):
raise TypeError("title should be a string")
resources = _check_resources_are_renewable_and_format(
resources, grid_model=scenario.info["grid_model"]
resources, mi=ModelImmutables(scenario.info["grid_model"])
)
curtailment = calculate_curtailment_time_series(scenario)
plant_list = get_plant_id_for_resources_in_area(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_plot_bar_generation_max_min_actual_argument_value():
with pytest.raises(ValueError) as excinfo:
plot_bar_generation_max_min_actual(scenario, "Europe", "wind", plot_show=False)
assert (
"interconnect must be one of ['Eastern', 'Texas', 'Texas_Western', 'USA', 'Western']"
"interconnect must be one of ['Eastern', 'Eastern_Western', 'Texas', 'Texas_Eastern', 'Texas_Western', 'USA', 'Western']"
in str(excinfo.value)
)
with pytest.raises(ValueError) as excinfo:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_plot_bar_renewable_max_profile_actual_argument_value():
scenario, "Europe", "wind", plot_show=False
)
assert (
"interconnect must be one of ['Eastern', 'Texas', 'Texas_Western', 'USA', 'Western']"
"interconnect must be one of ['Eastern', 'Eastern_Western', 'Texas', 'Texas_Eastern', 'Texas_Western', 'USA', 'Western']"
in str(excinfo.value)
)
with pytest.raises(ValueError) as excinfo:
Expand Down