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_pf()[source]

Returns PF data frame.

Returns:

(pandas.DataFrame) – data frame of power flow.

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'
print_infeasibilities()[source]

Prints infeasibilities.

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 = []
create_scenario()[source]

Creates scenario.

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'
set_grid(grid_model='usa_tamu', interconnect='USA', **kwargs)[source]

Sets grid builder.

Parameters:
  • grid_model (str) – name of grid model. Default is ‘usa_tamu’.

  • interconnect (str/list) – name of interconnect(s). Default is ‘USA’.

  • **kwargs – optional parameters used to instantiate a Grid object.

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.

print_available_profile()[source]

Print available profiles for the grid model

set_base_grid()[source]

Set base grid

set_base_profile(kind, version)[source]

Set base profile.

Parameters:
  • kind (str) – one of ‘demand’, ‘hydro’, ‘solar’, ‘wind’.

  • version (str) – base profile version.

Raises:

ValueError – if no profiles are available or version is not available.

set_change_table()[source]

Set change table

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.

set_base_grid()[source]

Set base grid

set_base_profile()[source]

Set base profile.

set_change_table()[source]

Set change table

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.

print_scenario_status()[source]

Prints scenario status.

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:
prepare_demand_flexibility_parameters()[source]

Prepares demand_flexibility parameters file for simulation.

prepare_grid()[source]

Prepare grid 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:
backup_scenario(confirm=True)[source]

Copy scenario data to backup disk and remove original

Parameters:

confirm (bool) – prompt before deleting each batch of files

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_ct()[source]

Returns change table.

Returns:

(dict) – change table.

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_grid()[source]

Returns Grid.

Returns:

(powersimdata.input.grid.Grid) – a Grid object.

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.

get_solar()[source]

Returns solar profile

Returns:

(pandas.DataFrame) – data frame of solar energy output.

get_wind()[source]

Returns wind profile

Returns:

(pandas.DataFrame) – data frame of wind energy output.

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

change(state)[source]

Changes state.

Parameters:

state (class) – One of Analyze Create, Execute or Delete.

get_scenario_table()[source]

Get scenario table

Returns:

(pandas.DataFrame) – scenario table

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'
print_scenario_info()[source]

Prints scenario information.

refresh(scenario)[source]

Called during state changes to ensure instance is properly initialized

Parameters:

scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

switch(state)[source]

Switches state.

Parameters:

state (class) – One of Analyze, Create, Execute, Delete, Move.

Module contents