Skip to main content

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

Metadata

Release files for AgriFoodPy 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AgriFoodPy 0.2.2
File Size Uploaded
agrifoodpy-0.2.2.tar.gz 59.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for AgriFoodPy 0.2.2
File Interpreter ABI Platform
agrifoodpy-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 128.1 kB

Release files / agrifoodpy-0.2.2.tar.gz

Download URL agrifoodpy-0.2.2.tar.gz
Size 59.1 kB
Tags Source
SHA-256 checksum
How to use checksums
feaad66bf75dc0826e186218a4d76f83c2d1e922e1d2562e70fdca3f670d3422
BLAKE2b-256 checksum
How to use checksums
e53ef3c72e6556bbf2a679c1719c7895fc8c8f8f13c85d001da808f4a66672e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / agrifoodpy-0.2.2-py3-none-any.whl

Download URL agrifoodpy-0.2.2-py3-none-any.whl
Size 69.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1bd7242f80242f5d1eb00b4d47f2876c84df11fd2fcaffe0159c29fae0d78eb
BLAKE2b-256 checksum
How to use checksums
04b26deb591a3baa832935aeaac209d1421a12dc28c083be01e8bf0ca3eaf115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page