Skip to main content

Generation of user defined scenarios for the GOBLIN model

Project description

💻 Static Scenario Generator for the generation of non randomised scenarios for GOBLIN

license python Code style: black

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

The package is simple. It defines the columns for scenario inputs. A user provided json or csv file is used to generate rows for each scenario and each corresponding livestock system.

Currently parameterised for Ireland, but the database can be updated with additional emissions factor contexts, which are selected able with an emissions factor key.

Final result is a pandas dataframe of scenario inputs that can be read by numerous GOBLIN packages.

The library contains sub-modules for the generation of scenarios for the national and sub-national (catchment level)

The package is structured as:

  src/
  │
  ├── static_scenario_generator/
      └── ... (other modules and sub-packages)
      │
      ├── geo_static_scenario_generator/
      └── ... (other modules and sub-packages)

The geo_static_scenario_generator modules are used for catchment level analysis, while the static_scenario_generator modules are used for national level analysis.

Installation

Install from git hub.

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

Install from PyPI

    pip install static_scenario_generator

Usage

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

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

In the previous version (v0.1.0) each scenario took 4 rows, 1 for each livestock system. However, this was cumbersome to deal with, and has now been refactored so that the input data does not require repition. The module will still create the 4 rows in the final dataframe for each entry. But the user only needs a single block to achieve this.

In addition, the module has been updated to allow the user to use csv files for data input. Each row in the csv file corresponds to a scenario with the same keys as columns. The ordering of the keys does not matter.

Finally, additional variables related to clover (clover proportion & clover fertilisation) and grass use efficiency (Dairy GUE and Beef GUE) have been added.

This addition makes the module incompatible with GOBLIN lite v0.1.0.

[{
    "Scenarios": 0,
    "Manure management cattle": "tank liquid",
    "Manure management sheep": "tank solid",
    "Dairy pop": 1060000,
    "Beef pop":1000,
    "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": 2080   
},
{
    "Scenarios": 1,
    "Manure management cattle": "tank liquid",
    "Manure management sheep": "tank solid",
    "Dairy pop": 1060000,
    "Beef pop":1000,
    "Upland sheep pop": 0,
    "Lowland sheep pop": 0,
    "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": 2080  
}
]

To generate the dataframe, follow the example below.

from static_scenario_generator.scenarios import ScenarioGeneration

def main():
    #instantiate the class 
    scenario_class = ScenarioGeneration()
    
    #pass the configuration file and return a pandas dataframe. 

    print(scenario_class.generate_scenario_dataframe("./data/config.json"))

if __name__ == "__main__":
    main()
    

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

static_scenario_generator-1.1.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

static_scenario_generator-1.1.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file static_scenario_generator-1.1.1.tar.gz.

File metadata

  • Download URL: static_scenario_generator-1.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-105-generic

File hashes

Hashes for static_scenario_generator-1.1.1.tar.gz
Algorithm Hash digest
SHA256 960dbcbc712c4c787d9d18f9a239be9e0bcd77b426db944c64cd7870d3afab89
MD5 c16a2da7a1e7e9f3e08eeec9916e4d12
BLAKE2b-256 d3539c45978d379214c5f4045e10244c870e3d768068bc654dd8a59b80963b8f

See more details on using hashes here.

File details

Details for the file static_scenario_generator-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for static_scenario_generator-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05be91cbe308b6025de7015a46161dc1d7fce756c8bbc16902e9ae02987b2b89
MD5 89c4bf1a244ce953eabbfbdeb30dc410
BLAKE2b-256 8c64551d56d507d7a32cd7df09f6a411ff8c0485918f3b9cb1b3e1a02802c74e

See more details on using hashes here.

Supported by

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