aggfly: Efficient climate data aggregation
NOTE: aggfly is still in development and may not be stable for new users. Please proceed with caution.
aggfly is a Python package developed to facilitate and harmonize the temporal and
spatial aggregation of gridded climate data. It performs linear and nonlinear
aggregations of weather data across different time periods — degree days, bins,
daily polynomials — and supports spatial aggregation by weighting gridded data
according to administrative boundaries and local exposures such as human
populations and crop distributions.
The package automates complex and memory-intensive geospatial operations, which are
common challenges for researchers dealing with large climate datasets. aggfly is
useful for researchers studying the impacts of weather and climate on other
variables, such as human health, agriculture, and economic growth.
Installation
pip install aggfly
Requires Python 3.11–3.13. Full instructions — including the uv-based development setup and Jupyter kernels — are in docs/installation.md.
Quickstart
Three inputs: a shapefile of target regions, a climate raster to aggregate, and optionally a secondary weights raster (population, cropland).
import numpy as np
import aggfly as af
# 1. Load regions and a sample raster layer
georegions = af.georegions_from_path("counties.shp", regionid="GEOID")
dataset = af.dataset_from_path(
"era5_2017.zarr", var="t2m",
georegions=georegions,
preprocess=lambda x: x - 273.15, # Kelvin → Celsius
)
# 2. Compute weights (cached; reused across years)
weights = af.weights_from_objects(dataset, georegions, project_dir="./proj")
weights.calculate_weights()
# 3. Transform and aggregate → a region-by-period panel
df = af.aggregate_dataset(
dataset=dataset,
weights=weights,
tavg=[
('aggregate', {'calc': 'mean', 'groupby': 'date'}),
('transform', {'transform': 'power', 'exp': np.arange(1, 3)}),
('aggregate', {'calc': 'sum', 'groupby': 'year'}),
],
growing_dday=[
('aggregate', {'calc': 'dd', 'groupby': 'date', 'ddargs': [10, 30, 0]}),
('aggregate', {'calc': 'sum', 'groupby': 'year'}),
],
)
See the Quickstart guide for a walkthrough of each step.
Command-line interface
The whole workflow can also be driven from a YAML config file — no Python script required:
aggfly info era5_2017.zarr --var t2m # discover coords, calendar, lon convention
aggfly validate config.yaml # check the config, no data read
aggfly run config.yaml # aggregate → panel
See the CLI reference and runnable configs in
examples/.
Documentation
| Documentation home | Full table of contents. |
| Installation | pip for users, uv for development. |
| Concepts | How the pipeline works and why weights matter. |
| Quickstart | End-to-end Python API walkthrough. |
| Weights | Area and secondary (population/crop) weighting. |
| Aggregation | The spec DSL: calcs, transforms, degree days, bins. |
| Execution & scaling | Dask backends and recipes by hardware. |
| Calendars | CMIP6 and non-standard CF calendars. |
| CLI | info, validate, weights, run. |
| API reference | The public Python API. |
Worked examples live in examples/ (CLI configs).
New to aggfly? quickstart_public_data.ipynb
is a standalone notebook that downloads all of its own data (~25 MB, public, no accounts) and runs
the full pipeline end to end — no local files required.
Acknowledgements
I gratefully acknowledge the support and funding provided by the Climate & Environment Program at Private Enterprise Development in Low Income Countries (PEDL, CEPR), and stellar research assistance from Giovanni Brocca and Nick Silvis. Research assistance was funded by Professors Colmer, Porzio, and Rossi through their project "The Human (Capital) Side of Climate Change," which was financed by the International Growth Center (XXX-23020) and Columbia Business School. The funding and research assistance provided were instrumental in the development of this package. I sincerely thank them for their commitment to advancing research and innovation.
Metadata
Release files for aggfly 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aggfly-0.4.0.tar.gz | 96.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aggfly-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 207.5 kB
Release files / aggfly-0.4.0.tar.gz
| Download URL | aggfly-0.4.0.tar.gz |
|---|---|
| Size | 96.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0ec6e7e54fea738f83acb8563cbb6d7b632c46ca20bbcaa12022a688e3bb2a3
|
|
BLAKE2b-256 checksum How to use checksums |
ed772751c874918b5845986a21d6b88343a73e38b6d14929412a7c761a78ca0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / aggfly-0.4.0-py3-none-any.whl
| Download URL | aggfly-0.4.0-py3-none-any.whl |
|---|---|
| Size | 110.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed5e798d121c83e83aed0348c79ae5c7551400daa38dacfcca8c64d05b7674dc
|
|
BLAKE2b-256 checksum How to use checksums |
959107a37a7c6ad1f7631b48381e99f641ab84af665e124e93d1e534f46c78be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for aggfly 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.