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.1

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.1
File Size Uploaded
agrifoodpy-0.2.1.tar.gz 58.7 kB Details

Built distribution (wheel)

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

Total release size: 129.5 kB

Release files / agrifoodpy-0.2.1.tar.gz

Download URL agrifoodpy-0.2.1.tar.gz
Size 58.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d597f56c0eec9f761cbf122890a20e591ea90836519e09401731da0ed00094a5
BLAKE2b-256 checksum
How to use checksums
32774a67dfe8f5928f7ef5265444e2220ad62cb9f319a8e99f36e6c4dffb63cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

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

Download URL agrifoodpy-0.2.1-py3-none-any.whl
Size 70.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3209ffda30c1bd90d8bc1932b2ae2cd7d4f2381065f1528cdb125c97432f5482
BLAKE2b-256 checksum
How to use checksums
6a55aef575dd0badb6c366c351bf4bb61034847847bb8574ad129a83e24c034b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

0.2.2

2 release files

This release

0.2.1 This release

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