Skip to main content

An interface between the CBM CFS3, libcbm_py, model and the GOBLIN model.

Project description

🌲 GOBLIN_CBM_runner, a CBM CFS3 interface for the GOBLIN model

license python Code style: black

Based on the GOBLIN (General Overview for a Backcasting approach of Livestock INtensification) LifeCycle Analysis tool, the cbm_runner package generates the data requried for the CBM CFS3 (libcbm_py) tool. It also interfaces with the tool directly, generating results in a single dataframe for all scenarios.

The outputs are related to biomass, and dead organic matter. These are summed into a total ecosystem value.

The estimated volumns are all in t of C.

Installation

Install from git hub.

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

Install from PyPI

pip install goblin_cbm_runner

Usage

The Runner class takes the total afforestation area and divides it evenly across years (calibration year - target year).

from goblin_cbm_runner.default_runner.runner import Runner
from goblin_cbm_runner.resource_manager.cbm_runner_data_manager import DataManager
import pandas as pd
import os


def main():
    # path to data
    path = "./data/runner_input"
    results_path = "./data/runner_results"

    # afforestation data for each scenario
    afforest_data = pd.read_csv(
        os.path.join(path, "cbm_afforestation.csv"), index_col=0
    )

    # basic configuration file
    config = os.path.join(path, "cbm_factory.yaml")

    # scenario_data
    sc_data = pd.read_csv(os.path.join(path, "scenario_dataframe.csv"))

    # calibration and end point
    calibration_year = 2020

    # instance of the DataManager class
    data_manager = DataManager(calibration_year = calibration_year,
                            config_file_path=config,
                            scenario_data=sc_data,
                            afforest_data=afforest_data)
    
    # instance of the Runner class
    runner = Runner(data_manager)

    # afforeation data
    runner.get_afforestation_dataframe().to_csv(os.path.join(results_path, "c_afforestation.csv"))

    # generation of aggregated results
    runner.run_aggregate_scenarios().to_csv(os.path.join(results_path, "c_aggregate.csv"))

    # generation of annual flux results
    runner.run_flux_scenarios().to_csv(os.path.join(results_path, "c_flux.csv"))


if __name__ == "__main__":
    main()

CBM Disturbance Sort Types Note

libcbm_py is not a direct conversion of the CBM-CFS3 model, and there are some small differences.

One key difference is the available sort types for stand disturbances. Some sorting options in CBM-CFS3 are not available in libcbm_py, while others may function slightly differently.

In particular, the "Sort by time since softwood component was last harvested" (4) and "Sort by time since hardwood component was last harvested" (13) are missing from libcbm_py. These sorts help prioritize stands based on past harvests, which can be important for disturbance modeling.

Below, we provide the full set of sort types from CBM-CFS3, followed by the available sorts in libcbm_py, along with suggested approximations for missing sorts.


Sort Types from CBM-CFS3

The following table lists all disturbance sort types available in CBM-CFS3:

Sort Type Description
1 No sorting; a proportion of each record to disturb is calculated. Only applicable to disturbance events with proportion (P) targets.
2 Sort by merchantable biomass carbon (highest first). Only applicable to disturbance events with merchantable carbon (M) targets.
3 Sort by oldest softwood first.
4 Sort by time since the softwood component was last harvested.
5 Sort by SVO (State Variable Object) ID. Used for spatially explicit projects and instructs the model to disturb 100% of a single eligible record.
6 Sort randomly. Only applicable to fire and insect disturbance events.
7 Sort by total stem snag carbon (highest first).
8 Sort by softwood stem snag carbon (highest first).
9 Sort by hardwood stem snag carbon (highest first).
10 Sort by softwood merchantable carbon (highest first).
11 Sort by hardwood merchantable carbon (highest first).
12 Sort by oldest hardwood first.
13 Sort by time since the hardwood component was last harvested.

Available Sort Types in libcbm_py

Below are the disturbance sort types that are implemented in libcbm_py:

{
    1: "PROPORTION_OF_EVERY_RECORD",
    2: "MERCHCSORT_TOTAL",
    3: "SORT_BY_SW_AGE",
    5: "SVOID",
    6: "RANDOMSORT",
    7: "TOTALSTEMSNAG",
    8: "SWSTEMSNAG",
    9: "HWSTEMSNAG",
    10: "MERCHCSORT_SW",
    11: "MERCHCSORT_HW",
    12: "SORT_BY_HW_AGE",
}

License

This project is licensed under the terms of the MIT 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_cbm_runner-0.5.0.tar.gz (928.1 kB view details)

Uploaded Source

Built Distribution

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

goblin_cbm_runner-0.5.0-py3-none-any.whl (972.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: goblin_cbm_runner-0.5.0.tar.gz
  • Upload date:
  • Size: 928.1 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_cbm_runner-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2724bc8aefa30892760924d1d625dece454a8cd280e6721f328d73c79ba2f666
MD5 b14ce8f928cb76181d4be21fde66e79c
BLAKE2b-256 efa89cc42b348436c7d92d68909f90987d6be020fa1365fa75de3643dec36961

See more details on using hashes here.

File details

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

File metadata

  • Download URL: goblin_cbm_runner-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 972.0 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_cbm_runner-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 396baa49a54626a5247c87eaa7e7aebd45fd81fa61e9e320c0412c3e755ca168
MD5 7016af6296b25c12f14f321749e11bb3
BLAKE2b-256 cfa00408b3890cbbb2d70e5b3dfa35d24aa67d04e9cf599f65f375b31a33b1f3

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