-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: extract pg pf from Switch results #108
Conversation
Should this have |
I like the idea of having a Scenario-like object from which the user can access all inputs and outputs. If |
I like this idea. What do you think @rouille ? If that's the way to go, shall we do it in this PR or in a separate PR, after we implement the extraction of timeseries of duals ( |
I guess this idea relates to making the MockScenario as described in #51. Once the output structure of this PR is set (i.e. the name of the new class and the methods that it has), I think we could get started on a feature for #51, and then in parallel we could work on the other aspects of #50, which should be able to get bolted onto the feature for #51 fairly easily. I think the biggest question in my mind is whether the |
As mentioned in the discussion of #107 , we should be consistent on function/variable names when referring to |
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.
The code looks good. We can change some of the higher-level design considerations (the name of the new class, etc.) as necessary when we integrate this into MockScenario creation to address #51.
83ec70c
to
fc3c542
Compare
Per @danielolsen 's suggestion, we now make import sys
from powersimdata import Scenario
sys.path.extend(['/Users/bainanxia/OneDrive - Gates Ventures/Documents/GitHub/SwitchWrapper'])
from switchwrapper.switch_to_profiles import ExtractTimeseries
grid = Scenario(599).get_grid() # the grid used as input to this Switch run
et = ExtractTimeseries(
"results.pickle",
"slicing_recovery.csv",
"./inputs/timepoints_input_v2.csv",
"./inputs/loads.csv",
"./inputs/variable_capacity_factors.csv",
grid
)
pg = et.get_pg()
pf = et.get_pf()
dcline_pf = et.get_dcline_pf()
demand = et.get_demand()
hydro = et.get_hydro()
wind = et.get_wind()
solar = et.get_solar() Now, the last thing we need to do is find a proper name for |
Besides its name, I think this class should be moved either to a different module or its own module. The |
|
There are |
True. |
Sounds reasonable. Any other ideas @rouille ? |
DataManager, SwitchData, RunData, ExpansionData, CEMData, ... Also, as mentioned above, I would move this class in a new module. |
Currently this class is the only thing in this module, we could simply rename this module then. Btw, This is not SwitchData/RunData, etc, right? We extract CEM outputs generated by Switch and transform it into a PCM compatible format. |
The module and the class are renamed into |
…in the doc strings
New usage demo after refactor: import sys
from powersimdata import Scenario
sys.path.extend(['/Users/bainanxia/OneDrive - Gates Ventures/Documents/GitHub/SwitchWrapper'])
from switchwrapper.switch_extract import SwitchExtract
grid = Scenario(599).get_grid() # the grid used as input to this Switch run
et = SwitchExtract(
"results.pickle",
"slicing_recovery.csv",
"./inputs/timepoints_input_v2.csv",
"./inputs/loads.csv",
"./inputs/variable_capacity_factors.csv",
grid
)
pg = et.get_pg()
pf = et.get_pf()
dcline_pf = et.get_dcline_pf()
demand = et.get_demand()
hydro = et.get_hydro()
wind = et.get_wind()
solar = et.get_solar() |
Do we need all these arguments? Are not the name of the files standard? In other words, would it be possible to just provide a path to a directory and load the files in the constructor of the class? |
Not all of these files have a standardized location that they are saved to within the project folder that SwitchWrapper creates on input (see #51 (comment)). Once we do save them, then we could create a static method of the |
I'm thinking about the same thing. We don't have a file directory structure for SwitchWrapper as we did for the PCM yet. Maybe it won't hurt to refactor this after we have one. |
Pull Request doc
Purpose
Extract time series results, power generation (PG) for each plant (original and expanded), power flow (PF) for each branches (ac and dc), for each investment year, from Switch results. Partially addresses #50
What the code is doing
switch_to_profiles.py
is created with a new classExtractTimeseries
. Creating a class instead of a function due to concerns:ExtractTimeseries
:_timestamp_to_investment_year
: map timestamps to investment year via timepoints_get_parsed_data
: feed raw results from pickle file and parameters to functionparse_timepoints
_calculate_net_pf
: calculate net power flow between bus tuples by combining mirror flow of pairs (A, B), (B, A).ExtractTimeseries
:get_pg
: get time series power generation for both original and expanded plants in every investment year.get_pf
: get time series power flow for all ac branches in every investment year.x
) instead of impedance assuming resistancer
<<x
.get_dcline_pf
: get time series power flow for all dc branches in every investment year.Pmax
), although we don't have any parallel dc lines in the system so far.Testing
Tested manually.
Where to look
switchwrapper/switch_to_profiles.py
Usage Example/Visuals
pg[2030]

pf[2030]

dcline_pf[2030]

Time estimate
30-40 min