Skip to main content

A goblin tool for the generation of static land balance scenarios and environmental impacts

Project description

🧌🏋️ Goblin lite, for the generation of static scenarios using the GOBLIN modelling framework

license python Code style: black

Based on the GOBLIN (General Overview for a Backcasting approach of Livestock INtensification) Scenario module

The package makes use of several other custom packages that are designed around the original GOBLIN model and the Geo GOBLIN model. It is called "GOBLIN lite" more so for the fact that it does not rely on heavy code base found in previous GOBLIN models. Instead, the GOBLIN lite package coordinates stand alone packages related to herd generation, grassland production, land use, forest carbon sequestration, scenario generation and scenario assessment.

In addition to climate change impact categories, goblin lite also produces eutrophication and air quality impacts as well.

There are specific classes for the retrieval of input and output dataframes, and the production of a limited number of graphics.

GOBLIN lite also has the capacity to rank scenarios based on environmental impacts and the overall change in protein production.

For a full list of custom package documentation that GOBLIN lite relies on, please see the FUSION research website.

Installation

Install from git hub.

pip install "goblin_lite@git+https://github.com/GOBLIN-Proj/goblin_lite.git@main" 

Install from PyPI

pip install goblin_lite

Usage

Firstly, the config.json file should look like the following. The example shows a two scenarios.

To add additional scenarios, simply repeat the inputs given here, update the values, including the sceanrio numbers.

In previous versions, each scenario took 4 rows, 1 for each livestock system. This has been reduced to a single row for each scenario with additional prameters.

In addition, a csv file can now be used instead. Simply add the keys as columns and the values in the rows, with a row for every scenario.

Note: Afforest year should be the target year + 1

[{
    "Scenarios": 0,
    "Manure management cattle": "tank liquid",
    "Manure management sheep": "solid",
    "Dairy pop": 1060000,
    "Beef pop":10000,
    "Upland sheep pop": 3000,
    "Lowland sheep pop": 50000,
    "Dairy prod":0,
    "Beef prod":0,
    "Lowland sheep prod": 0,
    "Upland sheep prod": 0,
    "Forest area":1,
    "Conifer proportion":0.7,
    "Broadleaf proportion": 0.3,
    "Conifer harvest": 0.05,
    "Conifer thinned": 0.1,
    "Broadleaf harvest": 0,
    "Crop area": 0,
    "Wetland area":0,
    "Dairy GUE":0,
    "Beef GUE":0,
    "Dairy Pasture fertilisation": 150,
    "Beef Pasture fertilisation": 110,
    "Clover proportion": 0.5,
    "Clover fertilisation": 0,
    "Urea proportion": 0.2,
    "Urea abated proportion": 0,
    "Afforest year": 2051   
},
{
    "Scenarios": 1,
    "Manure management cattle": "tank liquid",
    "Manure management sheep": "solid",
    "Dairy pop": 1060000,
    "Beef pop":10000,
    "Upland sheep pop": 10000,
    "Lowland sheep pop": 10000,
    "Dairy prod":0,
    "Beef prod":0,
    "Lowland sheep prod": 0,
    "Upland sheep prod": 0,
    "Forest area":1,
    "Conifer proportion":0.7,
    "Broadleaf proportion": 0.3,
    "Conifer harvest": 0.05,
    "Conifer thinned": 0.8,
    "Broadleaf harvest": 0,
    "Crop area": 0,
    "Wetland area":0,
    "Dairy GUE":0,
    "Beef GUE":0,
    "Dairy Pasture fertilisation": 150,
    "Beef Pasture fertilisation": 110,
    "Clover proportion": 0.5,
    "Clover fertilisation": 0,
    "Urea proportion": 0.2,
    "Urea abated proportion": 0,
    "Afforest year": 2051  
}]

The model also requires a yaml file to set specific parameters for the CBM CFS3 model

