Example usage

To use optigob in a project:

from optigob import Optigob
from optigob import OptiGobDataManager
from optigob import InputHelper

print("OptiGob Budget Model Input Combinations")

# Initialize the input helper
helper = InputHelper()
helper.print_all_combos()
OptiGob Budget Model Input Combinations

Input type: forest
{'affor_rate_kha-yr': 2, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 8, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 8, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'low'}
{'affor_rate_kha-yr': 8, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 8, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'low'}
{'affor_rate_kha-yr': 16, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'low'}
{'affor_rate_kha-yr': 16, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.0, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 16, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.0, 'forest_harvest_intensity': 'low'}
{'affor_rate_kha-yr': 25, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 25, 'broadleaf_frac': 0.5, 'organic_soil_frac': 0.15, 'forest_harvest_intensity': 'low'}
{'affor_rate_kha-yr': 25, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.0, 'forest_harvest_intensity': 'high'}
{'affor_rate_kha-yr': 25, 'broadleaf_frac': 0.3, 'organic_soil_frac': 0.0, 'forest_harvest_intensity': 'low'}

Input type: organic_soil
{'wetland_restored_frac': 0.5, 'organic_soil_under_grass_frac': 0.0}
{'wetland_restored_frac': 0.9, 'organic_soil_under_grass_frac': 0.5}
{'wetland_restored_frac': 0.9, 'organic_soil_under_grass_frac': 0.9}

Input type: abatement_and_productivity
{'abatement': 'baseline', 'scenario': 1}
{'abatement': 'baseline', 'scenario': 2}
{'abatement': 'baseline', 'scenario': 3}
{'abatement': 'macc', 'scenario': 4}
{'abatement': 'macc', 'scenario': 5}
{'abatement': 'macc', 'scenario': 6}
{'abatement': 'frontier', 'scenario': 7}
{'abatement': 'frontier', 'scenario': 8}
{'abatement': 'frontier', 'scenario': 9}
data = './data/sip.yaml'
# Initialize the data manager
data_manager = OptiGobDataManager(data)

# Create an instance of Optigob
optigob = Optigob(data_manager)
print("GHG Emissions by Sector")
print(optigob.get_total_emissions_co2e_by_sector())
print(optigob.get_total_emissions_co2e_by_sector_df())
GHG Emissions by Sector
{'baseline': {'agriculture': 21147.772800304, 'existing_forest': -2082.0, 'afforestation': 0, 'hwp': 0, 'other_land_use': 5947, 'ad': 0, 'beccs': 0}, 'scenario': {'agriculture': 12273.079795069938, 'existing_forest': 2057.0, 'afforestation': -4757.436304, 'hwp': -1198, 'other_land_use': 6546, 'ad': 141.1, 'beccs': -2315.2028127000003}}
                   baseline      scenario
agriculture      21147.7728  12273.079795
existing_forest  -2082.0000   2057.000000
afforestation        0.0000  -4757.436304
hwp                  0.0000  -1198.000000
other_land_use    5947.0000   6546.000000
ad                   0.0000    141.100000
beccs                0.0000  -2315.202813
print("Aggregated Total Land Area by Sector")
print(optigob.get_aggregated_total_land_area_by_sector())
print(optigob.get_aggregated_total_land_area_by_sector_df())
Aggregated Total Land Area by Sector
{'baseline': {'agriculture': 4225153.146096, 'afforested': 0, 'existing_forest': 773254, 'other_land_use': 1433000, 'ad': 0, 'protein_crops': 0, 'beccs_willow': 0}, 'scenario': {'agriculture': 2794622.2815562123, 'afforested': 368640, 'existing_forest': 781254, 'other_land_use': 1433000, 'ad': 130000.0, 'protein_crops': 0, 'beccs_willow': 150000.0}}
                     baseline      scenario
agriculture      4.225153e+06  2.794622e+06
afforested       0.000000e+00  3.686400e+05
existing_forest  7.732540e+05  7.812540e+05
other_land_use   1.433000e+06  1.433000e+06
ad               0.000000e+00  1.300000e+05
protein_crops    0.000000e+00  0.000000e+00
beccs_willow     0.000000e+00  1.500000e+05
print("Protein by Sector")
print(optigob.get_total_protein_by_sector())
print(optigob.get_total_protein_by_sector_df())
Protein by Sector
{'baseline': {'pig_and_poultry': 132000000.0, 'sheep': 14332176.614848224, 'beef': 155417070.62386402, 'milk': 297463320.00000006, 'protein_crops': 0}, 'scenario': {'pig_and_poultry': 158400000.0, 'sheep': 14332176.614848224, 'beef': 114726990.82573089, 'milk': 450223532.97514117, 'protein_crops': 0}}
                     baseline      scenario
pig_and_poultry  1.320000e+08  1.584000e+08
sheep            1.433218e+07  1.433218e+07
beef             1.554171e+08  1.147270e+08
milk             2.974633e+08  4.502235e+08
protein_crops    0.000000e+00  0.000000e+00
print("Area by Sector")
print(optigob.get_disaggregated_total_land_area_by_sector())
print(optigob.get_disaggregated_total_land_area_by_sector_df())
Area by Sector
{'baseline': {'dairy': 980841.4292544001, 'beef': 2066291.4368416, 'sheep': 828020.28, 'pig_and_poultry': 0.0, 'static_crops': 350000, 'protein_crops': 0, 'beccs_willow': 0, 'anaerobic_digestion': 0, 'managed forest': 773254, 'afforestation': 0, 'other_land_use': 1433000, 'available_area': 0}, 'scenario': {'dairy': 1082977.7200910388, 'beef': 765997.4414651733, 'sheep': 595647.12, 'pig_and_poultry': 0.0, 'static_crops': 350000.0, 'protein_crops': 0, 'beccs_willow': 150000.0, 'anaerobic_digestion': 130000.0, 'managed forest': 781254, 'afforestation': 368640, 'other_land_use': 1433000, 'available_area': 773890.8645397881}}
                         baseline      scenario
