Skip to main content

A package for modelling food systems

Project description

AgriFoodPy

Documentation Status Tests

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.

AgriFoodPy also provides a pipeline manager to build end-to-end simulations and analysis toolchains. Modules can also be executed in standalone mode, which does not require a pipeline to be defined.

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

UK data to test the package is available from the agrifoodpy_data repository which currently can be installed using

pip install git+https://github.com/FixOurFood/agrifoodpy-data.git@importable

Usage:

AgriFoodPy modules can be used to manipulate food system data in standalone mode or by constructing a pipeline of modules which can be executed partially or completely.

To build a pipeline

from agrifoodpy.pipeline import Pipeline
from agrifoodpy.utils.load_dataset import load_dataset
from agrifoodpy.food.model import 
import matplotlib.pyplot as plt

# Create pipeline object
fs = Pipeline()

# Add node to load food balance sheet data from external module.
fs.add_node(load_dataset,
            {
                "datablock_path": "food",
                "module": "agrifoodpy_data.food",
                "data_attr": "FAOSTAT",
                "coords": {"Year":np.arange(1990, 2010), "Region":229}
            })


# Add node convert scale Food Balance Sheet by a constant
fs.add_node(fbs_convert,
            {
                "fbs":"food",
                "convertion_arr":1e-6 # From 1000 Tonnes to kg
            })

fs.run()

results = fs.datablock

Examples and documentation

Examples demonstrating the functionality of AgriFoodPy can be the found in the package documentation. These include the use of accessors to manipulate data and access to basic models.

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.2.0.tar.gz (37.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agrifoodpy-0.2.0-py3-none-any.whl (48.7 kB view details)

Uploaded Python 3

File details

Details for the file agrifoodpy-0.2.0.tar.gz.

File metadata

  • Download URL: agrifoodpy-0.2.0.tar.gz
  • Upload date:
  • Size: 37.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for agrifoodpy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 320c9a6fbff983c09919d31c4bfdd8ac1da130332359aba36b59d6875a68a0b2
MD5 a3692996e29efcd4b81c24d53a5919bb
BLAKE2b-256 1a92ac0c61e74318a024a9d085ad78d93a15038041adfc089086f33585d844d7

See more details on using hashes here.

File details

Details for the file agrifoodpy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agrifoodpy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 48.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for agrifoodpy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1382bf01e50738edf5c7160495b4f99f0bb2cb9191d5876dfb67bb539f6e1da4
MD5 a6fcae5d46cdfc6ef9036eb69555e424
BLAKE2b-256 89b2c72b19ae9146466084917469b0e215079d32f44204003031e59cfb321f56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page