Skip to main content

calicropyield

Python client library for downloading and preparing county-level data used in the California Crop Yield Benchmark.

What this package does

calicropyield provides a single client to retrieve benchmark-ready files from the public Hugging Face dataset hkaman/california-crop-yield-benchmark:

  • ET (OpenET monthly GeoTIFF)
  • Landsat monthly GeoTIFF
  • CDL annual GeoTIFF
  • Irrigation annual GeoTIFF (IrrMapper)
  • DayMet climate (stored as Zarr, saved locally as NetCDF)
  • Soil (stored as Zarr, saved locally as NetCDF)
  • CDFA crop yield (statewide parquet, saved locally as one CSV per county)

The package supports optional geometry-based cropping and lightweight filtering for CDL/USDA outputs.

Installation

From source (this repository)

git clone https://github.com/plant-ai-biophysics-lab/calicropyield-dev.git
cd calicropyield-dev
pip install .
uv sync --extra dev --extra test

Authentication setup

None required. The dataset is public on Hugging Face, so the client downloads anonymously.

If you are logged in to Hugging Face (hf auth login, or the HF_TOKEN environment variable), your token is picked up automatically, which gives you higher rate limits for large downloads.

Quickstart

from calicropyield import CalCropYieldClient

client = CalCropYieldClient(
    cache_dir="~/data/calicropyield",
    dataset_version="v2",   # optional; defaults to latest
    overwrite=False,
)

print(client.list_datasets())
print(client.list_years("landsat"))

# Download 2021 Landsat files for two counties
paths = client.download_landsat(["Yolo", "Fresno"], years=[2021])
print(f"Downloaded {len(paths)} files")

Public API

Main exports:

  • CalCropYieldClient
  • DatasetCatalog
  • DataDownloader (backward-compatible alias of CalCropYieldClient)

Download methods

All download methods return List[pathlib.Path]:

  • download_et(county_names, years=None, geometry=None)
  • download_landsat(county_names, years=None, geometry=None)
  • download_climate(county_names, years=None, geometry=None, variables=None)
  • download_soil(county_names, geometry=None, variables=None)
  • download_cdl(county_names, years=None, geometry=None, crop_types=None)
  • download_irrigation(county_names, years=None, geometry=None)
  • download_yield(county_names, years=None, crop_types=None)

Introspection helpers

  • list_datasets()
  • list_years(dataset="landsat")
  • list_counties()

Dataset catalog and versioning

Dataset layout is defined in a versioned manifest file: calicropyield/catalog.json.

  • Current latest dataset version: v2, served from the Hugging Face repo named by hf_repo (at hf_revision) in the catalog
  • Years are declared per dataset (list_years("<dataset>")); 2012 is absent for every dataset
  • Available dataset keys: et, landsat, cdl, irrigation, climate, soil, yield
  • v1 (the original Google Drive release) is still listed for reference but is no longer downloadable

You can inspect catalog metadata via:

from calicropyield import DatasetCatalog

catalog = DatasetCatalog()  # latest
print(catalog.version)
print(catalog.available_datasets)
print(catalog.years_for("landsat"))

Output structure

Downloaded files are stored under:

<cache_dir>/counties/<County>/data/<dataset_type>/<year>/...

For non-yearly datasets (for example soil), year subfolders are omitted.

Development workflow

This project uses:

  • uv for environment and lockfile management
  • ruff for linting
  • pytest for tests
  • setuptools-scm for dynamic package versioning from git tags

Common commands:

uv sync --extra dev --extra test
uv run ruff check calicropyield/
uv run pytest
uv lock

Releases

Package version is derived from git tags (for example v0.2.0).

Typical release flow:

git tag vX.Y.Z
git push origin vX.Y.Z

On tag push, GitHub Actions builds wheel and sdist artifacts and validates them with twine check.

Repository layout

  • calicropyield/: installable Python package
  • dataset/: internal dataset generation scripts/notebooks (these wrote the original GCS release, which has since been moved to Hugging Face)
  • .github/workflows/ci.yml: lint/test/build CI

End-user tutorial notebooks and benchmark usage examples live in the companion repository:

License

BSD 3-Clause License. See LICENSE.

Metadata

Release files for calicropyield 0.4.0

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

Source distribution (sdist)

Source distribution for calicropyield 0.4.0
File Size Uploaded Provenance Actions
calicropyield-0.4.0.tar.gz 7.5 MB Without provenance Details for calicropyield-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calicropyield 0.4.0
File Interpreter ABI Platform Actions
calicropyield-0.4.0-py3-none-any.whl Python 3 none any Details for calicropyield-0.4.0-py3-none-any.whl

Total release size: 7.5 MB

Release files / calicropyield-0.4.0.tar.gz

Download URL calicropyield-0.4.0.tar.gz
Size 7.5 MB
Tags Source
SHA-256 checksum
How to use checksums
ad835e50f17c687798ccbb75ffc4bd36cec404e5ad32805bd9529232c10f3eb1
BLAKE2b-256 checksum
How to use checksums
8bd867094f4cd3128fe101d376af8b193dbf4ad9fe9d4a78ec6ea8c03fcbd994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / calicropyield-0.4.0-py3-none-any.whl

Download URL calicropyield-0.4.0-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0d5c7a5f6d3caa440f38beeff5ed54ea07f73f853ffc549993c3b444c3b4e6b
BLAKE2b-256 checksum
How to use checksums
e11e7c754e8be7544ced32cc480f47d12ab9f538e3ddb1628516ee4e97c61a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for calicropyield 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.

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