-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from REAM-lab/feature/post_process
Refactoring and simplification of postprocess
- Loading branch information
Showing
10 changed files
with
181 additions
and
78 deletions.
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
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
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
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
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
55 changes: 55 additions & 0 deletions
55
switch_model/wecc/get_inputs/post_process_steps/energy_cost.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,55 @@ | ||
# Standard packages | ||
import os | ||
import shutil | ||
|
||
# Third-party packages | ||
import pandas as pd | ||
|
||
from switch_model.wecc.get_inputs.register_post_process import register_post_process | ||
|
||
|
||
@register_post_process( | ||
msg="Change energy cost for storage candidate", | ||
) | ||
def post_process(config, func_config): | ||
|
||
percentage = int(func_config["percentage"]) / 100 | ||
dtype = {"GENERATION_PROJECT": str} | ||
df = pd.read_csv("generation_projects_info.csv", dtype=dtype) | ||
costs = pd.read_csv("gen_build_costs.csv", dtype=dtype) | ||
predetermined = pd.read_csv("gen_build_predetermined.csv", dtype=dtype) | ||
|
||
gen_projects = df.merge( | ||
costs, | ||
on="GENERATION_PROJECT", | ||
) | ||
|
||
gen_projects = gen_projects.merge( | ||
predetermined, | ||
on=["GENERATION_PROJECT", "build_year"], | ||
how="left", # Makes a left join | ||
) | ||
|
||
# Get candiate technology only | ||
candidate = gen_projects.query("build_year == 2050").query( | ||
"gen_tech =='Battery_Storage'" | ||
) | ||
|
||
# Get canidate generation project id | ||
candidate_ids = candidate["GENERATION_PROJECT"].values | ||
|
||
gen_cost_mwh = costs.loc[ | ||
costs["GENERATION_PROJECT"].isin(candidate_ids), | ||
"gen_storage_energy_overnight_cost", | ||
].astype(float) | ||
|
||
# Set to zero column that allows technology to provide reserves | ||
costs.loc[ | ||
costs["GENERATION_PROJECT"].isin(candidate_ids), | ||
"gen_storage_energy_overnight_cost", | ||
] = ( | ||
gen_cost_mwh * percentage | ||
) | ||
|
||
# Save file again | ||
costs.to_csv("gen_build_costs.csv", index=False) |
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
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
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
Oops, something went wrong.