Skip to main content

A package for modelling food systems

Project description

AgriFoodPy

AgriFoodPy is a collection of methods for manipulating and modelling agrifood data. It provides modelling for a variety of aspects of the food system, including food consumption paterns, environmental impact and emissions data, population and land use. It also provides an interface to run external models by using xarray as the data container.

In addition to this package, we have also pre-packaged some datasets for use with agrifood. These can be found on the agrifoodpy_data repository https://github.com/FixOurFood/agrifoodpy-data

Installation:

AgriFoodPy can be installed using pip, by running

pip install agrifoodpy

Usage:

Each of the four basic modules on AgriFoodPy (Food, Land, Impact, Population) has its own set of basic array manipulation functionality, a set of modelling methods to extract basic metrics from datasets, and interfaces with external modelling packages and code.

Agrifoodpy employs xarray accesors to add additional functionality on top of the array manipulation

Basic usage of the accesors depend on the type of array being manipulated As an example, using the food module

# import the FoodBalanceSheet accessor and FAOSTAT from agrifoodpy_data
from agrifoodpy.food import FoodBalanceSheet
from agrifoodpy_data.food import FAOSTAT

# Extract data for the UK in 2020 (Region=229, Year=2020)
food_uk = FAOSTAT.sel(Region=229, Year=2020)

# Compute the Self-sufficiency ratio using the fbs accessor SSR function
SSR = food_uk.fbs.SSR(per_item=True)

# Plot the results using the fbs accessor plot_years function
SSR.fbs.plot_years()

To use the specific models and interfaces to external code, these need to be imported

# import the FoodBalanceSheet accessor and FAOSTAT from agrifoodpy_data
from agrifoodpy.food import FoodBalanceSheet
from agrifoodpy_data.food import FAOSTAT
import agrifoodpy.food.model as food_model

# Extract data for the UK in 2020 (Region=229, Year=2020)
food_uk = FAOSTAT.sel(Region=229, Year=2020)

# Scale consumption of meat to 50%, 
food_uk_scaled = food_model.balanced_scaling(food_uk,
                                            items=2731,
                                            scale=0.5,
                                            constant=True)

# Plot bar summary of resultant food quantities
food_uk_scaled.fbs.plot_bars(elements=["production","imports"],
                            inverted_elements=["exports","food"])

In he future, we plan to implement a pipeline manager to automatize certain aspects of the agrifood execution, and to simulate a comprehensive model where all aspects of the food system are considered simultaneously.

Contributing

AgriFoodPy is an open-source project which aims at improving the transparency of evidence base food system interventions and policy making. As such, we are happy to hear the input and ideas from the community.

If you want to contribute, have a look at the discussions page or open a new issue

For a comprehensive guide, please refer to the contributing guidelines to open a pull request to contribute new functionality

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

AgriFoodPy-0.1.1.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

AgriFoodPy-0.1.1-py3-none-any.whl (17.3 MB view details)

Uploaded Python 3

File details

Details for the file AgriFoodPy-0.1.1.tar.gz.

File metadata

  • Download URL: AgriFoodPy-0.1.1.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for AgriFoodPy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b439a15a40ca697af7f12118189e1fb9ec09b44d507b90a17ee612c0fe208603
MD5 0c372b4aecb9d6d493e98f95f3dc24f3
BLAKE2b-256 ae1e88b510abbc94419d9bd0f39cb8a8b72f62b07e6fa09ee392d14e7118d6ef

See more details on using hashes here.

File details

Details for the file AgriFoodPy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: AgriFoodPy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for AgriFoodPy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80e91c09fbb777a0a86403f5318f10bb20ec117a430f5fd0ee80778468f1452b
MD5 2f12e67f1670f0d52acf0f7749d0266a
BLAKE2b-256 0b91e47000841f95c3f88fd86245354e694b2bdade3f077081e1b92accac16db

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