optigob
Submodules
Attributes
Classes
Central interface for retrieving, aggregating, and analyzing all model outputs in the FORESIGHT system. |
|
InputHelper class for querying and displaying valid input parameter combinations for Optigob scenarios. |
Functions
|
Configure logging for optigob with sensible defaults. |
|
Get a logger instance for optigob. |
Package Contents
- optigob.__version__
- class optigob.Optigob(optigob_data_manager)
Central interface for retrieving, aggregating, and analyzing all model outputs in the FORESIGHT system.
The Optigob class provides a unified API for accessing emissions, land area, protein, bioenergy, harvested wood products, and substitution impacts for both baseline and scenario cases. It wraps all major model outputs, including sectoral and total values for CO2e, CO2, CH4, N2O, land area (aggregated/disaggregated/HNV), protein, bioenergy, harvested wood products, and substitution impacts. All results can be returned as dictionaries or tidy Pandas DataFrames for further analysis and reporting.
- Parameters:
optigob_data_manager – An instance of the data manager class, typically OptiGobDataManager, providing access to all model data and configuration.
- data_manager_class
- baseline_emission
- emission_budget
- land_area_budget
- econ_output
- split_gas
- get_livestock_co2e_emission_budget()
Retrieve the total livestock CO2e emissions (kt) budget available for the scenario.
- Returns:
Total livestock CO2e emissions budget in kilotons.
- Return type:
float
- get_livestock_split_gas_ch4_emission_budget()
Retrieve the total livestock split gas CH4 emissions (kt) budget available for the scenario.
- Returns:
Total livestock split gas CH4 emissions budget in kilotons.
- Return type:
float
- Raises:
ValueError – If split gas is not included in the model configuration.
- total_emission_co2e()
Return the total scenario CO2e emissions (kt) for all sectors combined.
- Returns:
Total scenario CO2e emissions in kilotons.
- Return type:
float
- check_net_zero_status()
Check if the model is set to net zero, using either the split gas or net zero budget as appropriate.
- Returns:
True if the model is set to net zero (or split gas net zero), False otherwise. None if not applicable.
- Return type:
bool or None
- get_baseline_co2e_emissions_by_sector()
Retrieve baseline CO2e emissions by sector.
- Returns:
Sectors as keys and baseline CO2e emissions (kt) as values.
- Return type:
dict
- get_baseline_ch4_emissions_by_sector()
Retrieve baseline CH4 emissions by sector.
- Returns:
Sectors as keys and baseline CH4 emissions (kt) as values.
- Return type:
dict
- get_baseline_n2o_emissions_by_sector()
Retrieve baseline N2O emissions by sector.
- Returns:
Sectors as keys and baseline N2O emissions (kt) as values.
- Return type:
dict
- get_baseline_co2_emissions_by_sector()
Retrieve baseline CO2 emissions by sector.
- Returns:
Sectors as keys and baseline CO2 emissions (kt) as values.
- Return type:
dict
- get_baseline_co2e_emissions_total()
Retrieve total baseline CO2e emissions.
- Returns:
Total baseline CO2e emissions in kilotons.
- Return type:
float
- get_baseline_co2_emissions_total()
Retrieve total baseline CO2 emissions.
- Returns:
Total baseline CO2 emissions in kilotons.
- Return type:
float
- get_baseline_ch4_emissions_total()
Retrieve total baseline CH4 emissions.
- Returns:
Total baseline CH4 emissions in kilotons.
- Return type:
float
- get_baseline_n2o_emissions_total()
Retrieve total baseline N2O emissions.
- Returns:
Total baseline N2O emissions in kilotons.
- Return type:
float
- get_scenario_co2e_emissions_by_sector()
Retrieve scenario CO2e emissions by sector.
- Returns:
Sectors as keys and scenario CO2e emissions (kt) as values.
- Return type:
dict
- get_scenario_ch4_emissions_by_sector()
Retrieve scenario CH4 emissions by sector.
- Returns:
Sectors as keys and scenario CH4 emissions (kt) as values.
- Return type:
dict
- get_scenario_n2o_emissions_by_sector()
Retrieve scenario N2O emissions by sector.
- Returns:
Sectors as keys and scenario N2O emissions (kt) as values.
- Return type:
dict
- get_scenario_co2_emissions_by_sector()
Retrieve scenario CO2 emissions by sector.
- Returns:
Sectors as keys and scenario CO2 emissions (kt) as values.
- Return type:
dict
- get_total_emissions_co2e_by_sector()
Retrieve total CO2e emissions by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector emissions as values.
- Return type:
dict
- get_total_emissions_ch4_by_sector()
Retrieve total CH4 emissions by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector emissions as values.
- Return type:
dict
- get_total_emissions_n2o_by_sector()
Retrieve total N2O emissions by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector emissions as values.
- Return type:
dict
- get_total_emissions_co2_by_sector()
Retrieve total CO2 emissions by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector emissions as values.
- Return type:
dict
- get_total_emissions_co2e_by_sector_df()
Return total CO2e emissions as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_aggregated_total_land_area_by_sector()
Retrieve aggregated land area by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector land areas as values.
- Return type:
dict
- get_aggregated_total_land_area_by_sector_df()
Return aggregated land area as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_disaggregated_total_land_area_by_sector()
Retrieve disaggregated land area by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of disaggregated sector land areas as values.
- Return type:
dict
- get_disaggregated_total_land_area_by_sector_df()
Return disaggregated land area as a tidy DataFrame with disaggregated sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with disaggregated sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_total_protein_by_sector()
Retrieve total protein by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of sector protein as values.
- Return type:
dict
- get_total_protein_by_sector_df()
Return total protein as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_total_hnv_land_area_by_sector()
Retrieve total HNV (High Nature Value) land area by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of HNV land areas as values.
- Return type:
dict
- get_total_hnv_land_area_by_sector_df()
Return total HNV land area as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_bioenergy_by_sector()
Retrieve bioenergy area by sector for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of bioenergy areas as values.
- Return type:
dict
- get_bioenergy_by_sector_df()
Return bioenergy area as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_hwp_volume()
Retrieve the volume of harvested wood products (in cubic meters) for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and HWP volumes as values.
- Return type:
dict
- get_hwp_volume_df()
Return the harvested wood products (HWP) volume as a tidy DataFrame with ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_substitution_emission_by_sector_co2e()
Retrieve substitution emissions by sector for CO2e.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of substitution emissions as values.
- Return type:
dict
- get_substitution_emission_by_sector_co2e_df()
Return substitution emissions for CO2e as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_substitution_emission_by_sector_co2()
Retrieve substitution emissions by sector for CO2.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of substitution emissions as values.
- Return type:
dict
- get_substitution_emission_by_sector_co2_df()
Return substitution emissions for CO2 as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_substitution_emission_by_sector_ch4()
Retrieve substitution emissions by sector for CH4.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of substitution emissions as values.
- Return type:
dict
- get_substitution_emission_by_sector_ch4_df()
Return substitution emissions for CH4 as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_substitution_emission_by_sector_n2o()
Retrieve substitution emissions by sector for N2O.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of substitution emissions as values.
- Return type:
dict
- get_substitution_emission_by_sector_n2o_df()
Return substitution emissions for N2O as a tidy DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with sectors as rows and ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- get_livestock_population()
Retrieve the livestock population in number of animals for both baseline and scenario.
- Returns:
Dictionary with ‘baseline’ and ‘scenario’ as keys and dictionaries of livestock populations as values.
- Return type:
dict
- get_livestock_population_df()
Return the livestock population as a tidy DataFrame with ‘baseline’ and ‘scenario’ as columns.
- Returns:
DataFrame with ‘baseline’ and ‘scenario’ as columns.
- Return type:
pd.DataFrame
- class optigob.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
- class optigob.InputHelper
InputHelper class for querying and displaying valid input parameter combinations for Optigob scenarios. Provides convenience methods to print, filter, and retrieve input combos as DataFrames or dicts.
- query
- get_combos_dict()
Returns all valid input combinations as a dictionary. :returns: {input_type: [combo_dict, …], …} :rtype: dict
- get_combos_df()
Returns all valid input combinations as a pandas DataFrame. :returns: DataFrame with all input combinations and input_type column. :rtype: pd.DataFrame
- print_all_combos()
Prints all valid input combinations to the screen, grouped by input type.
- filter_combos(input_type=None, **kwargs)
Filters input combinations by input_type and/or parameter values. :param input_type: Filter by input type (e.g., ‘forest’, ‘organic_soil’). :type input_type: str, optional :param **kwargs: Additional key-value pairs to filter on (e.g., broadleaf_frac=0.5).
- Returns:
Filtered DataFrame of input combinations.
- Return type:
pd.DataFrame
- print_readable_combos(max_rows_per_type=10)
Prints a nicely formatted, readable summary of valid input combinations, grouped by input type. Limits rows per input type for readability. :param max_rows_per_type: Maximum number of combos to show per input type. :type max_rows_per_type: int
- optigob.configure_logging(level=logging.INFO, log_to_file=None, format_style='detailed')
Configure logging for optigob with sensible defaults.
This is a convenience function for common logging setups. Users can call this at the start of their script to control what optigob logs.
- Parameters:
level (int) – Minimum logging level to display. Options: - logging.DEBUG (most verbose - shows everything) - logging.INFO (normal - shows general info) - logging.WARNING (quiet - only warnings and errors) - logging.ERROR (very quiet - only errors) Default: logging.INFO
log_to_file (str, optional) – If provided, logs will be written to this file in addition to the console. If None, logs only go to console. Default: None
format_style (str) – How detailed the log messages should be. Options: - “simple”: Just the message - “detailed”: Time, module name, level, and message Default: “detailed”
- Returns:
None
Example
>>> # Show all INFO and above messages >>> configure_logging(level=logging.INFO)
>>> # Only show warnings and errors >>> configure_logging(level=logging.WARNING)
>>> # Log everything to a file >>> configure_logging(level=logging.DEBUG, log_to_file="optigob.log")
Note
This function configures the root ‘optigob’ logger. If you need more advanced control, use Python’s logging module directly.
- optigob.get_logger(name=None)
Get a logger instance for optigob.
This function returns a logger that is part of the ‘optigob’ logging hierarchy. All optigob loggers can be controlled together by configuring the root ‘optigob’ logger.
- Parameters:
name (str, optional) – Name of the module/component requesting the logger. If provided, logger will be named “optigob.{name}”. If None, returns the root “optigob” logger.
- Returns:
A logger instance that can be used to log messages.
- Return type:
logging.Logger
Example
>>> logger = get_logger("data_manager") >>> logger.info("Loading data...") >>> logger.warning("Parameter validation issue detected")
Note
By default, if no configuration has been done, Python’s logging will only show WARNING level and above. Call configure_logging() to see INFO and DEBUG.