dairy                9.808414e+05  1.082978e+06
beef                 2.066291e+06  7.659974e+05
sheep                8.280203e+05  5.956471e+05
pig_and_poultry      0.000000e+00  0.000000e+00
static_crops         3.500000e+05  3.500000e+05
protein_crops        0.000000e+00  0.000000e+00
beccs_willow         0.000000e+00  1.500000e+05
anaerobic_digestion  0.000000e+00  1.300000e+05
managed forest       7.732540e+05  7.812540e+05
afforestation        0.000000e+00  3.686400e+05
other_land_use       1.433000e+06  1.433000e+06
available_area       0.000000e+00  7.738909e+05
print("High Nature Value (HNV) Land Area by Sector")
print(optigob.get_total_hnv_land_area_by_sector())
print(optigob.get_total_hnv_land_area_by_sector_df())
High Nature Value (HNV) Land Area by Sector
{'baseline': {'agriculture': 681876.1741560001, 'afforested': 0, 'existing_forest': 255174, 'wetland': 884000, 'rewetted_wetland': 85000, 'organic_soil': 85000, 'beccs': 0}, 'scenario': {'agriculture': 252779.15563495315, 'afforested': 110592.0, 'existing_forest': 257814, 'wetland': 884000, 'rewetted_wetland': 198000, 'organic_soil': 198000, 'beccs': 150000.0}}
                       baseline       scenario
agriculture       681876.174156  252779.155635
afforested             0.000000  110592.000000
existing_forest   255174.000000  257814.000000
wetland           884000.000000  884000.000000
rewetted_wetland   85000.000000  198000.000000
organic_soil       85000.000000  198000.000000
beccs                  0.000000  150000.000000
print("Bioenergy by Sector")
print(optigob.get_bioenergy_by_sector())
print(optigob.get_bioenergy_by_sector_df())
Bioenergy by Sector
{'baseline': {'ad': 0, 'willow_biomass': 0, 'forest_biomass': 0}, 'scenario': {'ad': 5700000, 'willow_biomass': 6605280.0, 'forest_biomass': 9144547.727}}
                baseline     scenario
ad                     0  5700000.000
willow_biomass         0  6605280.000
forest_biomass         0  9144547.727
print("HWP")
print(optigob.get_hwp_volume())
print(optigob.get_hwp_volume_df())
HWP
{'baseline': {'hwp': 0}, 'scenario': {'hwp': 6407181}}
     baseline  scenario
hwp         0   6407181
print("Substitution")
print(optigob.get_substitution_emission_by_sector_co2e())
print(optigob.get_substitution_emission_by_sector_co2e_df())
Substitution
{'ad_substitution': -417.1257789, 'forest_substitution': -3034, 'willow_substitution': -496.3207392}
                        scenario
ad_substitution      -417.125779
forest_substitution -3034.000000
willow_substitution  -496.320739
print("NZ Status")
print(optigob.check_net_zero_status())
print(f"total emissions co2e: {optigob.total_emission_co2e()} kt")
NZ Status
True
total emissions co2e: 12746.540678369938 kt
print("Livestock Population")
print(optigob.get_livestock_population())
print(optigob.get_livestock_population_df())
Livestock Population
{'baseline': {'dairy': 1568000.0, 'beef': 984000.0}, 'scenario': {'dairy': 1832228.3887815578, 'beef': 183222.8388781558}}
        baseline      scenario
dairy  1568000.0  1.832228e+06
beef    984000.0  1.832228e+05
print("Livestock CH4 Emissions budget")
print(optigob.get_livestock_split_gas_ch4_emission_budget())
Livestock CH4 Emissions budget
293.11946640400004
print("Livestock CO2e Emissions budget")
print(optigob.get_livestock_co2e_emission_budget())
Livestock CO2e Emissions budget
-3259.6335684200003
print("AREA comparison")
df = optigob.get_disaggregated_total_land_area_by_sector_df()
print(df)
print("\nSum of each column:")
print(df.sum())
AREA comparison
                         baseline      scenario
dairy                9.808414e+05  1.082978e+06
beef                 2.066291e+06  7.659974e+05
sheep                8.280203e+05  5.956471e+05
pig_and_poultry      0.000000e+00  0.000000e+00
static_crops         3.500000e+05  3.500000e+05
protein_crops        0.000000e+00  0.000000e+00
beccs_willow         0.000000e+00  1.500000e+05
anaerobic_digestion  0.000000e+00  1.300000e+05
managed forest       7.732540e+05  7.812540e+05
afforestation        0.000000e+00  3.686400e+05
other_land_use       1.433000e+06  1.433000e+06
available_area       0.000000e+00  7.738909e+05

Sum of each column:
baseline    6.431407e+06
scenario    6.431407e+06
dtype: float64