onsset package
Submodules
onsset.gui_runner module
onsset.onsset module
- class onsset.onsset.SettlementProcessor(path)[source]
Bases:
object
Processes the DataFrame and adds all the columns to determine the cheapest option and the final costs and summaries
- calc_summaries(df_summary, sumtechs, tech_codes, year)[source]
The next section calculates the summaries for technology split, capacity added and total investment cost
- calculate_investments_and_capacity(sa_diesel_investment, sa_diesel_capacity, sa_pv_investment, sa_pv_capacity, mg_diesel_investment, mg_diesel_capacity, mg_pv_investment, mg_pv_capacity, mg_wind_investment, mg_wind_capacity, mg_hydro_investment, mg_hydro_capacity, grid_investment, grid_capacity, year)[source]
- calculate_new_connections(year, time_step, start_year)[source]
this method defines new connections for grid related purposes
- Parameters:
year (int) –
time_step (int) –
start_year (int) –
- calculate_off_grid_lcoes(mg_hydro_calc, mg_wind_calc, mg_pv_calc, sa_pv_calc, mg_diesel_calc, sa_diesel_calc, year, end_year, time_step, techs, tech_codes, diesel_techs=0)[source]
Calculate the LCOEs for all off-grid technologies
- calculate_total_demand_per_settlement(year)[source]
this method calculates total demand for each settlement per year
- Parameters:
year (int) –
- calibrate_current_pop_and_urban(pop_actual, urban_current)[source]
The function calibrates population values and urban/rural split (as estimated from GIS layers) based on actual values provided by the user for the start year.
- calibrate_elec_current(elec_actual, elec_actual_urban, elec_actual_rural, start_year, min_night_lights=0, min_pop=50, max_transformer_dist=2, max_mv_dist=2, max_hv_dist=5, buffer=True)[source]
Calibrate the current electrification status
- choose_minimum_off_grid_tech(year, mg_hydro_calc, techs, tech_codes)[source]
Choose minimum LCOE off-grid technology
First step determines the off-grid technology with minimum LCOE Second step determines the value (number) of the selected minimum off-grid technology
- Parameters:
year (int) –
mg_hydro_calc (dict) –
- static classify_elevation(elevation)[source]
Classify the elevation distance according to bins and labels
- Parameters:
elevation (list) –
- static classify_land_cover(column)[source]
this is a different method employed to classify land cover and create new columns with the classification
- Parameters:
column (series) –
Notes
0, 11 = 1 6, 8 = 2 1, 3, 5, 12, 13, 15 = 3 2, 4 = 4 7, 9, 10, 14, 16 = 5
- static classify_road_distance(road_distance)[source]
Classify the road distance according to bins and labels
- Parameters:
road_distance (list) –
- static classify_slope(slope)[source]
Classify the slope according to bins and labels
- Parameters:
slope (list) –
- static classify_substation_distance(substation_distance)[source]
Classify the substation distance according to bins and labels
- Parameters:
substation_distance (list) –
- closest_electrified_settlement(new_electrified, unelectrified, cell_path_real, grid_penalty_ratio, elecorder)[source]
- compute_diesel_cost(dataframe: DataFrame, sa_diesel_cost: Dict, mg_diesel_cost: Dict, year: int)[source]
Calculate diesel fuel cost
- Parameters:
dataframe (pandas.DataFrame) –
sa_diesel_cost (Dict) –
mg_diesel_cost (Dict) –
year (int) –
- Return type:
pandas.DataFrame
- diesel_cost_columns(sa_diesel_cost: Dict[str, float], mg_diesel_cost: Dict[str, float], year: int)[source]
Calculate diesel fuel cost based on TravelHours column
- Parameters:
sa_diesel_cost (Dict) –
mg_diesel_cost (Dict) –
year (int) –
- elec_extension(grid_calc, max_dist, year, start_year, end_year, time_step, grid_capacity_limit, grid_connect_limit, new_investment, new_capacity, auto_intensification=0, prioritization=0)[source]
Iterate through all electrified settlements and find which settlements can be economically connected to the grid Repeat with newly electrified settlements until no more are added
- get_grid_lcoe(dist_adjusted, elecorder, additional_transformer, year, time_step, end_year, grid_calc)[source]
- grid_penalties(data_frame)[source]
this method calculates the grid penalties in each settlement
First step classifies the parameters and creates new columns with classification
Second step adds the grid penalty to increase grid cost in areas that higher road distance, higher substation distance, unsuitable land cover, high slope angle or high elevation
- static haversine_vector(lon1, lat1, lon2, lat2)[source]
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
- pre_electrification(grid_price, year, time_step, end_year, grid_calc, grid_capacity_limit, grid_connect_limit)[source]
” …
- prepare_wtf_tier_columns(num_people_per_hh_rural, num_people_per_hh_urban, tier_1, tier_2, tier_3, tier_4, tier_5)[source]
Prepares the five Residential Demand Tier Targets based customized for each country
- project_pop_and_urban(pop_future, urban_future, start_year, years_of_analysis)[source]
This function projects population and urban/rural ratio for the different years of the analysis
- results_columns(techs, tech_codes, year, time_step, prio, auto_intensification)[source]
Calculate the capacity and investment requirements for each settlement
Once the grid extension algorithm has been run, determine the minimum overall option, and calculate the capacity and investment requirements for each settlement
- Parameters:
year (int) –
- set_residential_demand(rural_tier, urban_tier, num_people_per_hh_rural, num_people_per_hh_urban, productive_demand)[source]
this method defines residential demand per tier level for each target year
- Parameters:
rural_tier (int) –
urban_tier (int) –
num_people_per_hh_rural (float) –
num_people_per_hh_urban (float) –
productive_demand (int) –
- set_scenario_variables(year, num_people_per_hh_rural, num_people_per_hh_urban, time_step, start_year, urban_tier, rural_tier, end_year_pop, productive_demand)[source]
this method determines some basic parameters required in LCOE calculation it sets the basic scenario parameters that differ based on urban/rural so that they are in the table and can be read directly to calculate LCOEs
- Parameters:
year (int) –
num_people_per_hh_rural (float) –
num_people_per_hh_urban (float) –
time_step (int) –
start_year (int) –
urban_tier (int) –
rural_tier (int) –
end_year_pop (int) –
productive_demand (int) –
- class onsset.onsset.Technology(tech_life=0, base_to_peak_load_ratio=0, distribution_losses=0, connection_cost_per_hh=0, om_costs=0.0, capital_cost={inf: 0}, capacity_factor=0.9, grid_penalty_ratio=1, efficiency=1.0, diesel_price=0.0, grid_price=0.0, standalone=False, mini_grid=False, existing_grid_cost_ratio=0.1, grid_capacity_investment=0.0, diesel_truck_consumption=0, diesel_truck_volume=0, om_of_td_lines=0)[source]
Bases:
object
Used to define the parameters for each electricity access technology, and to calculate the LCOE depending on input parameters.
- distribution_network(people, energy_per_cell, num_people_per_hh, grid_cell_area, productive_nodes=0)[source]
This method calculates the required components for the distribution network This includes potentially MV lines, LV lines and service transformers
- Parameters:
people (float) – Number of people in settlement
energy_per_cell (float) – Annual energy demand in settlement (kWh)
num_people_per_hh (float) – Number of people per household in settlement
grid_cell_area (float) – Area of settlement (km2)
productive_nodes (int) – Additional connections (schools, health facilities, shops)
Notes
Based on: https://www.mdpi.com/1996-1073/12/7/1395
- get_lcoe(energy_per_cell, people, num_people_per_hh, start_year, end_year, new_connections, total_energy_per_cell, prev_code, grid_cell_area, additional_mv_line_length=0.0, capacity_factor=0.9, grid_penalty_ratio=1, fuel_cost=0, elec_loop=0, productive_nodes=0, additional_transformer=0, penalty=1)[source]
Calculates the LCOE depending on the parameters.
- Parameters:
people (float or pandas.Series) – Number of people in settlement
new_connections (float or pandas.Series) – Number of new people in settlement to connect
prev_code (int or pandas.Series) – Code representation of previous supply technology in settlement
total_energy_per_cell (float or pandas.Series) – Total annual energy demand in cell, including already met demand
energy_per_cell (float or pandas.Series) – Annual energy demand in cell, excluding already met demand
num_people_per_hh (float or pandas.Series) – Number of people per household in settlement
grid_cell_area (float or pandas.Series) – Area of settlement (km2)
additional_mv_line_length (float or pandas.Series) – Distance to connect the settlement
additional_transformer (int) – If a transformer is needed on other end to connect to HV line
productive_nodes (int or pandas.Series) – Additional connections (schools, health facilities, shops)
elec_loop (int or pandas.Series) – Round of extension in grid extension algorithm
penalty (float or pandas.Series) – Cost penalty factor for T&D network, e.g. https://www.mdpi.com/2071-1050/12/3/777
start_year (int) –
end_year (int) –
capacity_factor (float or pandas.Series) –
grid_penalty_ratio (float or pandas.Series) –
fuel_cost (float or pandas.Series) –
- Return type:
lcoe or discounted investment cost
- classmethod set_default_values(base_year, start_year, end_year, discount_rate, hv_line_type=69, hv_line_cost=53000, mv_line_type=33, mv_line_amperage_limit=8.0, mv_line_cost=7000, lv_line_type=0.24, lv_line_cost=4250, lv_line_max_length=0.5, service_transf_type=50, service_transf_cost=4250, max_nodes_per_serv_trans=300, mv_lv_sub_station_type=400, mv_lv_sub_station_cost=10000, mv_mv_sub_station_cost=10000, hv_lv_sub_station_type=1000, hv_lv_sub_station_cost=25000, hv_mv_sub_station_cost=25000, power_factor=0.9, load_moment=9643)[source]
Initialises the class with parameter values common to all Technologies
- td_network_cost(people, new_connections, prev_code, total_energy_per_cell, energy_per_cell, num_people_per_hh, grid_cell_area, additional_mv_line_length=0, additional_transformer=0, productive_nodes=0, elec_loop=0, penalty=1)[source]
Calculates all the transmission and distribution network components
- Parameters:
people (float) – Number of people in settlement
new_connections (float) – Number of new people in settlement to connect
prev_code (int) – Code representation of previous supply technology in settlement
total_energy_per_cell (float) – Total annual energy demand in cell, including already met demand
energy_per_cell (float) – Annual energy demand in cell, excluding already met demand
num_people_per_hh (float) – Number of people per household in settlement
grid_cell_area (float) – Area of settlement (km2)
additional_mv_line_length (float) – Distance to connect the settlement
additional_transformer (int) – If a transformer is needed on other end to connect to HV line
productive_nodes (int) – Additional connections (schools, health facilities, shops)
elec_loop (int) – Round of extension in grid extension algorithm
penalty (float) – Cost penalty factor for T&D network, e.g. https://www.mdpi.com/2071-1050/12/3/777
- transmission_network(peak_load, additional_mv_line_length=0, additional_transformer=0, mv_distribution=False)[source]
This method calculates the required components for connecting the settlement Settlements can be connected to grid or a hydropower source This includes potentially HV lines, MV lines and substations
- Parameters:
peak_load (float) – Peak load in the settlement (kW)
additional_mv_line_length (float) – Distance to connect the settlement
additional_transformer (int) – If a transformer is needed on other end to connect to HV line
mv_distribution (bool) – True if distribution network in settlement contains MV lines
Notes
Based on: https://www.mdpi.com/1996-1073/12/7/1395
onsset.runner module
onsset.specs module
Columns in the specs file must match these exactly
Module contents
The onsset package contains the following modules:
onsset.py : main functions of the model
runner.py : runner is used to calibrate inputs and specify scenario runs