Dynamic_Afforestation:
  afforest_delay: 5 #delays scenario afforestation by x years
  annual_afforestation_rate_pre_delay: 1200 #the default annual afforestation rate before during the delay period
  species_distribution: #the distribution of species in the landscape during delay period
    - Sitka: 0.7
    - SGB: 0.3

Forest_management:
  intensity: high

Classifiers:
  baseline:
    harvest:
      clearfell:
        - conifer: 0.95
        - broadleaf: 0.6
      thinning:
        - conifer: 0.5
        - broadleaf: 0.9
  scenario:
    harvest:
      clearfell:
        - broadleaf: 0.0
      thinning:
        - broadleaf: 0.5
        
  age_classes:
    max_age: 100
    age_interval: 5

  species:
    - Sitka
    - SGB

  yield_class:
    Sitka:
      - YC13_16: 0.37
      - YC17_20: 0.26
      - YC20_24: 0.20
      - YC24_30: 0.17
    SGB:
      - YC10: 1

Below is an example of the model, which generates scenarios, and the uses the results to generate graphics.

from goblin_lite.goblin import ScenarioRunner
from goblin_lite.resource_manager.goblin_data_manager import GoblinDataManager
from goblin_lite.scenario_analysis.data_grapher import DataGrapher
import shutil
import os


def main():
    # configuration
    goblin_config = "./data/config.json"
    cbm_config = "./data/cbm_factory.yaml"
    ef_country = "ireland"
    baseline_year = 2020
    target_year = 2050

    data_path = "./graph_data"
    # remove graph dir
    shutil.rmtree(data_path)

    # output dir
    os.mkdir(data_path)


    # create goblin data manager
    goblin_data_manger = GoblinDataManager(
        ef_country = ef_country, 
        calibration_year= baseline_year,
        target_year= target_year,
        configuration_path= goblin_config,
        cbm_configuration_path= cbm_config,
    )

    # class instances
    runner_class = ScenarioRunner(goblin_data_manger)

    
    graph_class = DataGrapher()

    # run scenarios
    runner_class.run_scenarios()

    # plot data
    graph_class.plot_animal_lca_emissions_by_category(data_path)
    graph_class.plot_land_use_emissions(data_path)
    graph_class.plot_forest_flux(data_path, detail=True)
    graph_class.plot_forest_aggregate(data_path)
    graph_class.plot_forest_flux_subplot(data_path)
    graph_class.plot_crop_lca_emissions_by_category(data_path)
    graph_class.plot_crop_livestock_lca_emissions_by_category(data_path)

    # ranking variables
    target = 0.01
    gas = "CO2E"

    # plot ranks
    graph_class.rank_chart(target, gas, data_path)


if __name__ == "__main__":
    main()

License

This project is licensed under the terms of the GPL-3.0-or-later license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goblin_lite-0.5.0.tar.gz (161.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goblin_lite-0.5.0-py3-none-any.whl (171.1 kB view details)

Uploaded Python 3

File details

Details for the file goblin_lite-0.5.0.tar.gz.

File metadata

  • Download URL: goblin_lite-0.5.0.tar.gz
  • Upload date:
  • Size: 161.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-131-generic

File hashes

Hashes for goblin_lite-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ef191eb37033f1c563e2279b7cb4ec192f6eb7da2c7dd49505697101ef35ed16
MD5 595f9aaa139dc86fea158fe9ea38ddf5
BLAKE2b-256 1bd99f42055beba8b1025d4b888f2ef811a0e5ca098a7e04094d880c7f9f328d

See more details on using hashes here.

File details

Details for the file goblin_lite-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: goblin_lite-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 171.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-131-generic

File hashes

Hashes for goblin_lite-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff570496b5390587e36afc556c46d12008ece2836432f5c5ada4bafd8bac2bf
MD5 86496c91948732a8701358545ec5d592
BLAKE2b-256 efa3a94ef4653547c3e3c4ac146ad1369e471f0c6cf2d415a4b936ff0ac93546

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page