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_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
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.5.tar.gz
.
File metadata
- Download URL: grassland_production-0.3.5.tar.gz
- Upload date:
- Size: 69.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-107-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92334555e763bdf875ad8e18e023bc6765e0c64f5d01b9cd4aefabc59ce964ed |
|
MD5 | 3f3dc6594b96f12821839c3088f48e2a |
|
BLAKE2b-256 | de83eefde9135a34d62e684a5992639c794545274b66abe9515bebc909fe67b5 |
File details
Details for the file grassland_production-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: grassland_production-0.3.5-py3-none-any.whl
- Upload date:
- Size: 87.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.0 Linux/5.15.0-107-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af3a4c5955a666337ef18063ee4e3fc7461766a5f07efc9269b40b7ccd70d93 |
|
MD5 | e8d1432bc1c17cd68f832e61e3cf0229 |
|
BLAKE2b-256 | a5adc0ff71af14d59af91c0961a1fa2be3ea61facf194761ed924daf61c1b1a3 |