powersimdata.tests package

Submodules

powersimdata.tests.mock_analyze module

class powersimdata.tests.mock_analyze.MockAnalyze(grid_attrs=None, congl=None, congu=None, ct=None, demand=None, bus_demand=None, lmp=None, pf=None, pg=None, dcline_pf=None, storage_e=None, storage_pg=None, solar=None, wind=None, hydro=None)[source]

Bases: object

A mock of a powersimdata.scenario.analyze.Analyze object.

Parameters:
  • grid_attrs (dict) – fields to be added to grid.

  • congl (pandas.DataFrame) – dummy congl

  • congu (pandas.DataFrame) – dummy congu

  • ct (dict) – dummy ct

  • demand (pandas.DataFrame) – dummy demand

  • lmp (pandas.DataFrame) – dummy lmp

  • pf (pandas.DataFrame) – dummy pf

  • pg (pandas.DataFrame) – dummy pg

  • storage_pg (pandas.DataFrame) – dummy storage_pg

  • solar (pandas.DataFrame) – dummy solar

  • wind (pandas.DataFrame) – dummy wind

  • hydro (pandas.DataFrame) – dummy hydro

exported_methods = ['get_congl', 'get_congu', 'get_ct', 'get_bus_demand', 'get_demand', 'get_grid', 'get_lmp', 'get_pf', 'gt_dcline_pf', 'get_pg', 'get_storage_pg', 'get_storage_e', 'get_solar', 'get_wind', 'get_hydro', 'get_profile']
get_bus_demand()[source]

Get bus demand. :return: (pandas.DataFrame) – dummy bus demand

get_congl()[source]

Get congl. :return: (pandas.DataFrame) – dummy congl

get_congu()[source]

Get congu. :return: (pandas.DataFrame) – dummy congu

get_ct()[source]

Get ct. :return: (Dict) – dummy ct

get_dcline_pf()[source]

Get PF_DCLINE. :return: (pandas.DataFrame) – dummy pf_dcline

get_demand(original=None)[source]

Get demand. :return: (pandas.DataFrame) – dummy demand

get_grid()[source]

Get grid. :return: (MockGrid) – mock grid

get_hydro()[source]

Get hydro. :return: (pandas.DataFrame) – dummy hydro

get_lmp()[source]

Get lmp. :return: (pandas.DataFrame) – dummy lmp

get_pf()[source]

Get PF. :return: (pandas.DataFrame) – dummy pf

get_pg()[source]

Get PG. :return: (pandas.DataFrame) – dummy pg

get_profile(kind)[source]

Return profile

Parameters:

kind (str) – either ‘demand’, ‘hydro’, ‘solar’, ‘wind’.

Returns:

(pandas.DataFrame) – dummy profile.

Raises:

ValueError – if kind is invalid.

get_solar()[source]

Get solar. :return: (pandas.DataFrame) – dummy solar

get_storage_e()[source]

Get storage E. :return: (pandas.DataFrame) – dummy storage_e

get_storage_pg()[source]

Get storage PG. :return: (pandas.DataFrame) – dummy storage_pg

get_wind()[source]

Get wind. :return: (pandas.DataFrame) – dummy wind

powersimdata.tests.mock_builder module

class powersimdata.tests.mock_builder.MockBuilder(ct=None)[source]

Bases: object

powersimdata.tests.mock_change_table module

class powersimdata.tests.mock_change_table.MockChangeTable(grid, ct=None)[source]

Bases: object

powersimdata.tests.mock_context module

class powersimdata.tests.mock_context.MockContext[source]

Bases: object

get_data_access(ignored=None)[source]

powersimdata.tests.mock_grid module

class powersimdata.tests.mock_grid.MockGrid(grid_attrs=None, model='usa_tamu')[source]

Bases: AbstractGrid

powersimdata.tests.mock_profile_input module

class powersimdata.tests.mock_profile_input.MockProfileInput(grid: Grid, start_time='2016-01-01 00:00:00', end_time=None, periods=24, freq='H', random_seed=6669)[source]

Bases: object

MockInputData is a mock of powersimdata.input.profile_input.ProfileInput that generates random profiles.

Exactly 3 of {start_time, end_time, periods, freq} must be specified. See <https://pandas.pydata.org/docs/reference/api/pandas.date_range.html>.

Parameters:
  • grid (powersimdata.input.grid.Grid) – instance of Grid object.

  • start_time (str) – when profiles begin.

  • end_time (str) – when profiles end.

  • periods (int) – number of times in profile.

  • freq (str) – frequency of times in profile.

  • random_seed (int) – used to initialize the random generator.

Raises:

ValueError – raised if field_name specified in get_data() is not specified by this mock

Returns:

(powersimdata.tests.mock_profile_input.MockProfileInput)

