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
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_dataframe1.csv"))
scenario_animal_dataframe = pd.read_csv(os.path.join(path_to_data,"future_animals.csv"))
baseline_animal_dataframe = pd.read_csv(os.path.join(path_to_data,"past_animals.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file grassland_production-0.3.3.tar.gz
.
File metadata
- Download URL: grassland_production-0.3.3.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-105-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 331555d250d070cd30c04c6abec3c09f8ce49b18637ad060c6aa21c3b1e5e0fa |
|
MD5 | 40fcb9ebba3ceb9cdc611aa16ce1db48 |
|
BLAKE2b-256 | 8ab7f3da0901f84d6789e676f6dc57d4397a4d8db55bb5384f77ae5f2127c984 |
File details
Details for the file grassland_production-0.3.3-py3-none-any.whl
.
File metadata
- Download URL: grassland_production-0.3.3-py3-none-any.whl
- Upload date:
- Size: 80.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-105-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea8ecbaf7bb601075a5da078e90797301eceaaa715b106886159e7dedb6860ad |
|
MD5 | 15eb710f0d570f591b5da32b6f6b9285 |
|
BLAKE2b-256 | d490eba63bdd040e2fc133acc83ae0797df802d0a6bb80c2c7bb5efaedd2c4a1 |