Skip to main content

Discrete Spatial Modeling framework for raster and vector simulations

Project description

DisSModel ๐ŸŒ

License: MIT Python 3.10+ PyPI version Coverage LambdaGeo JOSS Status

"Science should not need to be rewritten to go into production."
(A ciรชncia nรฃo deve ser reescrita para ir para a produรงรฃo.)


๐Ÿ“– Research Trajectory

DisSModel did not emerge from a blank slate. It is the current expression of a research agenda that began in 2001 with an undergraduate thesis on geographic data interoperability using XML and open standards โ€” a time when the central question was already forming:

How can geospatial models be built so that others can understand, reuse, and trust them?

Period Project Contribution to the Agenda
2001โ€“2002 Terra Translator (XML, ontologies) Foundation: geographic data needs semantics and open standards
2005 TerraHS (Haskell + GIS) Vision: scientific models as verifiable, executable artifacts
2007โ€“2010 TerraME / LuccME (INPE) Maturity: spatially explicit dynamic models as scientific objects
2015โ€“2024 DbCells, Linked Data, QGIS plugins Infrastructure: reproducibility demands rich metadata and federated access
2024โ€“2026 DisSModel (Python, FAIR, cloud-native) Synthesis: same code runs from Jupyter to distributed cluster

Three principles unite this trajectory:

  1. ๐Ÿ”“ Openness as method โ€” open source and open data as conditions for scientific validation.
  2. ๐Ÿงฉ Interoperability as architecture โ€” systems designed to communicate, avoiding silos.
  3. โ™ป๏ธ Reproducibility as requirement โ€” publishing conditions for re-execution, not just results.

DisSModel is the synthesis: a Python-native, FAIR-aligned, cloud-ready simulation framework where the same scientific code runs unchanged from a Jupyter notebook to a distributed production cluster.


๐ŸŽฏ About

DisSModel is a modular Python framework for spatially explicit dynamic simulation models. Developed by the LambdaGeo group at the Federal University of Maranhรฃo (UFMA), it provides the simulation layer that connects domain models (LUCC, coastal dynamics) to a reproducible execution environment.

INPE / TerraME Ecosystem LambdaGeo Ecosystem Role
TerraME dissmodel Generic framework for dynamic spatial modeling
LUCCME DisSLUCC LUCC domain models built on dissmodel
โ€” coastal-dynamics Coastal domain models built on dissmodel
TerraLib geopandas / rasterio Geographic data handling

๐ŸŒŸ Key Features

  • Dual substrate โ€” same model logic runs on vector (GeoDataFrame) and raster (RasterBackend/NumPy).
  • Lightweight scheduler โ€” pure-Python time-stepped engine; models auto-register at instantiation and receive clock ticks via setup / pre_execute / execute / post_execute lifecycle hooks.
  • Executor pattern โ€” strict separation between science (models) and infrastructure (I/O, CLI, reproducible execution).
  • Experiment tracking โ€” every run generates an immutable ExperimentRecord with SHA-256 checksums, TOML snapshot, and full provenance.
  • Storage-agnostic I/O โ€” dissmodel.io handles local paths and s3:// URIs transparently.
  • Cloud-ready โ€” deploy via Docker, FastAPI, and Redis without changing model code.

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Science Layer  (Model)                                  โ”‚
โ”‚  FloodModel, AllocationClueLike, MangroveModel, ...      โ”‚
โ”‚  โ†’ only knows math, geometry and time                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Infrastructure Layer  (ModelExecutor)                   โ”‚
โ”‚  CoastalRasterExecutor, LUCCVectorExecutor, ...          โ”‚
โ”‚  โ†’ only knows URIs, local/S3, column_map, parameters     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Core modules                                            โ”‚
โ”‚  dissmodel.core      โ€” Environment, Model, SpatialModel  โ”‚
โ”‚  dissmodel.geo       โ€” RasterBackend, neighborhoods      โ”‚
โ”‚  dissmodel.executor  โ€” ModelExecutor ABC, ExperimentRecordโ”‚
โ”‚  dissmodel.io        โ€” load_dataset / save_dataset       โ”‚
โ”‚  dissmodel.visualization โ€” Map, RasterMap, Chart         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

1. Install

pip install dissmodel

# Or latest development version
pip install "git+https://github.com/DisSModel/dissmodel.git@main"

2. Write a Model

# forest_fire_model.py
from dissmodel.core import Environment
from dissmodel.geo import SpatialModel, vector_grid

# 10x10 grid where every cell starts as forest
gdf = vector_grid(dimension=(10, 10), resolution=1.0, attrs={"state": "forest"})

class ForestFireModel(SpatialModel):
    def setup(self, prob_spread=0.3):
        self.prob_spread = prob_spread

    def execute(self):
        # Called every step โ€” only math here, no I/O
        burning = self.gdf["state"] == "burning"
        # ... apply spread logic ...

env = Environment(end_time=50)
ForestFireModel(gdf=gdf, prob_spread=0.4)
env.run()

3. Wrap an Executor (for CLI + Provenance)

# my_executor.py
from dissmodel.executor import ExperimentRecord, ModelExecutor
from dissmodel.executor.cli import run_cli
from dissmodel.io import load_dataset, save_dataset

