Skip to content

Commit 11bedbf

Browse files
authored
Merge pull request #713 from Breakthrough-Energy/develop
develop - > master
2 parents bda9849 + 080e0e0 commit 11bedbf

80 files changed

Lines changed: 4342 additions & 2980 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ build
1111
.venv
1212
.dockerignore
1313
config.ini
14+
powersimdata/network/europe_tub/data*

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111

1212
name: Generate coverage report
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

1616
- name: Set up Python
17-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v4
1818
with:
1919
python-version: 3.9
2020

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
if: "!contains(github.event.head_commit.message, 'skip_ci')"
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-python@v2
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v4
1616
- run: python -m pip install --upgrade tox
1717
- run: tox -e checkformatting
1818
flake8:
1919
if: "!contains(github.event.head_commit.message, 'skip_ci')"
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions/setup-python@v2
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-python@v4
2424
- run: python -m pip install --upgrade tox
2525
- run: tox -e flake8

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
name: Publish python package
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-python@v4
1515
- run: python -m pip install --upgrade build
1616
- run: python -m build
1717

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717

1818
name: Python ${{ matrix.python-version }}
1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121

2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is specific to this package
22
powersimdata/utility/.server_user
33
config.ini
4-
powersimdata/network/europe_tub/data/*
4+
powersimdata/network/europe_tub/data*
55

66
# The remainder of this file taken from github/gitignore
77
# https://github.com/github/gitignore/blob/master/Python.gitignore
@@ -142,3 +142,8 @@ dmypy.json
142142

143143
# Windows
144144
Thumbs.db
145+
146+
# Misc
147+
environment.yaml
148+
.syncignore-receive*
149+
.syncignore-send*

Pipfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ black = "*"
88
pytest = "*"
99
coverage = "*"
1010
pytest-cov = "*"
11-
pypsa = "*"
12-
zenodo_get = "*"
1311

1412
[packages]
1513
networkx = "~=2.5"
@@ -22,3 +20,4 @@ requests = "~=2.25"
2220
fs = "==2.4.14"
2321
"fs.sshfs" = "*"
2422
fs-azureblob = ">=0.2.1"
23+
pypsa = "*"

Pipfile.lock

Lines changed: 901 additions & 761 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Breakthrough-Energy/PowerSimData/develop?logo=GitHub)
1212
![GitHub pull requests](https://img.shields.io/github/issues-pr/Breakthrough-Energy/PowerSimData?logo=GitHub)
1313
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
14-
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat)](https://breakthrough-energy.github.io/docs/communication/code_of_conduct.html)
14+
[![Code of Conduct](https://img.shields.io/badge/Code_of_conduct-ff69b4.svg)](https://breakthrough-energy.github.io/docs/communication/code_of_conduct.html)
1515
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4538590.svg)](https://doi.org/10.5281/zenodo.4538590)
16-
16+
[![Slack](https://img.shields.io/badge/Community_Slack-sign_up-1f425f.svg?logo=slack)](https://science.breakthroughenergy.org/#get-updates)
1717

1818
# PowerSimData
1919
**PowerSimData** is part of a Python software ecosystem developed by [Breakthrough

powersimdata/design/generation/clean_capacity_scaling.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def add_resource_data_to_targets(input_targets, scenario, calculate_curtailment=
156156
:param pandas.DataFrame input_targets: table includeing target names, used to
157157
summarize resource data.
158158
:param powersimdata.scenario.scenario.Scenario scenario: A Scenario instance.
159-
:return: (*pandas.DataFrame*) -- DataFrame of targets including resource data.
159+
:return: (*pandas.DataFrame*) -- data frame of targets including resource data.
160160
"""
161161
targets = input_targets.copy()
162-
grid = scenario.state.get_grid()
162+
grid = scenario.get_grid()
163163
plant = grid.plant
164164
curtailment_types = ["hydro", "solar", "wind"]
165165
scenario_length = _get_scenario_length(scenario)
@@ -174,24 +174,33 @@ def add_resource_data_to_targets(input_targets, scenario, calculate_curtailment=
174174
capacity_groupby = plant.Pmax.groupby(groupby_cols)
175175
capacity_by_target_type = capacity_groupby.sum().unstack(fill_value=0)
176176
# Generated energy
177-
pg_groupby = scenario.state.get_pg().sum().groupby(groupby_cols)
177+
pg_groupby = scenario.get_pg().sum().groupby(groupby_cols)
178178
summed_generation = pg_groupby.sum().unstack(fill_value=0)
179179
# Calculate capacity factors
180180
possible_energy = scenario_length * capacity_by_target_type[curtailment_types]
181181
capacity_factor = summed_generation[curtailment_types] / possible_energy
182+
182183
if calculate_curtailment:
183184
# Calculate: curtailment, no_curtailment_cap_factor
184185
# Hydro and solar are straightforward
185-
hydro_plant_sum = scenario.state.get_hydro().sum()
186-
hydro_plant_targets = plant[plant.type == "hydro"].target_area
186+
hydro_plant_sum = scenario.get_profile("hydro").sum()
187+
hydro_plant_targets = plant[
188+
plant["type"].isin(
189+
grid.model_immutables.plants["group_profile_resources"]["hydro"]
190+
)
191+
]["target_area"]
187192
hydro_potential_by_target = hydro_plant_sum.groupby(hydro_plant_targets).sum()
188-
solar_plant_sum = scenario.state.get_solar().sum()
189-
solar_plant_targets = plant[plant.type == "solar"].target_area
193+
solar_plant_sum = scenario.get_profile("solar").sum()
194+
solar_plant_targets = plant[
195+
plant["type"].isin(
196+
grid.model_immutables.plants["group_profile_resources"]["solar"]
197+
)
198+
]["target_area"]
190199
solar_potential_by_target = solar_plant_sum.groupby(solar_plant_targets).sum()
191-
# Wind is a little tricker because get_wind() returns 'wind' and 'wind_offshore'
192-
onshore_wind_plants = plant[plant.type == "wind"].index
193-
onshore_wind_plant_sum = scenario.state.get_wind().sum()[onshore_wind_plants]
194-
wind_plant_targets = plant[plant.type == "wind"].target_area
200+
onshore_wind_type = grid.model_immutables.plants["label2type"]["Onshore Wind"]
201+
onshore_wind_plants = plant[plant["type"] == onshore_wind_type].index
202+
onshore_wind_plant_sum = scenario.get_profile("wind").sum()[onshore_wind_plants]
203+
wind_plant_targets = plant[plant["type"] == onshore_wind_type].target_area
195204
wind_potential_by_target = onshore_wind_plant_sum.groupby(
196205
wind_plant_targets
197206
).sum()
@@ -234,7 +243,7 @@ def add_demand_to_targets(input_targets, scenario):
234243

235244
zonename2target = _make_zonename2target(grid, targets)
236245
zoneid2target = {grid.zone2id[z]: target for z, target in zonename2target.items()}
237-
summed_demand = scenario.state.get_demand().sum().to_frame()
246+
summed_demand = scenario.get_demand().sum().to_frame()
238247
summed_demand["target"] = [zoneid2target[id] for id in summed_demand.index]
239248
targets["demand"] = summed_demand.groupby("target").sum()
240249
return targets
@@ -507,12 +516,19 @@ def calculate_clean_capacity_scaling(
507516
For method == 'independent', these values are specified in the targets table.
508517
:return: (*pandas.DataFrame*) -- dataframe of targets including new capacities,
509518
plus intermediate values used in calculation.
519+
:raises TypeError:
520+
if ``ref_scenario`` is not a Scenario object.
521+
if both ``targets`` and ``targets_filename`` are None or set.
522+
if ``targets`` is not a pandas.DataFrame
523+
:raises ValueError:
524+
if ``ref_scenario`` is not in the analyze state.
525+
if ``method`` is incorrectly set.
510526
"""
511527
allowed_methods = {"independent", "collaborative"}
512528
# Input validation
513529
if not isinstance(ref_scenario, Scenario):
514530
raise TypeError("ref_scenario must be a Scenario object")
515-
if ref_scenario.state.name != "analyze":
531+
if ref_scenario.name != "analyze":
516532
raise ValueError("ref_scenario must be in Analyze state")
517533
if method not in allowed_methods:
518534
raise ValueError(f"method must be one of: {allowed_methods}")
@@ -521,7 +537,7 @@ def calculate_clean_capacity_scaling(
521537
if targets is not None and targets_filename is not None:
522538
raise TypeError("targets and targets_filename cannot both be given")
523539
if targets is not None and not isinstance(targets, pd.DataFrame):
524-
raise TypeError("targets must be passed as a pandas.DataFrame")
540+
raise TypeError("targets must be a pandas.DataFrame")
525541
if targets_filename is not None:
526542
targets = load_targets_from_csv(targets_filename)
527543

0 commit comments

Comments
 (0)