Skip to content
IFPRIPublic

About

Tokki orchestrates DSSAT crop simulations across a 47,707-cell US grid to model maize and soybean yields: it builds per-cell inputs (soil, 30-year weather, climate-matched cultivars), runs CERES/CROPGRO each season, and merges results into one CSV. Calibrated to USDA NASS and built for above/average/below-normal yield monitoring.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

73 Commits

Folders and files

Repository files navigation

Tokki

Gridded, multi-country crop simulation with DSSAT. One country-agnostic Java engine runs DSSAT over thousands of 5-arcminute grid cells in parallel. A shared Python package builds the inputs (weather, soil, MapSPAM cells, management, cultivars) and analyses the outputs. Each country adds only its own data rules, configs and calibration.

Country Folder Crops Status
USA countries/usa maize, soybean, wheat Maize/soybean calibrated and validated against NASS (Corn Belt, 12-state RDA area); winter wheat in 15 states not calibrated
Brazil countries/bra maize (incl. safrinha MZ2), soybean National and core-5-state tables; runs end to end, not calibrated
Argentina countries/arg maize (MZ, late MZ2), soybean (SB, second SB2) National table; runs end to end, not calibrated
Australia countries/aus wheat National table; runs end to end, not calibrated
Ukraine countries/ukr winter wheat National table; runs end to end, not calibrated
Bolivia countries/bol soybean, maize Smoke test passes; separate project

The RDA study area (three crops, five countries) is described in docs/rda-study-area.md.

Layout

engine/              Java engine (Maven). engine/static/ = schema + CO2 history (global)
tokki/               shared Python: weather/ soil/ spam/ units/ cultivar/ analysis/ data_sync.py paths.py
countries/
  defaults.yml       engine defaults every country inherits
  <iso3>/
    country.yml      country settings (extends defaults.yml)
    configs/*.yml    runnable configs: regions, scenarios, smoke test (extend country.yml)
    regions.yml      named regions (lists of ADM1 units)
    calibration/     calibrated DSSAT .CUL files (overlaid on stock DSSAT at run time)
    prep/            country-specific input builders
    analysis/        country-specific validation (e.g. NASS for the USA)
    data-manifest.json   sha256 of the data this commit expects (data lives on Hugging Face)
templates/country/   skeleton for a new country
tests/               smoke fixtures for every country, expected outputs, run_smoke.sh
docs/                conventions.md (read this), adding-a-country.md, data.md
bin/tokki            launcher
data/   (not in git) stock DSSAT, inputs, weather, raw sources, caches — see docs/data.md
runs/   (not in git) one folder per run: runs/<iso3>/<run-id>/

Rule of thumb. Git holds code, configs, calibration and tiny test fixtures. Anything big or regenerable lives in data/ (versioned on Hugging Face) or runs/. Never hard-code a path: use tokki.paths in Python and paths: in configs.

Setup

  1. Java 25 and the bundled Maven wrapper (engine/mvnw, Maven 3.9.10).

  2. DSSAT 4.8, compiled once. Its binary and stock data go into data/dssat/:

    git clone https://github.com/dssat/dssat-csm-os && cd dssat-csm-os
    mkdir release && cd release && cmake -DCMAKE_BUILD_TYPE=RELEASE .. && make && cd ..
    mkdir -p <tokki>/data/dssat
    for d in . BatchFiles Default Genotype Pest StandardData; do cp Data/$d/* <tokki>/data/dssat/ 2>/dev/null; done
    cp release/bin/dscsm048 <tokki>/data/dssat/DSCSM048.EXE

    Keep data/dssat/ stock. Calibrated CULs live in countries/<iso3>/calibration/.

  3. Python (3.10+):

    python3 -m venv .venv && .venv/bin/pip install -e '.[all]'    # or a subset: .[geo,analysis]
  4. Data for the countries you need, from Hugging Face (checked against the manifest):

    .venv/bin/python -m tokki.data_sync pull usa --weather 1995-2025_usa-mzsb
  5. Check everything works:

    tests/run_smoke.sh          # every country's smoke test; needs only data/dssat

data/ and runs/ may be symlinks to another disk, or set TOKKI_DATA / TOKKI_RUNS.

Running

bin/tokki countries/usa/configs/cornbelt.yml               # builds the engine if sources changed
bin/tokki countries/bra/configs/brazil-core.yml --run-id brazil-core-baseline

Each run gets its own folder, so runs for different countries can go at the same time:

runs/usa/cornbelt_20261130-142501/
  config.resolved.yml   merged config
  manifest.txt          git commit, sha256 of inputs and calibration, weather set
  dssat/  input/        staged DSSAT (stock + calibration overlay) and input symlinks
  result/tokki_combinedOutput_*.csv

Exit code 0 = clean. Exit code 2 = some DSSAT runs failed (see .temp/error/). Thread folders are removed after a clean run unless keepThreads: true.

Configs

Configs inherit with extends: (configs/cornbelt.yml → country.yml → defaults.yml). Maps merge and lists are replaced. A region config is usually two lines:

extends: ../country.yml
tableNameUnitInformation: unit-information-cornbelt

The paths: block says where a run reads from. Paths are relative to $TOKKI_DATA, except calibration/static, which are relative to the repo; repo: forces repo-relative:

paths:
  inputs: usa/inputs
  weather: usa/weather/1995-2025_usa-mzsb
  calibration: [countries/usa/calibration]      # overlays, later wins

Working rules

  • Engine changes are shared by every country. Before merging, tests/run_smoke.sh must pass for all of them. If an output legitimately changes, regenerate tests/expected/ in the same commit and say why.
  • One branch, master. Country work goes on short-lived branches (bra/calibration) that merge back. No long-lived per-country forks or clones (that is how Tokki-BO happened).
  • Data changes: rebuild the input, run python -m tokki.data_sync manifest <iso3>, commit the manifest, and push the data. A commit then names exactly the data it used.
  • Read docs/conventions.md before touching seasons, soils, cultivars or weather.

Adding a country

See docs/adding-a-country.md. In short: cp -r templates/country countries/<iso3>, fill in country.yml and regions.yml, build inputs with the shared tools, add a 3–5 cell smoke fixture, and run it.

License

Code is released under the MIT License. Data on Hugging Face keep their sources' terms (see the country READMEs and PROVENANCE.md files). DSSAT is distributed separately under its own licence.

Acknowledgement

This repository was developed by International Food Policy Research Institute (IFPRI) under the Cooperative Research Project "Advancement of Country-Level Crop Growth and Productivity Estimation Technology using Crop Models," funded by the Rural Development Administration (RDA), Republic of Korea, and led by the National Institute of Agricultural Sciences (NAS), RDA, with Seoul National University and Jeonbuk National University as project partners. The authors are solely responsible for the content of this repository.

About

Tokki orchestrates DSSAT crop simulations across a 47,707-cell US grid to model maize and soybean yields: it builds per-cell inputs (soil, 30-year weather, climate-matched cultivars), runs CERES/CROPGRO each season, and merges results into one CSV. Calibrated to USDA NASS and built for above/average/below-normal yield monitoring.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages