Coder Social home page Coder Social logo

static_scenario_generator's Introduction

๐Ÿ’ป 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.

static_scenario_generator's People

Contributors

colmduff avatar

Watchers

 avatar

static_scenario_generator's Issues

Update to v1.0.0

Addition of GUE and Clover variables. In addition, reduced block requirement for user input and the ability to use csv and json files. The addition of new variables will make this version incompatible with GOBLIN lite v0.1.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.