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.
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 and soil 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
- Turn your own soil data 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
DSSATRunErrorwith the command, the end of DSSAT's console output and the start ofERROR.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 and soil data
Put your daily weather in the fixed weather template, and optionally your soil profile in the soil template, then create a Simulation for one treatment of an existing FileX:
import dssatlab as dl
dl.write_weather_template("weather.csv") # a correct weather example
dl.write_soil_template("soil.csv") # a valid 3-layer soil profile
sim = dl.Simulation(
"UFGA8201.MZX",
treatment=1,
weather="weather.csv",
soil="soil.csv",
)
problems = sim.check() # every problem at once, nothing is written; [] means fine
result = sim.run() # checks first, then writes files and runs DSSAT
The templates are comma-separated UTF-8 CSVs with exact lower-case column names, in any order. Values are in DSSAT's own units and nothing is converted:
- Weather template:
station,latitude,longitude,elevation,date(YYYY-MM-DD),srad,tmax,tmin,rain, and optionaltav,amp,refht,wndht(default -99). Station and coordinates repeat on every row; one row per calendar day without gaps or duplicates. - Soil template: one soil profile, one row per layer. Required profile columns:
soil_id(1 to 10 ASCII characters matching the FileXID_SOIL),salb,slro,sldr,slpf. Required layer columns:slb(cm, strictly increasing),slll,sdul,ssat(strictlyslll < sdul < ssat),srgf. Optional columns (slnf,ssks,sbdm,sloc, etc.) default to -99. Profile values repeat identically on every row.
Inputs can be given as a CSV path, a list of dicts with the same keys, or 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 or depths, gaps, impossible values (e.g.tmax < tmin, negative rain, non-increasing depths, water limits out of order), and mismatches with the FileX (station code, start date coverage, case-sensitivesoil_idmatch). Nothing is fixed or filled in automatically.run()raises oneDSSATCheckErrorlisting all problems if there are any, before writing anything.- Otherwise
run()makes a newdssat_sim_<date>folder beside your FileX. Withsoil, it writesSOIL.SOLand does not copy sibling.SOLfiles (a local.SOLbeats DSSAT's own Soil folder);.CUL,.ECO, and.SPEfiles are copied as before. Withoutsoil, sibling.SOLfiles are copied. The generated weather file is written to the simulation folder, DSSAT runs there, and output files are collected into adssat_run_<date>folder inside it. Your original files are not changed. - If DSSAT cannot use the soil profile, it exits with return code 99 and
run()raisesDSSATRunErrorwith theERROR.OUTmessage. - DSSAT does not fail when weather is missing: it exits normally and gives -99 results. After the run,
run()looks for DSSAT's "weather record not found" warning and raisesDSSATRunErrornaming the first missing date.
Not built yet: management data, unit converters, reading DSSAT's output files, choosing a soil profile from DSSAT's own soil files, and more than one treatment per Simulation.
Metadata
Release files for dssatlab 0.3.1
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 | Actions |
|---|---|---|---|---|
| dssatlab-0.3.1.tar.gz | 54.5 kB | With provenance | Details for dssatlab-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dssatlab-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for dssatlab-0.3.1-py3-none-any.whl |
Total release size: 83.1 kB
Release files / dssatlab-0.3.1.tar.gz
| Download URL | dssatlab-0.3.1.tar.gz |
|---|---|
| Size | 54.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b105aac5def5f3e03358bb4c56157db5abb7c5666fcbbfbdf010a7599e91461a
|
|
BLAKE2b-256 checksum How to use checksums |
2b18ea8437695472fc2760adb868bb45cb14214d60e63f12a04a3229ba539b1b
|
| 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 logRelease files / dssatlab-0.3.1-py3-none-any.whl
| Download URL | dssatlab-0.3.1-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4999016c572e59d39a41cae7d6672f7948fccb153089bc4927573f6c15724ad7
|
|
BLAKE2b-256 checksum How to use checksums |
ecf455feca275c262b60d4df37522de1d3a3ac5de371b86b6017be8f31a5df2d
|
| 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 logSecurity for dssatlab 0.3.1
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.
Attestation for dssatlab-0.3.1.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 logA 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.