optigob.resource_manager.optigob_data_manager
This module provides the OptiGobDataManager class, which is responsible for managing and retrieving various data scalers related to livestock emissions, forest management, and other land use sectors. The class interacts with a database to load and cache scaler values, and provides methods to retrieve these values based on specific parameters.
- Classes:
OptiGobDataManager: Manages and retrieves data scalers for various sectors.
- optigob.resource_manager.optigob_data_manager.get_solver_name()
Retrieves the solver type from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_ha_to_kha()
Retrieves the conversion factor from hectares to kilohectares.
- optigob.resource_manager.optigob_data_manager.get_kha_to_ha()
Retrieves the conversion factor from square kilohectares to hectares.
- optigob.resource_manager.optigob_data_manager.get_AR_gwp100_values()
Retrieves the GWP values for each gas based on the AR value.
- optigob.resource_manager.optigob_data_manager.get_emission_sectors()
Retrieves the emission sectors.
- optigob.resource_manager.optigob_data_manager.get_livestock_emission_scaler()
Retrieves the scaler value for a given year, system, gas, scenario, and abatement.
- optigob.resource_manager.optigob_data_manager.get_livestock_area_scaler()
Retrieves the scaler value for a given year, system, scenario, and abatement.
- optigob.resource_manager.optigob_data_manager.get_livestock_protein_scaler()
Retrieves the scaler value for a given year, system, item, scenario, and abatement.
- optigob.resource_manager.optigob_data_manager.get_static_livestock_emission_scaler()
Retrieves the static scaler value for a given year, system, gas, and abatement.
- optigob.resource_manager.optigob_data_manager.get_static_livestock_area_scaler()
Retrieves the static scaler value for a given year, system, and abatement.
- optigob.resource_manager.optigob_data_manager.get_static_livestock_protein_scaler()
Retrieves the static scaler value for a given year, system, and abatement.
- optigob.resource_manager.optigob_data_manager.get_forest_scaler()
Retrieves the scaler value for a given year and forest management parameters.
- optigob.resource_manager.optigob_data_manager.get_static_forest_scaler()
Retrieves the static scaler value for a given year and harvest intensity.
- optigob.resource_manager.optigob_data_manager.get_ccs_scaler()
Retrieves the CCS scaler value for a given year and forest management parameters.
- optigob.resource_manager.optigob_data_manager.get_hwp_scaler()
Retrieves the HWP scaler value for a given year and forest management parameters.
- optigob.resource_manager.optigob_data_manager.get_substitution_scaler()
Retrieves the substitution scaler value for a given year and forest management parameters.
- optigob.resource_manager.optigob_data_manager.get_organic_soil_emission_scaler()
Retrieves the organic soil emission scaler value for a given year and land management parameters.
- optigob.resource_manager.optigob_data_manager.get_organic_soil_area_scaler()
Retrieves the organic soil area scaler value for a given year and land management parameters.
- optigob.resource_manager.optigob_data_manager.get_ad_area_scaler()
Retrieves the AD area scaler value for a given year and land management parameters.
- optigob.resource_manager.optigob_data_manager.get_ad_emission_scaler()
Retrieves the AD emission scaler value for a given year.
- optigob.resource_manager.optigob_data_manager.get_crop_scaler()
Retrieves the crop scaler value for a given year, gas, and abatement.
- optigob.resource_manager.optigob_data_manager.get_baseline_year()
Retrieves the baseline year from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_target_year()
Retrieves the target year from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_abatement_scenario()
Retrieves the abatement scenario from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_dairy_beef_ratio()
Retrieves the dairy to beef ratio from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_forest_harvest_intensity()
Retrieves the forest harvest intensity from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_afforestation_rate_kha_per_year()
Retrieves the afforestation rate in kha per year from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_broadleaf_fraction()
Retrieves the broadleaf fraction from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_organic_soil_fraction_forest()
Retrieves the organic soil fraction for forest from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_beccs_included()
Retrieves whether BECCS is included from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_wetland_restored_fraction()
Retrieves the wetland restored fraction from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_organic_soil_under_grass_fraction()
Retrieves the organic soil under grass fraction from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_biomethane_included()
Retrieves whether biomethane is included from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_abatement_type()
Retrieves the abatement type from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_AR()
Retrieves the AR value from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_split_gas()
Retrieves whether split gas is used from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_split_gas_fraction()
Retrieves the split gas fraction from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_baseline_dairy_population()
Retrieves the baseline dairy population from the SIP input file.
- optigob.resource_manager.optigob_data_manager.get_baseline_beef_population()
Retrieves the baseline beef population from the SIP input file.
Attributes
Classes
Module Contents
- optigob.resource_manager.optigob_data_manager.logger
- class optigob.resource_manager.optigob_data_manager.OptiGobDataManager(sip)
- db_manager
- solver_name = None
- _livestock_emission_scalers = None
- _livestock_area_scalers = None
- _livestock_protein_scalers = None
- _forest_scalers = None
- _static_forest_scalers = None
- _wood_ccs_scalers = None
- _hwp_scalers = None
- _substitution_scalers = None
- _organic_soil_emission_scalers = None
- _organic_soil_area_scalers = None
- _ad_area_scalers = None
- _ad_emission_scalers = None
- _crop_scalers = None
- _static_livestock_emission_scalers = None
- _static_livestock_area_scalers = None
- _static_livestock_protein_scalers = None
- _protein_crop_emission_scalers = None
- _protein_crop_protein_scalers = None
- _protein_content_scalers = None
- _willow_bioenergy_scalers = None
- _ha_to_kha = 0.001
- _kha_to_ha = 1000.0
- _AR_VALUES
- emission_sectors = ['agriculture', 'existing_forest', 'afforestation', 'hwp', 'other_land_use', 'ad', 'beccs']
- _get_available_solvers()
Retrieves the list of available solvers from the Pyomo SolverFactory.
- Returns:
A list of available solver names.
- Return type:
list
- _validate_input_parameters()
Validate that input parameters are consistent and within valid ranges.
This method performs two types of validation: 1. Parameter consistency checks (e.g., split_gas and split_gas_frac) 2. Database combination validation (e.g., forest, organic soil, abatement parameters)
For database combination validation, the method checks if the provided parameter combinations exist in the underlying database. Not all parameter combinations are valid - the database contains only specific combinations that have been modeled.
- Use the InputHelper class to explore valid combinations:
from optigob.input_helper import InputHelper helper = InputHelper() helper.print_all_combos() # View all valid combinations
- Raises:
ValueError – If parameters are invalid, inconsistent, or form an invalid combination not present in the database.
- Warns:
UserWarning – If parameters are confusing but don’t affect calculations.
- _validate_forest_parameters()
Validate forest parameter combinations against database.
Checks if the provided forest parameters form a valid combination that exists in the database. Only validates if all four forest parameters are provided.
- Raises:
ValueError – If the forest parameter combination is invalid.
- _validate_organic_soil_parameters()
Validate organic soil parameter combinations against database.
Checks if the provided organic soil parameters form a valid combination that exists in the database. Only validates if both organic soil parameters are provided.
- Raises:
ValueError – If the organic soil parameter combination is invalid.
- _validate_abatement_productivity_parameters()
Validate abatement and productivity parameter combinations against database.
Checks if the provided abatement_type and abatement_scenario form a valid combination that exists in the database. Only validates if both parameters are provided.
- Raises:
ValueError – If the abatement/productivity parameter combination is invalid.
- get_solver_name()
Retrieves the solver name from the SIP input parameters.
- Returns:
The solver name specified in the SIP input parameters.
- Return type:
str
- Raises:
ValueError – If the solver_name parameter is missing from the SIP input parameters.
- get_ha_to_kha()
Retrieves the conversion factor from hectares to square kilometers.
- Returns:
The conversion factor.
- Return type:
float
- get_kha_to_ha()
Retrieves the conversion factor from square kilometers to hectares.
- Returns:
The conversion factor.
- Return type:
float
- get_AR_gwp100_values(gas)
Retrieves the GWP values for each gas based on the AR value.
- Parameters:
gas (str) – The gas identifier (e.g., “CO2”, “CH4”, “N2O”).
- Returns:
The GWP values for each gas.
- Return type:
dict
- get_emission_sectors()
Retrieves the emission sectors.
- Returns:
The emission sectors.
- Return type:
list
- _load_livestock_emission_scalers()
Loads and caches the livestock scalers from the database.
- _load_static_livestock_emission_scalers()
Loads and caches the static livestock scalers from the database.
- _load_livestock_area_scalers()
Loads and caches the livestock area scalers from the database.
- _load_static_livestock_area_scalers()
Loads and caches the static livestock area scalers from the database.
- _load_livestock_protein_scalers()
Loads and caches the livestock protein scalers from the database.
- _load_static_livestock_protein_scalers()
Loads and caches the static livestock protein scalers from the database.
- _load_forest_scalers()
Loads and caches the forest scalers from the database.
- _load_static_forest_scalers()
Loads and caches the static forest scalers from the database.
- _load_wood_ccs_scalers()
Loads and caches the CCS scalers from the database.
- _load_hwp_scalers()
Loads and caches the HWP scalers from the database.
- _load_substitution_scalers()
Loads and caches the substitution scalers from the database.
- _load_organic_soil_emission_scalers()
Loads and caches the organic soil emission scalers from the database.
- _load_organic_soil_area_scalers()
Loads and caches the organic soil area scalers from the database.
- _load_ad_area_scalers()
Loads and caches the AD area scalers from the database.
- _load_ad_emission_scalers()
Loads and caches the AD emission scalers from the database.
- _load_crop_scalers()
Loads and caches the crop scalers from the database.
- _load_protein_crop_emission_scalers()
Loads and caches the protein crop emission scalers from the database.
- _load_protein_crop_protein_scalers()
Loads and caches the protein crop protein scalers from the database.
- _load_protein_content_scalers()
Loads and caches the protein content scalers from the database.
- _load_willow_bioenergy_scalers()
Loads and caches the willow bioenergy scalers from the database.
- get_livestock_emission_scaler(year, system, gas, scenario, abatement)
Retrieves the scaler value for a given year, system, gas, and scenario.
- Parameters:
year (int) – The year of interest.
system (str) – The system identifier.
gas (str) – The gas identifier.
scenario (int) – The scenario identifier.
abatement (int) – The abatement identifier.
- Returns:
The scaler value and additional information.
- Return type:
dict
- Raises:
ValueError – If no matching row is found.
- get_livestock_area_scaler(year, system, scenario, abatement)
Retrieves the scaler value for a given year, system, and scenario.
- Parameters:
year (int) – The year of interest.
system (str or list) – The system identifier(s).
scenario (int) – The scenario identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_livestock_protein_scaler(year, system, item, scenario, abatement)
Retrieves the scaler value for a given year, system, and scenario.
- Parameters:
year (int) – The year of interest.
system (str) – The system identifier.
item (str) – The item identifier.
scenario (int) – The scenario identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_static_livestock_emission_scaler(year, system, gas, abatement)
Retrieves the static scaler value for a given year, system, gas, and abatement.
- Parameters:
year (int) – The year of interest.
system (str) – The system identifier.
gas (str) – The gas identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_static_livestock_area_scaler(year, system, abatement)
Retrieves the static scaler value for a given year, system, and abatement.
- Parameters:
year (int) – The year of interest.
system (str) – The system identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_static_livestock_protein_scaler(year, system, item, abatement)
Retrieves the static scaler value for a given year, system, and abatement.
- Parameters:
year (int) – The year of interest.
system (str) – The system identifier.
item (str) – The item identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_forest_scaler(target_year, affor_rate, broadleaf_frac, organic_soil_frac, harvest)
Retrieves the scaler value for a given year and forest management parameters.
- Parameters:
target_year (int) – The year of interest.
affor_rate (float) – The afforestation rate in kha per year.
broadleaf_frac (float) – The fraction of broadleaf trees.
organic_soil_frac (float) – The fraction of organic soil.
harvest (float) – The forest harvest intensity.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_static_forest_scaler(target_year, harvest)
Retrieves the static scaler value for a given year and harvest intensity.
- Parameters:
target_year (int) – The year of interest.
harvest (float) – The forest harvest intensity.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_wood_ccs_scaler(target_year, affor_rate, broadleaf_frac, organic_soil_frac, harvest)
Retrieves the CCS scaler value for a given year and forest management parameters.
- Parameters:
target_year (int) – The year of interest.
affor_rate (float) – The afforestation rate in kha per year.
broadleaf_frac (float) – The fraction of broadleaf trees.
organic_soil_frac (float) – The fraction of organic soil.
harvest (float) – The forest harvest intensity.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_hwp_scaler(target_year, affor_rate, broadleaf_frac, organic_soil_frac, harvest)
Retrieves the HWP scaler value for a given year and forest management parameters.
- Parameters:
target_year (int) – The year of interest.
affor_rate (float) – The afforestation rate in kha per year.
broadleaf_frac (float) – The fraction of broadleaf trees.
organic_soil_frac (float) – The fraction of organic soil.
harvest (float) – The forest harvest intensity.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_substitution_scaler(target_year, affor_rate, broadleaf_frac, organic_soil_frac, harvest)
Retrieves the substitution scaler value for a given year and forest management parameters.
- Parameters:
target_year (int) – The year of interest.
affor_rate (float) – The afforestation rate in kha per year.
broadleaf_frac (float) – The fraction of broadleaf trees.
organic_soil_frac (float) – The fraction of organic soil.
harvest (float) – The forest harvest intensity.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_organic_soil_emission_scaler(target_year, wetland_restored_frac, organic_soil_under_grass_frac)
Retrieves the organic soil emission scaler value for a given year and land management parameters.
- Parameters:
target_year (int) – The year of interest.
wetland_restored_frac (float) – The fraction of wetland restored.
organic_soil_under_grass_frac (float) – The fraction of organic soil under grass.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_organic_soil_area_scaler(target_year, wetland_restored_frac, organic_soil_under_grass_frac)
Retrieves the organic soil area scaler value for a given year and land management parameters.
- Parameters:
target_year (int) – The year of interest.
wetland_restored_frac (float) – The fraction of wetland restored.
organic_soil_under_grass_frac (float) – The fraction of organic soil under grass.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_ad_area_scaler(target_year)
Retrieves the AD area scaler value for a given year.
- Parameters:
target_year (int) – The year of interest.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_ad_emission_scaler(target_year)
Retrieves the AD emission scaler value for a given year.
- Parameters:
target_year (int) – The year of interest.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_crop_scaler(year, gas, abatement)
Retrieves the crop scaler value for a given year, gas, and abatement.
- Parameters:
year (int) – The year of interest.
gas (str) – The gas identifier.
abatement (int) – The abatement identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_protein_crop_emission_scaler(year, ghg, abatement)
Retrieves the protein crop emission scaler value for a given year, crop, gas, and abatement.
- get_protein_crop_protein_scaler(year, abatement)
Retrieves the protein crop protein scaler value for a given year, crop, and abatement.
- get_protein_content_scaler(type)
Retrieves the protein content scaler value.
- Returns:
The DataFrame containing the protein content scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_willow_bioenergy_scaler(year, type, ghg)
Retrieves the willow bioenergy scaler value for a given year, type, and gas.
- Parameters:
year (int) – The year of interest.
type (str) – The type of willow bioenergy.
ghg (str) – The greenhouse gas identifier.
- Returns:
The filtered DataFrame containing the scaler values.
- Return type:
DataFrame
- Raises:
ValueError – If no matching row is found.
- get_baseline_year()
Retrieves the baseline year from the SIP input file.
- Returns:
The baseline year.
- Return type:
int
- get_target_year()
Retrieves the target year from the SIP input file.
- Returns:
The target year.
- Return type:
int
- get_abatement_scenario()
Retrieves the abatement scenario from the SIP input file.
- Returns:
The abatement scenario.
- Return type:
str
- get_livestock_ratio_type()
Retrieves the livestock ratio type from the SIP input file.
- Returns:
The livestock ratio type.
- Return type:
str
- get_livestock_ratio_value()
Retrieves the livestock ratio from the SIP input file.
- Returns:
The livestock ratio.
- Return type:
float
- get_forest_harvest_intensity()
Retrieves the forest harvest intensity from the SIP input file.
- Returns:
The forest harvest intensity.
- Return type:
float
- get_afforestation_rate_kha_per_year()
Retrieves the afforestation rate in kha per year from the SIP input file.
- Returns:
The afforestation rate in kha per year.
- Return type:
float
- get_broadleaf_fraction()
Retrieves the broadleaf fraction from the SIP input file.
- Returns:
The broadleaf fraction.
- Return type:
float
- get_organic_soil_fraction_forest()
Retrieves the organic soil fraction for forest from the SIP input file.
- Returns:
The organic soil fraction for forest.
- Return type:
float
- get_beccs_included()
Retrieves whether BECCS is included from the SIP input file.
- Returns:
True if BECCS is included, False otherwise.
- Return type:
bool
- get_wetland_restored_fraction()
Retrieves the wetland restored fraction from the SIP input file.
- Returns:
The wetland restored fraction.
- Return type:
float
- get_organic_soil_under_grass_fraction()
Retrieves the organic soil under grass fraction from the SIP input file.
- Returns:
The organic soil under grass fraction.
- Return type:
float
- get_biomethane_included()
Retrieves whether biomethane is included from the SIP input file.
- Returns:
True if biomethane is included, False otherwise.
- Return type:
bool
- get_abatement_type()
Retrieves the abatement type from the SIP input file.
- Returns:
The abatement type.
- Return type:
str
- get_AR()
Retrieves the AR value from the SIP input file.
- Returns:
The AR value.
- Return type:
str
- get_split_gas()
Retrieves whether split gas is used from the SIP input file.
- Returns:
True if split gas is used, False otherwise.
- Return type:
bool
- get_split_gas_fraction()
Retrieves the split gas fraction from the SIP input file.
- Returns:
The split gas fraction.
- Return type:
float
- get_protein_crop_included()
Retrieves whether protein crop is included from the SIP input file.
- Returns:
True if protein crop is included, False otherwise.
- Return type:
bool
- get_protein_crop_multiplier()
Retrieves the protein crop multiplier from the SIP input file.
- Returns:
The protein crop multiplier.
- Return type:
float
- get_beccs_willow_area_multiplier()
Retrieves the BECCS willow area multiplier from the SIP input file.
- Returns:
The BECCS willow area multiplier.
- Return type:
float
- get_pig_and_poultry_multiplier()
Retrieves the pig and poultry multiplier from the SIP input file.
- Returns:
The pig and poultry multiplier.
- Return type:
float
- get_baseline_dairy_population()
Retrieves the baseline dairy population from the SIP input file.
- Returns:
The baseline dairy population.
- Return type:
int
- get_baseline_beef_population()
Retrieves the baseline beef population from the SIP input file.
- Returns:
The baseline beef population.
- Return type:
int