Skip to main content

Computation of grassland area and production based on animal energy calculations and grassland inputs

Project description

🌱 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_dataframe2.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.

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

grassland_production-0.3.4.tar.gz (64.8 kB view details)

Uploaded Source

Built Distribution

grassland_production-0.3.4-py3-none-any.whl (80.1 kB view details)

Uploaded Python 3

File details

Details for the file grassland_production-0.3.4.tar.gz.

File metadata

  • Download URL: grassland_production-0.3.4.tar.gz
  • Upload date:
  • Size: 64.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-106-generic

File hashes

Hashes for grassland_production-0.3.4.tar.gz
Algorithm Hash digest
SHA256 d555ad1330997d0b9ce4de67c9df8cad95553a22a5765979d6808cd1e923a54d
MD5 a9cea21a770b8c17caa2342b7bab689a
BLAKE2b-256 8ed6fe1cd3ff927e6b85f3a5cd9b400b4432e3acd82d3ae255d6a7da7bdc6b64

See more details on using hashes here.

File details

Details for the file grassland_production-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for grassland_production-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0b2b48aec17717f487221c707228b6799c4f5bc95bb403edb540576a9180de21
MD5 35c1d66f4e0ee1e1f8b0dd461d18fced
BLAKE2b-256 512f887028c41655895df72c5cded51a911e6c3bc412ac64bd3fd84ec60ba972

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