class ForestFireExecutor(ModelExecutor):
    name = "forest_fire"

    def load(self, record: ExperimentRecord):
        gdf, checksum = load_dataset(record.source.uri)
        record.source.checksum = checksum
        return gdf

    def run(self, data, record: ExperimentRecord):
        from dissmodel.core import Environment
        env = Environment(end_time=record.parameters.get("end_time", 50))
        ForestFireModel(gdf=data, **record.parameters)
        env.run()
        return data

    def save(self, result, record: ExperimentRecord) -> ExperimentRecord:
        uri = record.output_path or "output.gpkg"
        checksum = save_dataset(result, uri)
        record.output_path = uri
        record.output_sha256 = checksum
        record.status = "completed"
        return record

if __name__ == "__main__":
    run_cli(ForestFireExecutor)

4. Run via CLI

# Execute a simulation
python my_executor.py run \
  --input data/forest.gpkg \
  --output data/result.gpkg \
  --param end_time=50 \
  --toml model.toml

# Validate data contract without running
python my_executor.py validate --input data/forest.gpkg

# Show resolved parameters
python my_executor.py show --toml model.toml

๐Ÿ“ฆ ExperimentRecord: Reproducibility by Design

Every run produces an immutable provenance record:

{
  "experiment_id": "abc123",
  "model_commit": "a3f9c12",
  "code_version": "0.5.0",
  "resolved_spec": { "...TOML snapshot..." },
  "source": { "uri": "s3://...", "checksum": "e3b0c44..." },
  "artifacts": { "output": "sha256...", "profiling": "sha256..." },
  "metrics": { "time_run_sec": 2.15, "time_total_sec": 2.34 },
  "status": "completed"
}

Reproduce any past experiment exactly:

curl -X POST http://localhost:8000/experiments/abc123/reproduce \
  -H "X-API-Key: chave-sergio"

๐Ÿ“Š Performance Telemetry

Every run via the executor lifecycle generates a profiling_{id}.md alongside the output:

Phase Time (s) % Total Memory Peak (MB) I/O Ops
Validate 0.000 0.0% 142 0
Load 0.306 14.7% 387 12 (read)
Run 1.025 49.4% 521 0
Save 0.746 35.9% 498 8 (write)
Total 2.077 100% 521 20

๐Ÿงฉ Ecosystem: Models & Examples

DisSModel is a core framework. To maintain a clean and specialized environment, all simulation models and implementation examples are hosted in separate repositories within the DisSModel ecosystem.

๐Ÿ”ฌ Specialized Model Libraries

Repository Description Install
dissmodel-ca Classic Cellular Automata (Game of Life, Forest Fire, Growth) pip install "git+https://github.com/DisSModel/dissmodel-ca.git"
dissmodel-sysdyn System Dynamics (SIR, Predator-Prey, Lorenz) pip install "git+https://github.com/DisSModel/dissmodel-sysdyn.git"
coastal-dynamics Coastal flooding and mangrove succession models pip install "git+https://github.com/DisSModel/coastal-dynamics.git"
disslucc-continuous Land Use and Cover Change models, continuous allocation (CLUE-inspired) pip install "git+https://github.com/DisSModel/disslucc-continuous.git"
disslucc-discrete Land Use and Cover Change models, discrete allocation (CLUE-inspired) pip install "git+https://github.com/DisSModel/disslucc-discrete.git"

๐Ÿ›  Implementation Templates

Each repository demonstrates how to:

  1. Define a Model: Using SpatialModel and Environment.
  2. Wrap an Executor: Using ModelExecutor for I/O and provenance.
  3. Deploy: Running via CLI or API.

๐Ÿ“š Documentation


๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guidelines and Code of Conduct before submitting a pull request.

  • ๐Ÿ› Report bugs โ†’ GitHub Issues
  • ๐Ÿ’ก Request features โ†’ GitHub Issues
  • ๐Ÿ“ Improve docs โ†’ Fork, edit, and submit a PR

๐ŸŽ“ Citation

@software{dissmodel2026,
  author = {Costa, Sรฉrgio Souza and Santos Junior, Nerval de Jesus and Sousa, Felipe Martins and Alves, Josรฉ Magno Pinheiro and Bezerra, Denilson da Silva},
  title = {DisSModel: A Python Framework for Spatially Explicit Dynamic Modeling},
  year = {2026},
  publisher = {LambdaGeo, Federal University of Maranhรฃo (UFMA)},
  url = {https://github.com/DisSModel/dissmodel},
  version = {0.6.0}
}

โš–๏ธ License

MIT ยฉ DisSModel โ€” UFMA
See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dissmodel-0.6.0.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dissmodel-0.6.0-py3-none-any.whl (76.1 kB view details)

Uploaded Python 3

File details

Details for the file dissmodel-0.6.0.tar.gz.

File metadata

  • Download URL: dissmodel-0.6.0.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dissmodel-0.6.0.tar.gz
Algorithm Hash digest
SHA256 45f940d15eeabab74fe8c53e1d2e50deefb1082af6a33c2a1796cda44d081cbf
MD5 5279ab80dfc1e91245ee070073a52a89
BLAKE2b-256 040c040f7e4ecdf05a31a9920a5246cbb362f618874734aad0ae47083b2c80b7

See more details on using hashes here.

File details

Details for the file dissmodel-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: dissmodel-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 76.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dissmodel-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af497a58e45269538eae90843fcd4360746e3c484edf5a6bc5e199aa7b12bebb
MD5 91a745b50abeaf7227fc2c6f3db3be8e
BLAKE2b-256 fb233b28eef03ffc478e0aec6be00c0cf69d8a5916f44c0251340c61ab0fda60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page