Skip to main content

dssatlab

dssatlab aims to be a Python interface to the DSSAT-CSM. The goal is to let users work with DSSAT from Python and use the wider Python ecosystem (data, analysis, plotting, notebooks) to make DSSAT easier and more powerful to use.

PyPI version Python versions Downloads Tests License Open In Colab

Installation

pip install dssatlab

Requires Python 3.10 or newer. To upgrade later: pip install --upgrade dssatlab.

Current stage

The project can get a working DSSAT into Python, run an existing experiment file, and run a simulation from your own weather data. This part is done:

  • Find an existing DSSAT-CSM installation on Windows and Linux (including Google Colab)
  • Build DSSAT-CSM from the official release on Linux and Colab
  • Run one existing FileX
  • Turn your own daily weather into a strictly checked simulation and run it
import dssatlab as dl

dssat = dl.connect()                          # path to the DSSAT executable
result = dl.run("UFGA8201.MZX")               # all treatments
result = dl.run("UFGA8201.MZX", treatment=2)  # one treatment
print(result.run_dir, result.outputs)

How a run works:

  • DSSAT runs in the FileX's own folder, so weather and soil files beside the FileX are found. Its output files are then moved into a new dssat_run_<date> folder beside the FileX, and your FileX folder is left as it was.
  • The FileX filename can be at most 12 characters, including the extension (DSSAT's own limit), for example UFGA8201.MZX.
  • A failed run raises DSSATRunError with the command, the end of DSSAT's console output and the start of ERROR.OUT. The run folder is kept so you can look inside.
  • run() returns the files DSSAT wrote and does not read them. Reading input or output files, building experiments and plotting are not built yet.

Upgrading from 0.1.x on Linux or Colab: a DSSAT built by 0.1.x cannot run simulations, so the first dl.install() (or dl.connect() with consent) rebuilds it once.

Your own weather data

Put your daily weather in the fixed weather template, then create a Simulation for one treatment of an existing FileX:

import dssatlab as dl

dl.write_weather_template("weather.csv")       # a correct example to start from
sim = dl.Simulation("UFGA8201.MZX", treatment=1, weather="weather.csv")

problems = sim.check()   # every problem at once, nothing is written; [] means fine
result = sim.run()       # checks first, then writes the files and runs DSSAT

The template is one comma-separated UTF-8 CSV with these exact lower-case column names, in any order. Values are in DSSAT's own units and nothing is converted:

Column Meaning
station four letters or digits, the weather station code
latitude, longitude degrees
elevation m
date YYYY-MM-DD, one row per calendar day, sorted, no gaps or duplicates
srad solar radiation, MJ/m2 per day
tmax, tmin degrees C
rain mm
tav, amp, refht, wndht optional; left empty they are written as -99 (not given)

Station, latitude, longitude and elevation must be identical on every row. The weather can also be given as a list of dicts with the same keys, or as a pandas DataFrame (pandas is never required).

What happens:

  • check() reports every problem it finds: wrong or unknown columns, empty or non-numeric values, bad dates, gaps, impossible values (for example tmax below tmin, negative rain), and, by reading the chosen treatment in your FileX, a station that does not match the FileX or weather that does not cover its start date. Nothing is fixed or filled in automatically.
  • run() raises one DSSATCheckError listing all problems if there are any, before writing anything.
  • Otherwise run() makes a new dssat_sim_<date> folder beside your FileX holding a copy of the FileX, your .SOL, .CUL, .ECO and .SPE files that sit beside it, and the generated weather file, then runs DSSAT there. The run's output files are in the dssat_run_<date> folder inside it. Your own files and folder are not changed.
  • DSSAT does not fail when weather is missing: it exits normally and gives -99 results. So after the run, run() looks for DSSAT's "weather record not found" warning and raises DSSATRunError naming the first missing date.

Not built yet: soil and management data, unit converters, reading DSSAT's output files, and more than one treatment per Simulation.

Metadata

Release files for dssatlab 0.3.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 dssatlab 0.3.0
File Size Uploaded Provenance Actions
dssatlab-0.3.0.tar.gz 42.2 kB With provenance Details for dssatlab-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 63.8 kB

Release files / dssatlab-0.3.0.tar.gz

Download URL dssatlab-0.3.0.tar.gz
Size 42.2 kB
Tags Source
SHA-256 checksum
How to use checksums
21d07d6377a50f73599cf77bd40fdb3232515f9946e43dac21fb0fa532b1943a
BLAKE2b-256 checksum
How to use checksums
383de5e2a64b5c2a032c335bf3dca84aee0cdce0fde2ee8c21333436ed893adb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / dssatlab-0.3.0-py3-none-any.whl

Download URL dssatlab-0.3.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e58a2df939d22c5e0cd25ecae7d2a01461d8a3995ac07303b5ec1ff59805e72c
BLAKE2b-256 checksum
How to use checksums
ccea0829c4c71a4cd6f0d14853a550bef66ea9e03ae454d9332cb8de2bf33f69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Security for dssatlab 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dssatlab-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

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