powersimdata.scenario package¶
Subpackages¶
Submodules¶
powersimdata.scenario.analyze module¶
- class powersimdata.scenario.analyze.Analyze(scenario)[source]¶
Bases:
Ready
Scenario is in a state of being analyzed.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.
- allowed = ['delete']¶
- exported_methods = {'get_averaged_cong', 'get_base_grid', 'get_bus_demand', 'get_congl', 'get_congu', 'get_ct', 'get_dcline_pf', 'get_demand', 'get_gentype_profile', 'get_grid', 'get_hydro', 'get_lmp', 'get_load_shed', 'get_load_shift_dn', 'get_load_shift_up', 'get_pf', 'get_pg', 'get_profile', 'get_solar', 'get_storage_e', 'get_storage_pg', 'get_wind', 'print_infeasibilities', 'print_scenario_info'}¶
- get_averaged_cong()[source]¶
Returns averaged CONGL and CONGU.
- Returns:
(pandas.DataFrame) – data frame of averaged congestion with the branch id as indices an the averaged CONGL and CONGU as columns.
- get_congl()[source]¶
Returns CONGL data frame. CONGL = Congestion, Lower flow limit
- Returns:
(pandas.DataFrame) – data frame of branch flow mu (lower).
- get_congu()[source]¶
Returns CONGU data frame. CONGU = Congestion, Upper flow limit
- Returns:
(pandas.DataFrame) – data frame of branch flow mu (upper).
- get_dcline_pf()[source]¶
Returns PF_DCLINE data frame.
- Returns:
(pandas.DataFrame) – data frame of power flow on DC line(s).
- get_demand(original=True)[source]¶
Returns demand profiles.
- Parameters:
original (bool) – should the original demand profile or the potentially modified one be returned.
- Returns:
(pandas.DataFrame) – data frame of demand (hour, zone).
- get_lmp()[source]¶
Returns LMP data frame. LMP = locational marginal price
- Returns:
(pandas.DataFrame) – data frame of nodal prices.
- get_load_shed()[source]¶
Returns LOAD_SHED data frame, either via loading or calculating.
- Returns:
(pandas.DataFrame) – data frame of load shed (hour x bus).
- get_load_shift_dn()[source]¶
Returns LOAD_SHIFT_DN data frame. This is the amount that flexible demand deviates below (e.g., curtails) the base demand.
- Returns:
(pandas.DataFrame) – data frame of load shifted down (hour x bus).
- get_load_shift_up()[source]¶
Returns LOAD_SHIFT_UP data frame. This is the amount that flexible demand deviates above (e.g., recovers) the base demand.
- Returns:
(pandas.DataFrame) – data frame of load shifted up (hour x bus).
- get_pg()[source]¶
Returns PG data frame.
- Returns:
(pandas.DataFrame) – data frame of power generated.
- get_storage_e()[source]¶
Returns STORAGE_E data frame. Energy state of charge.
- Returns:
(pandas.DataFrame) – data frame of energy state of charge.
- get_storage_pg()[source]¶
Returns STORAGE_PG data frame.
- Returns:
(pandas.DataFrame) – data frame of power generated by storage units.
- name = 'analyze'¶
- refresh(scenario)[source]¶
Called during state changes to ensure instance is properly initialized
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance
powersimdata.scenario.check module¶
powersimdata.scenario.create module¶
- class powersimdata.scenario.create.Create(scenario)[source]¶
Bases:
State
Scenario is in a state of being created.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.
- allowed = []¶
- default_exported_methods = {'create_scenario', 'get_bus_demand', 'print_scenario_info', 'set_grid'}¶
- get_bus_demand()[source]¶
Returns demand profiles, by bus.
- Returns:
(pandas.DataFrame) – data frame of demand (hour, bus).
- name = 'create'¶
- class powersimdata.scenario.create.FromCSV(grid_model, interconnect, table, **kwargs)[source]¶
Bases:
_Builder
Build scenario using grid model and associated profiles enclosed in CSV files
- Parameters:
model (str grid) – the grid model
interconnect (list) – list of interconnect(s) to build.
table (pandas.DataFrame) – scenario list table.
**kwargs – optional parameters used to instantiate a Grid object.
- get_base_profile(kind)[source]¶
Return available base profiles.
- Parameters:
kind (str) – one of ‘demand’, ‘hydro’, ‘solar’, ‘wind’.
- Returns:
(list) – available version for selected profile kind.
- class powersimdata.scenario.create.FromPyPSA(grid_model, interconnect, table, **kwargs)[source]¶
Bases:
_Builder
Build scenario from a PyPSA Network object
- Parameters:
model (str grid) – the grid model
interconnect (list) – list of interconnect(s) to build.
table (pandas.DataFrame) – scenario list table.
**kwargs – optional parameters used to instantiate a Grid object: ‘reduction’: number of nodes in the network. If None, the full resolution PyPSA Network object will be used. Available reductions are specified in the
powersimdata.network.europe_tub.model
module.
- powersimdata.scenario.create.get_builder(grid_model, interconnect, table, **kwargs)[source]¶
Returns a Builder instance
- Parameters:
model (str grid) – the grid model
interconnect (list) – list of interconnect(s) to build.
table (pandas.DataFrame) – scenario list table
**kwargs – optional parameters used to instantiate a Grid object.
- Returns:
(object) – builder instance associated with the grid model.
powersimdata.scenario.delete module¶
- class powersimdata.scenario.delete.Delete(scenario)[source]¶
Bases:
Ready
Deletes scenario.
- allowed = []¶
- delete_scenario(confirm=True)[source]¶
Deletes scenario on server.
- Parameters:
confirm (bool) – prompt before each batch
- exported_methods = {'delete_scenario', 'get_base_grid', 'get_bus_demand', 'get_ct', 'get_demand', 'get_gentype_profile', 'get_grid', 'get_hydro', 'get_profile', 'get_solar', 'get_wind', 'print_scenario_info'}¶
- name = 'delete'¶
powersimdata.scenario.execute module¶
- class powersimdata.scenario.execute.Execute(scenario)[source]¶
Bases:
Ready
Scenario is in a state of being executed.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.
- allowed = ['delete']¶
- check_progress()[source]¶
Get the status of an ongoing simulation, if possible
- Returns:
(dict) – either None if using ssh, or a dict which contains “output”, “errors”, “scenario_id”, and “status” keys which map to stdout, stderr, and the respective scenario attributes
- exported_methods = {'check_progress', 'extract_simulation_output', 'get_base_grid', 'get_bus_demand', 'get_ct', 'get_demand', 'get_gentype_profile', 'get_grid', 'get_hydro', 'get_profile', 'get_solar', 'get_wind', 'launch_simulation', 'prepare_simulation_input', 'print_scenario_info', 'print_scenario_status', 'scenario_id'}¶
- extract_simulation_output()[source]¶
Extracts simulation outputs {PG, PF, LMP, CONGU, CONGL} on server.
- Returns:
(subprocess.Popen) – new process used to extract output data.
- launch_simulation(threads=None, solver=None, extract_data=True)[source]¶
Launches simulation on target environment
- Parameters:
threads (int/None) – the number of threads to be used. This defaults to None, where None means auto.
solver (str) – the solver used for optimization. This defaults to None, which translates to gurobi
extract_data (bool) – whether the results of the simulation engine should automatically extracted after the simulation has run. This defaults to True.
- Returns:
(subprocess.Popen) or (dict) - the process, if using ssh to server, otherwise a dict containing status information.
- name = 'execute'¶
- prepare_simulation_input(profiles_as=None)[source]¶
Prepares scenario for execution
- Parameters:
profiles_as (int/str/None) – if given, copy profiles from this scenario.
- Raises:
TypeError – if profiles_as parameter not a str or int.
- refresh(scenario)[source]¶
Called during state changes to ensure instance is properly initialized
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance
- property scenario_id¶
Get the current scenario id
- Returns:
(str) – scenario id
- class powersimdata.scenario.execute.SimulationInput(data_access, scenario_info, grid, ct)[source]¶
Bases:
object
Prepares scenario for execution.
- Parameters:
data_access (powersimdata.data_access.data_access.DataAccess) – data access object.
scenario_info (dict) – scenario information.
grid (powersimdata.input.grid.Grid) – a Grid object.
ct (dict) – change table.
- prepare_demand_flexibility_parameters()[source]¶
Prepares demand_flexibility parameters file for simulation.
- prepare_profile(kind, profile_as=None, slice=False)[source]¶
Prepares profile for simulation.
- Parameters:
kind – one of demand, ‘hydro’, ‘solar’, ‘wind’, ‘demand_flexibility_up’, ‘demand_flexibility_dn’, ‘demand_flexibility_cost_up’, or ‘demand_flexibility_cost_dn’.
profile_as (int/str) – if given, copy profile from this scenario.
slice (bool) – whether to slice the profiles by the Scenario’s time range.
powersimdata.scenario.move module¶
- class powersimdata.scenario.move.BackUpDisk(data_access, scenario_id)[source]¶
Bases:
object
Back up scenario data to backup disk mounted on server.
- Parameters:
data_access (powersimdata.data_access.data_access.DataAccess) – data access object.
scenario_id (str) – scenario id
- class powersimdata.scenario.move.Move(scenario)[source]¶
Bases:
Ready
Moves scenario.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.
- allowed = []¶
- exported_methods = {'get_base_grid', 'get_bus_demand', 'get_ct', 'get_demand', 'get_gentype_profile', 'get_grid', 'get_hydro', 'get_profile', 'get_solar', 'get_wind', 'move_scenario', 'print_scenario_info'}¶
- move_scenario(confirm=True)[source]¶
Move scenario.
- Parameters:
confirm (bool) – prompt before deleting each batch of files
- Raises:
ValueError – if current deployment mode not supported
- name = 'move'¶
powersimdata.scenario.ready module¶
- class powersimdata.scenario.ready.Ready(scenario)[source]¶
Bases:
State
- exported_methods = {'get_base_grid', 'get_bus_demand', 'get_ct', 'get_demand', 'get_gentype_profile', 'get_grid', 'get_hydro', 'get_profile', 'get_solar', 'get_wind', 'print_scenario_info'}¶
- get_base_grid()[source]¶
Returns original grid.
- Returns:
(powersimdata.input.grid.Grid) – a Grid object.
- get_bus_demand()[source]¶
Returns demand profiles, by bus.
- Returns:
(pandas.DataFrame) – data frame of demand (hour, bus).
- get_demand(original=True)[source]¶
Returns demand profiles.
- Parameters:
original (bool) – should the original demand profile or the potentially modified one be returned.
- Returns:
(pandas.DataFrame) – data frame of demand (hour, zone).
- get_gentype_profile(gentype)[source]¶
Returns profile for a generator type.
- Parameters:
gentype (str) – generator type with profile.
- Returns:
(pandas.DataFrame) – profile.
- Raises:
ValueError – if
gentype
is invalid or not in the grid.
- get_hydro()[source]¶
Returns hydro profile
- Returns:
(pandas.DataFrame) – data frame of hydro energy output.
- get_profile(kind)[source]¶
Returns demand, hydro, solar or wind profile.
- Parameters:
kind (str) – either ‘demand’, ‘hydro’, ‘solar’, ‘wind’.
- Returns:
(pandas.DataFrame) – profile.
powersimdata.scenario.scenario module¶
- class powersimdata.scenario.scenario.Scenario(descriptor=None)[source]¶
Bases:
object
Handles scenario.
- Parameters:
descriptor (int/str) – scenario name or index. If None, default to a Scenario in Create state.
- Raises:
TypeError – if descriptor is not int or str
powersimdata.scenario.state module¶
- class powersimdata.scenario.state.State(scenario)[source]¶
Bases:
object
Defines an interface for encapsulating the behavior associated with a particular state of the Scenario object.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance
- Raises:
TypeError – if not instantiated through a derived class
- allowed = []¶
- exported_methods = {'print_scenario_info'}¶
- name = 'state'¶
- refresh(scenario)[source]¶
Called during state changes to ensure instance is properly initialized
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance