powersimdata.input package¶
Subpackages¶
- powersimdata.input.changes package
- powersimdata.input.const package
- powersimdata.input.converter package
- powersimdata.input.exporter package
- powersimdata.input.tests package
- Submodules
- powersimdata.input.tests.test_change_table module
ct()
test_add_branch_Pmin_and_Pmax()
test_add_branch_argument_buses_in_different_interconnect()
test_add_branch_zero_distance_between_buses()
test_add_bus_bad_list_entries()
test_add_bus_bad_type()
test_add_bus_success()
test_add_dcline_Pmin_and_Pmax_and_capacity()
test_add_dcline_Pmin_and_Pmax_success()
test_add_dcline_Pmin_gt_Pmax()
test_add_dcline_argument_negative_capacity()
test_add_dcline_argument_number_of_keys()
test_add_dcline_argument_same_buses()
test_add_dcline_argument_type()
test_add_dcline_argument_wrong_bus()
test_add_dcline_argument_wrong_keys()
test_add_dcline_in_different_interconnect()
test_add_dcline_output()
test_add_demand_flexibility()
test_add_new_elements_at_new_buses()
test_add_plant_argument_type()
test_add_plant_check_pmin_is_added()
test_add_plant_negative_pmax()
test_add_plant_negative_pmin()
test_add_plant_neighbor_can_be_on_same_bus()
test_add_plant_pmin_pmax_relationship()
test_add_plant_wrong_bus()
test_add_plant_wrong_resource()
test_add_renewable_plant_check_neighbor_is_added()
test_add_renewable_plant_missing_key_bus_id()
test_add_renewable_plant_missing_key_pmax()
test_add_renewable_plant_missing_key_type()
test_add_thermal_plant_missing_key_c0()
test_add_thermal_plant_missing_key_c1()
test_add_thermal_plant_missing_key_c2()
test_add_thermal_plant_wrong_coefficients()
test_change_table_clear_bad_key()
test_change_table_clear_bad_type()
test_change_table_clear_success()
test_remove_branch()
test_remove_bus()
test_resource_exist()
test_scale_pmin_by_plant_and_zone_too_high()
test_scale_pmin_by_plant_too_high()
test_scale_pmin_by_zone_too_high()
- powersimdata.input.tests.test_check module
check_grid_models_match_failure()
check_grid_models_match_success()
europe()
mock_gencost()
mock_grid()
mock_plant()
mock_scenario()
test_check_areas_and_format()
test_check_areas_and_format_argument_type()
test_check_areas_and_format_argument_value()
test_check_areas_are_in_grid_and_format()
test_check_areas_are_in_grid_and_format_argument_type()
test_check_areas_are_in_grid_and_format_argument_value()
test_check_data_frame()
test_check_data_frame_argument_type()
test_check_data_frame_argument_value()
test_check_date()
test_check_date_argument_type()
test_check_date_range_in_scenario()
test_check_date_range_in_scenario_argument_value()
test_check_date_range_in_time_series_argument_value()
test_check_epsilon()
test_check_epsilon_argument_type()
test_check_epsilon_argument_value()
test_check_gencost()
test_check_gencost_argument_type()
test_check_gencost_argument_value()
test_check_grid()
test_check_grid_type_failure()
test_check_grid_type_success()
test_check_number_hours_to_analyze()
test_check_number_hours_to_analyze_argument_type()
test_check_number_hours_to_analyze_argument_value()
test_check_plants_are_in_grid()
test_check_plants_are_in_grid_argument_type()
test_check_plants_are_in_grid_argument_value()
test_check_resources_and_format()
test_check_resources_and_format_argument_type()
test_check_resources_and_format_argument_value()
test_check_resources_are_in_grid_and_format()
test_check_resources_are_in_grid_and_format_argument_value()
test_check_resources_are_renewable_and_format()
test_check_resources_are_renewable_and_format_argument_value()
test_check_time_series()
test_check_time_series_argument_value()
test_error_handling()
- powersimdata.input.tests.test_configure module
- powersimdata.input.tests.test_expansion_candidates module
- powersimdata.input.tests.test_grid module
base_texas()
base_western()
test_deepcopy_works()
test_grid_eq_failure_branch()
test_grid_eq_failure_bus()
test_grid_eq_failure_dcline()
test_grid_eq_failure_gencost_before()
test_grid_eq_failure_plant()
test_grid_eq_failure_simple()
test_grid_eq_failure_storage()
test_grid_eq_failure_sub()
test_grid_eq_success_bus_type()
test_grid_eq_success_gencost_after()
test_grid_eq_success_plant_ramp30()
test_grid_eq_success_simple()
test_grid_incorrect_source()
test_grid_type()
test_that_fields_are_not_modified_when_loading_another_grid()
- powersimdata.input.tests.test_helpers module
TestResourcesInGrid
TestSummarizePlantToBus
TestSummarizePlantToLocation
check_dataframe_matches()
grid()
test_get_plant_id_for_resources()
test_get_plant_id_for_resources_argument_type()
test_get_plant_id_for_resources_argument_value()
test_get_plant_id_for_resources_in_area()
test_get_plant_id_for_resources_in_interconnects()
test_get_plant_id_for_resources_in_interconnects_argument_type()
test_get_plant_id_for_resources_in_interconnects_argument_value()
test_get_plant_id_for_resources_in_loadzones()
test_get_plant_id_for_resources_in_loadzones_argument_type()
test_get_plant_id_for_resources_in_loadzones_argument_value()
test_get_plant_id_for_resources_in_states()
test_get_plant_id_for_resources_in_states_argument_type()
test_get_plant_id_for_resources_in_states_argument_value()
test_get_plant_id_in_interconnects()
test_get_plant_id_in_interconnects_argument_type()
test_get_plant_id_in_interconnects_argument_value()
test_get_plant_id_in_loadzones()
test_get_plant_id_in_loadzones_argument_type()
test_get_plant_id_in_loadzones_argument_value()
test_get_plant_id_in_states()
test_get_plant_id_in_states_argument_type()
test_get_plant_id_in_states_argument_value()
test_get_storage_id_in_area()
- powersimdata.input.tests.test_input_data module
- powersimdata.input.tests.test_profile_input module
- powersimdata.input.tests.test_transform_demand module
- powersimdata.input.tests.test_transform_grid module
ct()
get_branch_id()
get_plant_id()
test_add_branch()
test_add_bus()
test_add_dcline()
test_add_gen_add_entries_in_gencost_data_frame()
test_add_gen_add_entries_in_plant_data_frame()
test_add_storage()
test_added_branch_scaled()
test_remove_branch()
test_remove_bus()
test_scale_branch_one_zone()
test_scale_branch_two_zones()
test_scale_dcline()
test_scale_gen_capacity_one_zone()
test_scale_gen_one_plant()
test_scale_gen_pmin_one_plant()
test_scale_gen_pmin_two_types_two_zones()
test_scale_gencost_one_plant()
test_scale_gencost_two_types_two_zones()
test_scale_one_branch()
test_scale_renewable_gen_gencost_one_zone()
test_scale_thermal_gen_gencost_two_types_two_zones()
test_that_only_capacities_are_modified_when_scaling_renewable_gen()
- powersimdata.input.tests.test_transform_profile module
base_grid()
get_change_table_for_id_scaling()
get_change_table_for_new_plant_addition()
get_change_table_for_zone_scaling()
get_plant_with_resource()
get_zone_with_resource()
mock_profile_input_class()
profile_input()
raw_demand()
raw_demand_flexibility_dn()
raw_demand_flexibility_up()
raw_hydro()
raw_solar()
raw_wind()
test_demand_is_scaled()
test_flexible_demand_profiles_are_trimmed()
test_hydro_is_scaled_by_id()
test_hydro_is_scaled_by_zone()
test_hydro_is_scaled_by_zone_and_id()
test_new_hydro_added()
test_new_hydro_are_not_scaled()
test_new_hydro_profile()
test_new_solar_are_added()
test_new_solar_are_not_scaled()
test_new_solar_profile()
test_new_wind_are_added()
test_new_wind_are_not_scaled()
test_new_wind_profile()
test_solar_is_scaled_by_id()
test_solar_is_scaled_by_zone()
test_solar_is_scaled_by_zone_and_id()
test_wind_is_scaled_by_id()
test_wind_is_scaled_by_zone()
test_wind_is_scaled_by_zone_and_id()
- Module contents
Submodules¶
powersimdata.input.abstract_grid module¶
powersimdata.input.change_table module¶
- class powersimdata.input.change_table.ChangeTable(grid)[source]¶
Bases:
object
Create change table for changes that need to be applied to the original grid as well as to the original demand, hydro, solar and wind profiles. A pickle file enclosing the change table in form of a dictionary can be created and transferred on the server. Keys are ‘demand’, ‘branch’, ‘dcline’, ‘new_branch’, ‘new_dcline’, ‘new_plant’, ‘storage’, ‘[resource]’, ‘[resource]_cost’, and ‘[resource]_pmin’,; where ‘resource’ is defined in
powersimdata.network.constants.plants.Resource
and depends on the grid model. If a key is missing in the dictionary, then no changes will be applied. The data structure is given below:- ‘demand’:
value is a dictionary. The latter has ‘zone_id’ as keys and a factor indicating the desired increase/decrease of load in zone (1.2 would correspond to a 20% increase while 0.95 would be a 5% decrease) as value.
- ‘branch’:
value is a dictionary. The latter has ‘branch_id’ and/or ‘zone_id’ as keys. The ‘branch_id’ dictionary has the branch ids as keys while the ‘zone_id’ dictionary has the zone ids as keys. The value of those dictionaries is a factor indicating the desired increase/decrease of capacity of the line or the lines in the zone (1.2 would correspond to a 20% increase while 0.95 would be a 5% decrease).
- ‘[resource]’:
value is a dictionary. The latter has ‘plant_id’ and/or ‘zone_id’ as keys. The ‘plant_id’ dictionary has the plant ids as keys while the ‘zone_id’ dictionary has the zone ids as keys. The value of those dictionaries is a factor indicating the desired increase/decrease of capacity of the plant or plants in the zone fueled by ‘[resource]’ (1.2 would correspond to a 20% increase while 0.95 would be a 5% decrease).
- ‘[resource]_cost’:
value is a dictionary. The latter has ‘plant_id’ and/or ‘zone_id’ as keys. The ‘plant_id’ dictionary has the plant ids as keys while the ‘zone_id’ dictionary has the zone ids as keys. The value of those dictionaries is a factor indicating the desired increase/decrease of cost of the plant or plants in the zone fueled by ‘[resource]’ (1.2 would correspond to a 20% increase while 0.95 would be a 5% decrease).
- ‘[resource]_pmin:
value is a dictionary. The latter has ‘plant_id’ and/or ‘zone_id’ as keys. The ‘plant_id’ dictionary has the plant ids as keys while the ‘zone_id’ dictionary has the zone ids as keys. The value of those dictionaries is a factor indicating the desired increase/decrease of minimum generation of the plant or plants in the zone fueled by ‘[resource]’ (1.2 would correspond to a 20% increase while 0.95 would be a 5% decrease).
- ‘dcline’:
value is a dictionary. The latter has ‘dcline_id’ as keys and the and the scaling factor for the increase/decrease in capacity of the line as value.
- ‘storage’:
value is a list. Each entry in this list is a dictionary enclosing all the information needed to add a new storage device to the grid. The keys in the dictionary are: ‘bus_id’, ‘capacity’, “duration”, “min_stor”, “max_stor”, “energy_value”, “InEff”, “OutEff”, “LossFactor”, “terminal_min”, and “terminal_max”. See the
add_storage_capacity()
method for details.
- ‘new_dcline’:
value is a list. Each entry in this list is a dictionary enclosing all the information needed to add a new dcline to the grid. The keys in the dictionary are: ‘capacity’, ‘from_bus_id’ and ‘to_bus_id’ with values giving the capacity of the HVDC line and the bus id at each end of the line.
- ‘new_branch’:
value is a list. Each entry in this list is a dictionary enclosing all the information needed to add a new branch to the grid. The keys in the dictionary are: ‘capacity’, ‘from_bus_id’ and ‘to_bus_id’ with values giving the capacity of the line and the bus id at each end of the line.
- ‘new_plant’:
value is a list. Each entry in this list is a dictionary enclosing all the information needed to add a new generator to the grid. The keys in the dictionary are ‘type’, ‘bus_id’, ‘Pmax’ for renewable generators and ‘type’, ‘bus_id’, ‘Pmax’, ‘c0’, ‘c1’, ‘c2’ for thermal generators. An optional ‘Pmin’ can be passed for both renewable and thermal generators. The values give the fuel type, the identification number of the bus, the maximum capacity of the generator, the coefficients of the cost curve (polynomials) and optionally the minimum capacity of the generator.
- ‘new_bus’:
value is a list. Each entry in this list is a dictionary enclosing all the information needed to add a new bus to the grid. The keys in the dictionary are: ‘lat’, ‘lon’, one of ‘zone_id’/’zone_name’, and optionally ‘Pd’, specifying the location of the bus, the demand zone, and optionally the nominal demand at that bus (defaults to 0).
- ‘remove_branch’:
value is a set. Each entry in this set is a branch ID to be removed.
- ‘remove_bus’:
value is a set. Each entry in this set is a bus ID to be removed.
- ‘remove_dcline’:
value is a set. Each entry in this set is a DC line ID to be removed.
- ‘remove_plant’:
value is a set. Each entry in this set is a plant ID to be removed.
- add_branch(info)[source]¶
Sets parameters of new branch(es) in change table.
- Parameters:
info (list) – each entry is a dictionary. The dictionary gathers the information needed to create a new branch. Required keys: “from_bus_id”, “to_bus_id”, “capacity”.
- Raises:
TypeError – if
info
is not a list.
- add_dcline(info)[source]¶
Adds HVDC line(s).
- Parameters:
info (list) – each entry is a dictionary. The dictionary gathers the information needed to create a new dcline. Required keys: “from_bus_id”, “to_bus_id”. Optional keys: “capacity”, “Pmax”, “Pmin”. “capacity” denotes a bidirectional power limit (MW). “Pmax” denotes a limit on power flowing from ‘from’ end to ‘to’ end. “Pmin” denotes a limit on power flowing from ‘from’ end to ‘to’ end. Either “capacity” XOR (“Pmax” and “Pmin”) must be provided. capacity: 200 is equivalent to Pmax: 200, Pmin: -200.
- Raises:
TypeError – if
info
is not a list.
- add_demand_flexibility(info)[source]¶
Adds demand flexibility to the system.
See
powersimdata.input.changes.demand_flex.add_demand_flexibility()
- add_electrification(kind, info)[source]¶
Add profiles and scaling factors for electrified demand.
See
powersimdata.input.changes.electrification.add_electrification()
- add_storage_capacity(info)[source]¶
Sets storage parameters in change table.
See
powersimdata.input.changes.storage.add_storage_capacity()
- clear(which=None)[source]¶
Clear all or part of the change table.
- Parameters:
which (str/set) – str or set of strings of what to clear from self.ct If None (default), everything is cleared.
- remove_branch(info)[source]¶
Remove one or more branches.
- Parameters:
info (int/iterable) – iterable of branch indices, or a single branch index.
- Raises:
ValueError – if
info
contains one or more entries not present in the branch table index.
- remove_dcline(info)[source]¶
Remove one or more DC lines.
- Parameters:
info (int/iterable) – iterable of DC line indices, or a single index.
- Raises:
ValueError – if
info
contains one or more entries not present in the dcline table index.
- scale_branch_capacity(zone_name=None, branch_id=None)[source]¶
Sets branch capacity scaling factor in change table.
- Parameters:
zone_name (dict) – load zones. The key(s) is (are) the name of the load zone(s) and the associated value is the scaling factor for the increase/decrease in capacity of all the branches in the load zone. Only lines that have both ends in zone are considered.
branch_id (dict) – identification numbers of branches. The key(s) is (are) the id of the line(s) and the associated value is the scaling factor for the increase/decrease in capacity of the line(s).
- scale_congested_mesh_branches(ref_scenario, **kwargs)[source]¶
Scales congested branches based on previous scenario results.
- Parameters:
ref_scenario (powersimdata.scenario.scenario.Scenario) – the reference scenario to be used in determining branch scaling.
- Optional kwargs as documented in the
- scale_dcline_capacity(dcline_id)[source]¶
Sets DC line capacity scaling factor in change table.
- Parameters:
dcline_id (dict) – identification numbers of dc line. The key(s) is (are) the id of the line(s) and the associated value is the scaling factor for the increase/decrease in capacity of the line(s).
- scale_demand(zone_name=None, zone_id=None)[source]¶
Sets load scaling factor in change table.
- Parameters:
zone_name (dict) – load zones. The key(s) is (are) the name of the load zone(s) and the value is the scaling factor for the increase/decrease in load.
zone_id (dict) – identification numbers of the load zones. The key(s) is (are) the id of the zone(s) and the associated value is the scaling factor for the increase/decrease in load.
- scale_plant_capacity(resource, zone_name=None, plant_id=None)[source]¶
Sets plant capacity scaling factor in change table.
- Parameters:
resource (str) – type of generator to consider.
zone_name (dict) – load zones. The key(s) is (are) the name of the load zone(s) and the associated value is the scaling factor for the increase/decrease in capacity of all the generators fueled by specified resource in the load zone.
plant_id (dict) – identification numbers of plants. The key(s) is (are) the id of the plant(s) and the associated value is the scaling factor for the increase/decrease in capacity of the generator.
- scale_plant_cost(resource, zone_name=None, plant_id=None)[source]¶
Sets plant cost scaling factor in change table.
- Parameters:
resource (str) – type of generator to consider.
zone_name (dict) – load zones. The key(s) is (are) the name of the load zone(s) and the associated value is the scaling factor for the increase/decrease in cost of all the generators fueled by specified resource in the load zone.
plant_id (dict) – identification numbers of plants. The key(s) is (are) the id of the plant(s) and the associated value is the scaling factor for the increase/decrease in cost of the generator.
- scale_plant_pmin(resource, zone_name=None, plant_id=None)[source]¶
Sets plant cost scaling factor in change table.
powersimdata.input.check module¶
- powersimdata.input.check.check_grid(grid)[source]¶
Check whether an object is an internally-consistent Grid object.
- Parameters:
grid (powersimdata.input.grid.Grid) – grid or grid-like object to check.
- Raises:
ValueError – if
grid
has any inconsistency
powersimdata.input.configure module¶
- powersimdata.input.configure.adjust_pmin(grid)[source]¶
Adjust plant Pmin values inplace
- Parameters:
grid (powersimdata.input.grid.Grid) – a grid object
- powersimdata.input.configure.adjust_ramp30(plant)[source]¶
Adjust plant ramp_30 values inplace
- Parameters:
plant (pandas.DataDrame) – a plant dataframe
- powersimdata.input.configure.linearize_gencost(gencost_before, plant, num_segments=1)[source]¶
Updates the generator cost information to include piecewise linear cost curve information. Allows the user to specify the number of piecewise segments into which the cost curve should be split.
- Parameters:
gencost_before (pandas.DataFrame) – the original gencost
plant (pandas.DataFrame) – the generator information containing Pmin/Pmax
num_segments (int) – The number of segments into which the piecewise linear cost curve will be split.
- Returns:
(pandas.DataFrame) – An updated DataFrame containing the piecewise linear cost curve parameters.
- Raises:
ValueError – if the generator cost curve is not of an acceptable form.
powersimdata.input.electrified_demand_input module¶
- class powersimdata.input.electrified_demand_input.ElectrifiedDemand[source]¶
Bases:
ProfileInput
Loads electrification profile data
- get_profile(grid_model, kind, profile)[source]¶
Get the specified profile
- Parameters:
grid_model (str) – the grid model
kind (str) – the kind of electrification
profile (str) – the filename
- Returns:
(pandas.DataFrame) – profile data frame
- get_profile_version(grid_model, kind, end_use, tech)[source]¶
Returns available raw profile from blob storage or local disk.
- Parameters:
grid_model (str) – grid model.
kind (str) – ‘building’, ‘transportation’
end_use (str) – electrification use case
tech (str) – the technology used for the given use case
- Returns:
(list) – available profile version.
powersimdata.input.expansion_candidates module¶
- class powersimdata.input.expansion_candidates.ExpansionCandidates(grid)[source]¶
Bases:
object
Instantiate a data structure to hold candidates for expansion in a capacity expansion model.
- Parameters:
grid (powersimdata.input.grid.Grid) – reference grid
- branch: DataFrame¶
- plant: DataFrame¶
- set_branch(branch)[source]¶
Validate and assign branch candidates
- Parameters:
branch (pd.DataFrame) – branch dataframe
- set_plant(plant)[source]¶
Validate and assign plant candidates
- Parameters:
plant (pd.DataFrame) – plant dataframe
- set_storage(storage)[source]¶
Validate and assign storage candidates
- Parameters:
storage (pd.DataFrame) – storage dataframe
- storage: DataFrame¶
- powersimdata.input.expansion_candidates.check_branch(branch, grid)[source]¶
Check branch expansion candidates relative to a specific grid
- Parameters:
branch (pd.DataFrame) – dataframe of branch candidates
grid (powersimdata.input.grid.Grid) – reference grid
- powersimdata.input.expansion_candidates.check_branch_voltage(branch, grid)[source]¶
Check that branches are attached to buses with the same voltage
- Parameters:
branch (pd.DataFrame) – dataframe with from_bus and to_bus columns
grid (powersimdata.input.grid.Grid) – reference grid
- Raises:
ValueError – if any branches have mismatched voltage
- powersimdata.input.expansion_candidates.check_bus_id(bus_id, grid)[source]¶
Check that buses are within the given grid
- Parameters:
bus_id (pd.Series) – the bus ids to check
grid (powersimdata.input.grid.Grid) – reference grid
- Raises:
ValueError – if any buses are not in the grid
- powersimdata.input.expansion_candidates.check_plant(plant, grid)[source]¶
Check plant expansion candidates relative to a specific grid
- Parameters:
plant (pd.DataFrame) – dataframe of plant candidates
grid (powersimdata.input.grid.Grid) – reference grid
- powersimdata.input.expansion_candidates.check_storage(storage, grid)[source]¶
Check storage expansion candidates relative to a specific grid
- Parameters:
storage (pd.DataFrame) – dataframe of storage candidates
grid (powersimdata.input.grid.Grid) – reference grid
powersimdata.input.grid module¶
- class powersimdata.input.grid.Grid(interconnect, source='usa_tamu', **kwargs)[source]¶
Bases:
object
- SUPPORTED_IMPORTS = {'pypsa'}¶
- SUPPORTED_MODELS = {'europe_tub', 'usa_tamu'}¶
Grid
- Parameters:
interconnect (str/iterable) – geographical region covered. Either the region (e.g. USA), one of the interconnects in the region or a combination of the interconnects in the region. The full list of interconnects of the grid models is defined in
powersimdata.network.constants.model.model2interconnect
.source (str) – model used to build the network. Can be one of the supported models
- Raises:
TypeError – if source is not a string.
ValueError – if source is not a supported grid model.
powersimdata.input.helpers module¶
- powersimdata.input.helpers.decompose_plant_data_frame_into_areas(df, areas, grid)[source]¶
Take a plant-column data frame and decompose it into plant-column data frames for areas.
- Parameters:
df (pandas.DataFrame) – data frame, columns are plant id in grid.
areas (dict) – areas to use for decomposition. Keys are area types (’loadzone’, ‘state’, or ‘interconnect’), values are str/list/tuple/set of areas.
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(dict) – keys are areas, values are plant-column data frames.
- powersimdata.input.helpers.decompose_plant_data_frame_into_areas_and_resources(df, areas, resources, grid)[source]¶
Take a plant-column data frame and decompose it into plant-column data frames for each resources-areas combinations.
- Parameters:
df (pandas.DataFrame) – data frame, columns are plant id in grid.
areas (dict) – areas to use for decomposition. Keys are area types (’loadzone’, ‘state’ or ‘interconnect’), values are str/list/tuple/set of areas.
resources (str/list/tuple/set) – resource(s) to use for decomposition.
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(dict) – keys are areas, values are dictionaries whose keys are resources and values are data frames indexed by (datetime, plant) where plant include only plants of matching type and located in area.
- powersimdata.input.helpers.decompose_plant_data_frame_into_resources(df, resources, grid)[source]¶
Take a plant-column data frame and decompose it into plant-column data frames for each resource.
- Parameters:
df (pandas.DataFrame) – data frame, columns are plant id in grid.
resources (str/list/tuple/set) – resource(s) to use for decomposition.
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(dict) – keys are resources, values are plant-column data frames.
- powersimdata.input.helpers.decompose_plant_data_frame_into_resources_and_areas(df, resources, areas, grid)[source]¶
Take a plant-column data frame and decompose it into plant-column data frames for each resources-areas combinations.
- Parameters:
df (pandas.DataFrame) – data frame, columns are plant id in grid.
resources (str/list/tuple/set) – resource(s) to use for decomposition.
areas (dict) – areas to use for decomposition. Keys are area types (’loadzone’, ‘state’, ‘state_abv’ or ‘interconnect’), values are str/list/tuple/set of areas.
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(dict) – keys are resources, values are dictionaries whose keys are areas and values are data frames indexed by (datetime, plant) where plant include only plants of matching type and located in area.
- powersimdata.input.helpers.get_active_resources_in_grid(grid)[source]¶
Get active resources in grid.
- Parameters:
grid (powersimdata.input.grid.Grid) – a Grid instance.
- Returns:
(set) – name of active resources in grid.
- powersimdata.input.helpers.get_plant_id_for_resources(resources, grid)[source]¶
Get plant id for plants fueled by resource(s).
- Parameters:
resources (str/list/tuple/set) – name of resource(s).
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(set) – list of plant id.
- powersimdata.input.helpers.get_plant_id_for_resources_in_area(scenario, area, resources, area_type=None)[source]¶
Get the list of plant ids of certain resources in the specific area of a scenario.
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance
area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’
resources (str/list) – one or a list of resources
area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’
- Returns:
(list) – list of plant id
- powersimdata.input.helpers.get_plant_id_for_resources_in_interconnects(resources, interconnects, grid)[source]¶
Get plant id for for plants fueled by resource(s) in interconnect(s).
- Parameters:
resources (str/list/tuple/set) – name of resource(s).
interconnects (str/list/tuple/set) – name of interconnect(s).
grid (powersimdata.input.grid.Grid) – a Grid instance.
- Returns:
(set) – list of plant id.
- powersimdata.input.helpers.get_plant_id_for_resources_in_loadzones(resources, loadzones, grid)[source]¶
Get plant id for plants fueled by resource(s) in load zone(s).
- Parameters:
resources (str/list/tuple/set) – name of resource(s).
loadzones (str/list/tuple/set) – name of load zone(s).
grid (powersimdata.input.grid.Grid) – a Grid instance.
- Returns:
(set) – list of plant id.
- powersimdata.input.helpers.get_plant_id_for_resources_in_states(resources, states, grid)[source]¶
Get plant id for for plants fueled by resource(s) in state(s).
- Parameters:
resources (str/list/tuple/set) – name of resource(s).
states (str/list/tuple/set) – state(s) name or abbreviation.
grid (powersimdata.input.grid.Grid) – a Grid instance.
- Returns:
(set) – list of plant id
- powersimdata.input.helpers.get_plant_id_in_interconnects(interconnects, grid)[source]¶
Get plant id for plants in interconnect(s).
- Parameters:
interconnects (str/list/tuple/set) – name of interconnect(s).
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(set) – list of plant id
- powersimdata.input.helpers.get_plant_id_in_loadzones(loadzones, grid)[source]¶
Get plant id for plants in loadzone(s).
- Parameters:
loadzones (str/list/tuple/set) – name of load zone(s).
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(set) – list of plant id.
- powersimdata.input.helpers.get_plant_id_in_states(states, grid)[source]¶
Get plant id for plants in state(s).
- Parameters:
states (str/list/tuple/set) – states(s) name or abbreviation(s).
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(set) – list of plant id.
- powersimdata.input.helpers.get_resources_in_grid(grid)[source]¶
Get resources in grid.
- Parameters:
grid (powersimdata.input.grid.Grid) – a Grid instance.
- Returns:
(set) – name of all resources in grid.
- powersimdata.input.helpers.get_storage_id_in_area(scenario, area, area_type=None)[source]¶
Get the list of storage ids in the specific area of a scenario
- Parameters:
scenario (powersimdata.scenario.scenario.Scenario) – scenario instance
area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’
area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’
- Returns:
(list) – list of storage id
- powersimdata.input.helpers.summarize_plant_to_bus(df, grid, all_buses=False)[source]¶
Take a plant-column data frame and sum to a bus-column data frame.
- Parameters:
df (pandas.DataFrame) – dataframe, columns are plant id in grid.
grid (powersimdata.input.grid.Grid) – Grid instance.
all_buses (boolean) – return all buses in grid, not just plant buses.
- Returns:
(pandas.DataFrame) – index as df input, columns are buses.
- powersimdata.input.helpers.summarize_plant_to_location(df, grid)[source]¶
Take a plant-column data frame and sum to a location-column data frame.
- Parameters:
df (pandas.DataFrame) – dataframe, columns are plant id in grid.
grid (powersimdata.input.grid.Grid) – Grid instance.
- Returns:
(pandas.DataFrame) – index: df index, columns: location tuples.
powersimdata.input.input_base module¶
powersimdata.input.input_data module¶
- powersimdata.input.input_data.distribute_demand_from_zones_to_buses(zone_demand, bus)[source]¶
Decomposes zone demand to bus demand based on bus ‘Pd’ column.
- Parameters:
zone_demand (pandas.DataFrame) – demand by zone. Index is timestamp, columns are zone IDs, values are zone demand (MW).
bus (pandas.DataFrame) – table of bus data, containing at least ‘zone_id’ and ‘Pd’ columns.
- Returns:
(pandas.DataFrame) – data frame of demand. Index is timestamp, columns are bus IDs, values are bus demand (MW).
- Raises:
ValueError – if the columns of
zone_demand
don’t match the set of zone IDs within the ‘zone_id’ column ofbus
.
powersimdata.input.profile_input module¶
- class powersimdata.input.profile_input.ProfileInput[source]¶
Bases:
InputBase
Loads profile data
- get_profile_version(grid_model, kind)[source]¶
Returns available raw profile from blob storage or local disk.
- Parameters:
grid_model (str) – grid model.
kind (str) – ‘demand’, ‘hydro’, ‘solar’, ‘wind’, ‘demand_flexibility_up’, ‘demand_flexibility_dn’, ‘demand_flexibility_cost_up’, or ‘demand_flexibility_cost_dn’.
- Returns:
(list) – available profile version.
- upload(grid_model, name, profile)[source]¶
Upload the given profile to blob storage and local cache
- Parameters:
grid_model (str) – the grid model
name (str) – the file name for the profile, without extension
profile (pandas.DataFrame) – profile data frame
- Raises:
ValueError – if no credential with write access is set
- powersimdata.input.profile_input.get_profile_version(_fs, grid_model, kind)[source]¶
Returns available raw profile from the given filesystem
- Parameters:
_fs (fs.base.FS) – filesystem instance
grid_model (str) – grid model.
kind (str) – ‘demand’, ‘hydro’, ‘solar’, ‘wind’, ‘demand_flexibility_up’, ‘demand_flexibility_dn’, ‘demand_flexibility_cost_up’, or ‘demand_flexibility_cost_dn’.
- Returns:
(list) – available profile version.
powersimdata.input.transform_demand module¶
- class powersimdata.input.transform_demand.TransformDemand(grid, ct, kind)[source]¶
Bases:
object
Aggregate demand from electrified sources.
- Parameters:
grid (powersimdata.input.grid.Grid) – a grid object
powersimdata.input.change_table.ChangeTable – a change table object
kind (str) – the class of electrification, e.g. building, transportation
powersimdata.input.transform_grid module¶
- class powersimdata.input.transform_grid.TransformGrid(grid, ct)[source]¶
Bases:
object
Transforms grid according to operations listed in change table.
- powersimdata.input.transform_grid.voltage_to_x_per_distance(grid)[source]¶
Calculates reactance per distance for voltage level.
- Parameters:
grid (powersimdata.input.grid.Grid) – a Grid object instance.
- Returns:
(dict) – bus voltage to average reactance per mile.
powersimdata.input.transform_profile module¶
- class powersimdata.input.transform_profile.TransformProfile(scenario_info, grid, ct, slice=True)[source]¶
Bases:
object
Transform profile according to operations listed in change table.
- get_profile(name)[source]¶
Return profile.
- Parameters:
name (str) – either demand, ‘demand_flexibility_up’, ‘demand_flexibility_dn’, ‘demand_flexibility_cost_up’, ‘demand_flexibility_cost_dn’ or a generator type with profile.
- Returns:
(pandas.DataFrame) – profile.
- Raises:
ValueError – if argument not one of ‘demand’, ‘demand_flexibility_up’, ‘demand_flexibility_dn’, ‘demand_flexibility_cost_up’, ‘demand_flexibility_cost_dn’ or a generator type wit profile.