get_data(scenario_info, field_name)[source]

Returns fake profile data.

Parameters:
  • scenario_info (dict) – not used.

  • field_name (str) – Can be any of ‘demand’, ‘hydro’, ‘solar’, ‘wind’, ‘demand_flexibility_up’, or ‘demand_flexibility_dn’.

Returns:

(pandas.DataFrame) – fake profile data

powersimdata.tests.mock_scenario module

class powersimdata.tests.mock_scenario.MockScenario(grid_attrs=None, **kwargs)[source]

Bases: object

Parameters:
  • grid_attrs (dict) – fields to be added to grid.

  • **kwargs – collected keyword arguments to be passed to MockAnalyze init.

powersimdata.tests.mock_scenario_info module

class powersimdata.tests.mock_scenario_info.MockScenarioInfo(scenario=None)[source]

Bases: ScenarioInfo

area_to_loadzone(area, area_type=None)[source]
Map the query area to a list of loadzones. For more info, see

powersimdata.network.model.area_to_loadzone().

Parameters:
  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(set) – set of loadzones associated to the query area

get_available_resource(area, area_type=None)[source]
Find the available resources of a specific area in the grid of the

given scenario

Parameters:
  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(list) – a list of available resources in the query area

get_capacity(gentype, area, area_type=None)[source]
Calculate the total capacity of the query gentype in the query area

of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – total capacity (in MW) based on the specified parameters

get_capacity_factor(gentype, area, start_time, end_time, area_type=None)[source]
Calculate the capacity factor of the query gentype in the

query area during the query time range of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – capacity factor based on the specified parameters

Raises:

ZeroDivisionError – if no generator of gentype is found in the area

get_curtailment(gentype, area, start_time, end_time, area_type=None)[source]
Calculate the curtailment of the query gentype in the query

area during the query time range of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – curtailment percentage (rounded up to two decimals) based on the specified parameters

get_demand(area, start_time, end_time, area_type=None)[source]
Calculate the total demand of the query area during the query time

range of the given scenario

Parameters:
  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – total demand (in MWh) based on the specified parameters

get_generation(gentype, area, start_time, end_time, area_type=None)[source]
Calculate the total generation of the query gentype in the query

area during the query time range of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – total generation (in MWh) based on the specified parameters

get_no_congest_capacity_factor(gentype, area, start_time, end_time, area_type=None)[source]
Calculate the no congestion capacity factor of the query gentype

in the query area during the query time range of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – no congestion capacity factor based on the specified parameters

get_profile_resource(gentype, area, start_time, end_time, area_type=None)[source]
Calculate the total resource from profile of the query gentype in

the query area during the query time range of the given scenario

Parameters:
  • gentype (str) – type of generator

  • area (str) – one of: loadzone, state, state abbreviation, interconnect, ‘all’

  • start_time (str) – start timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • end_time (str) – end timestamp in the format ‘YYYY-MM-DD HH:MM:SS’

  • area_type (str) – one of: ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

Returns:

(float) – total resource from profile (in MWh) based on the specified parameters

Raises:

ValueError – if the resource type is invalid

powersimdata.tests.test_mocks module

class powersimdata.tests.test_mocks.TestMockGrid[source]

Bases: object

test_mock_grid_failures()[source]
test_mock_grid_successes()[source]
class powersimdata.tests.test_mocks.TestMockInputData[source]

Bases: object

grid()[source]
test_create_mock_profile_input(grid)[source]
test_happy_case(grid)[source]
test_multiple_get_data_calls_returns_same_data(grid)[source]
test_no_end_time(grid)[source]
test_no_freq(grid)[source]
test_no_period(grid)[source]
test_no_start_time(grid)[source]
test_raise_if_all_date_range_fields_present(grid)[source]
test_raise_if_no_profile_specified(grid)[source]
class powersimdata.tests.test_mocks.TestMockScenario[source]

Bases: object

test_mock_hydro_stored_properly(mock_hydro)[source]
test_mock_pg_stored_properly(mock_pg)[source]
test_mock_profile(mock_hydro, mock_solar, mock_wind)[source]
test_mock_profile_value()[source]
test_mock_solar_stored_properly(mock_solar)[source]
test_mock_wind_stored_properly(mock_wind)[source]
class powersimdata.tests.test_mocks.TestMockScenarioInfo[source]

Bases: object

test_create_mock_scenario_info()[source]
test_default_float()[source]
test_grid_set_correctly()[source]
test_info_set_correctly()[source]
powersimdata.tests.test_mocks.mock_hydro(mock_pg)[source]
powersimdata.tests.test_mocks.mock_pg()[source]
powersimdata.tests.test_mocks.mock_solar(mock_pg)[source]
powersimdata.tests.test_mocks.mock_wind(mock_pg)[source]

Module contents