Skip to main content

🌱 Grassland_production, a grassland balance tool for catchment and national level analysis in the Irish context

license python Code style: black

Based on the GOBLIN (General Overview for a Backcasting approach of Livestock INtensification) Grassland module, the Grassland_production library decouples this module making it an independent distribution package.

Structure

The package is structured for use in national and catchment level analysis.

The geo_grassland_production sub module is intended for use at the catchment level and interfaces with the catchment_data_api to retrieve catchment specific grassland data that has been retrieved from Ireland's National Land Cover map

   src/
   │
   ├── grassland_production/
   │   └── ... (other modules and sub-packages)
       │
       ├── geo_grassland_production/
       |   └── ... (other modules and sub-packages)

For national level analysis, the package is shipped with key data for Central Statistics Office grassland areas, Irish National Farm Survey data and FAO fertiliser data.

Currently parameterised for Ireland, refactoring is possible, however, this is designed to work alongside other GOBLIN (and GOBLIN derivative) modules specifically for producing scenarios in an Irish national and catchment context. The module uses the energy requirements of livestock as well as organic and inorganic field inputs to estimate the area required to support the herd.

The final outputs are dataframes for:

-   Total spared (destocked) area relative to a given baseline year
-   Total remaining grassland area
-   Total fertiliser (inorganic) inputs
-   Spared area soil group breakdown
-   Total concentrate feed
-   Per ha stocking rate

Installation

Install from git hub.

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

Install from PyPI

pip install grassland_production

Usage

Below is an example usage of the grassland_production submodule, for the national level.

import pandas as pd
from grassland_production.grassland_output import GrasslandOutput
import shutil
import os

def main():

    #check for previous test data and remove if exists
    if os.path.exists("./test_data"):
        shutil.rmtree("./test_data")

    #create new test data directory
    os.mkdir("./test_data")

    #set up test data
    path_to_data = "./data/"

    ef_country = "ireland"
    calibration_year = 2020
    target_year = 2050

    scenario_dataframe = pd.read_csv(os.path.join(path_to_data,"scenario_input_dataframe.csv"))
    scenario_animal_dataframe = pd.read_csv(os.path.join(path_to_data,"scenario_animal_data.csv"))
    baseline_animal_dataframe = pd.read_csv(os.path.join(path_to_data,"baseline_animal_data.csv"))

    #class instance
    grassland = GrasslandOutput(
        ef_country,
        calibration_year,
        target_year,
        scenario_dataframe,
        scenario_animal_dataframe,
        baseline_animal_dataframe,
    )

    #print results

    #total destocked area
    print(grassland.total_spared_area())

    #total remaining grassland 
    print(grassland.total_grassland_area())

    #farm inputs (nitrogen, phosphorus, potassium, lime)
    print(grassland.farm_inputs_data())

    #baseline (calibration) farm inputs (nitrogen, phosphorus, potassium, lime)
    print(grassland.baseline_farm_inputs_data())

    #total destocked area by soil group
    print(grassland.total_spared_area_breakdown())

    #total concentrate feed
    print(grassland.total_concentrate_feed())

    #per hectare stocking rate
    print(grassland.grassland_stocking_rate())


    #save results to csv
    test_data_path = "./test_data"

    grassland.total_spared_area().to_csv(os.path.join(test_data_path,"spared_area.csv"))
    grassland.total_grassland_area().to_csv(os.path.join(test_data_path,"total_grassland_area.csv"))
    grassland.total_spared_area_breakdown().to_csv(os.path.join(test_data_path,"spared_area_breakdown.csv"))
    grassland.total_concentrate_feed().to_csv(os.path.join(test_data_path,"concentrate_feed.csv"))
    grassland.grassland_stocking_rate().to_csv(os.path.join(test_data_path,"stocking_rate.csv"))


if __name__ == "__main__":
    main()

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for grassland_production 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grassland_production 0.3.6
File Size Uploaded
grassland_production-0.3.6.tar.gz 70.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grassland_production 0.3.6
File Interpreter ABI Platform
grassland_production-0.3.6-py3-none-any.whl Python 3 none any Details

Total release size: 159.2 kB

Release files / grassland_production-0.3.6.tar.gz

Download URL grassland_production-0.3.6.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2959776802d490b73910d87865fe07743859c477bf3982dfbf73cd80e13f68c4
BLAKE2b-256 checksum
How to use checksums
8187a1713272e808619bdf1ed834d7e66de19e9355a41d56f27d4274da2e7092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-131-generic

Release files / grassland_production-0.3.6-py3-none-any.whl

Download URL grassland_production-0.3.6-py3-none-any.whl
Size 88.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eff4a1969f298380b706fc2b878d3a0f802ccab8f0fee368e957aa0fc161e77b
BLAKE2b-256 checksum
How to use checksums
68e4c3faaf67790a59faefe35e28e96fa8e1d05484203c947a120cb732f60455
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-131-generic

Release history Release notifications | RSS feed

This release

0.3.6 This release

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page