onstove.OnStove#
- class onstove.OnStove(project_crs: pyproj.CRS | int | None = 3395, cell_size: float = (1000, 1000), output_directory: str = '.')[source]#
The
OnStove
class is used to perform a geospatial cost-benefit analysis on clean cooking access.OnStove determines the net-benefits of cooking with different stoves across an area with regards to capital, fuel, and operation and maintenance costs, as well as benefits from reduced morbidity, reduced mortality, time saved and emissions avoided. The model identifies the stove that can provide cooking in each settlement achieving the highest net-benefit.
Note
The
OnStove
class inherits all functionalities from theDataProcessor
class.- Parameters:
- project_crs: pyproj.CRS or int, optional
See the
DataProcessor
class for details.- cell_size: float, optional
See the
DataProcessor
class for details.- output_directory: str, default ‘output’
A folder path where to save the output datasets.
- Attributes:
- gdf: gpd.GeoDataFrame
GeoDataFrame containing the georeferenced information for every populated square kilometer of the study area. This attribute gets created when calling the
population_to_dataframe()
method.- rows: np.ndarray
Array containing the row indexes of each row of the
gdf
in relation to the spatial grid of the data. Indicates the horizontal position of each data point.- cols: np.ndarray
Array containing the column indexes of each row of the
gdf
in relation to spatial grid of the data. Indicates the vertical position of each data point.- specs: dict
Dictionary containing the socio-economic information of the study area. It gets created when reading the scenario file using the
read_scenario_data()
method.- techs: dict of dict
Dictionary containing the technology names and classes. It gets created when reading the technology file using the
read_tech_data()
method.- base_fuel: Technology
Technology
class containing information on the current technologies used in the study area. It gets created using information from thetechs
and when theset_base_fuel()
method gets called.- energy_per_meal: float
Average energy required for cooking a standard meal (MJ).
- gwp: dict
Dictionary containing values of Global Warming Potential (GWP) of relevant pollutants. Default values are for 100 year potential:
{'co2': 1, 'ch4': 25, 'n2o': 298, 'co': 2, 'bc': 900, 'oc': -46}
.- clean_cooking_access_u: float
Percentage of clean cooking acces in urban settlements.
- clean_cooking_access_r: float
Percentage of clean cooking acces in rural settlements.
Methods
add_layer
(path, layer_type[, category, ...])Adds a new layer (type VectorLayer or RasterLayer) to the DataProcessor class
add_mask_layer
(path[, category, name, ...])Adds a vector layer to self.mask_layer.
align_layers
([datasets, save_layers])Ensures that the coordinate system and resolution of the raster is the same as the base layer
Calibrates the spatial population in each cell according to the user defined population in the start year (
Population_start_year
in thespecs
dictionary).calibrate_urban_rural_split
(GHS_path)Calibrates the urban rural split using spatial data from the GHS SMOD dataset.
create_layer
(variable[, name, labels, cmap, ...])Creates a
RasterLayer
from a column of the main GeoDataFrame (gdf
).Calculates a binary variable that defines which settlements are at least partially electrified.
distance_to_electricity
([hv_lines, ...])Calculates the distance to electricity infrastructure.
extract_emissions_costs_saved
([column])Extracts the economic value of the emissions by adopt each stove type across the study area.
extract_fuel_costs
([column])Extracts the total fuel costs needed in order to adopt each stove type across the study area.
extract_health_costs_saved
([column])Extracts the health costs avoided from adopting each stove type selected across the study area.
extract_investment_costs
([column])Extracts the total investment costs needed in order to adopt each stove type across the study area.
extract_lives_saved
([column])Extracts the number of deaths avoided from adopting each stove type selected across the study area and saves the data in the
deaths_avoided
column of thegdf
.extract_om_costs
([column])Extracts the total operation and maintenance costs needed in order to adopt each stove type across the study area.
extract_opportunity_cost
([column])Extracts the opportunity cost of adopting each stove type selected across the study area.
extract_reduced_emissions
([column])Extracts the reduced emissions achieved by adopting each stove type selected across the study area.
extract_salvage
([column])Extracts the total salvage costs in order to adopt each stove type across the study area.
extract_time_saved
([column])Extracts the total time saved from adopting each stove type selected across the study area.
extract_wealth_index
(wealth_index[, ...])Extracts the relative wealth index to a column called relative wealth in the
gdf
.Calibrates the electrified population within each cell.
get_clean_cooking_access
(base_fuels)Calculates the clean cooking access in rural and urban settlements.
get_distance_rasters
([datasets, save_layers])Calls the .distance_raster method of all the layers entered.
Calculates the value of time based on the minimum wage ($/h) and a spatial representation of wealth.
mask_layers
([datasets, crop, save_layers])Uses the mask layer in
self.mask_layer
to mask layers to its boundaries.maximum_net_benefit
(techs[, restriction])Extracts the technology or technology combinations producing the highest net-benefit in each cell.
normalize
(column[, inverse])Uses the MinMax method to normalize the data from a column of the
gdf
GeoDataFrame.normalize_rasters
([datasets, buffer, ...])Calls the .normalize method of all the layers entered.
Calculates the number of households withing each cell based on their urban/rural classification and a defined household size.
plot
(variable[, metric, labels, cmap, ...])Plots a map from a desired column
variable
from thegdf
.plot_costs_benefits
([variable, labels, ...])Displays a stacked bar plot with the aggregated total costs and benefits for the technologies with the highest net-benefits over the study area.
plot_distribution
([type, fill, groupby, ...])Displays a distribution plot of the stove mix in relation to a variable.
plot_split
([labels, cmap, x_variable, fill, ...])Displays a bar plot with the population or households share using the technologies with highest net-benefits over the study area.
population_to_dataframe
([layer])Takes a population RasterLayer as input and extracts the populated points to the main GeoDataFrame saved in the
gdf
attribute.raster_to_dataframe
(layer[, name, method, ...])Takes a
RasterLayer
and a method (sample
orread
) and extracts the values from the raster layer to the main GeoDataFrame (gdf
).read_model
(path)Reads a model from a pickle
read_scenario_data
(path_to_config[, delimiter])Reads the scenario data into a dictionary.
read_tech_data
(path_to_config[, delimiter])Reads the technology data from a csv file into a dictionary of dictionaries.
reproject_layers
([datasets, save_layers])Reprojects all layers entered.
run
([technologies, restriction])Runs the model using the defined
technologies
as options to cook with.save_datasets
([datasets])Saves layers.
set_base_fuel
([techs])Defines the base fuel properties according to the technologies currently used in the study area.
set_postgres
(dbname, user, password)Wrapper function to set a connection to a PostgreSQL database using the psycopg2.connect class.
summary
([total, pretty, labels, variable, ...])Creates a summary of the results grouped by the selected categorical variable.
to_csv
(name)Saves the main GeoDataFrame
gdf
as a.csv
file into theoutput_directory
.to_image
(variable, name[, metric, labels, ...])Saves a map from a desired column
variable
from thegdf
into an image file.to_pickle
(name)Saves the model as a pickle.
to_raster
(variable[, labels, cmap, metric, ...])Creates a RasterLayer and saves it as a
.tif
file and a.clr
colormap.