Skip to main content

Discrete Spatial Modeling framework for raster and vector simulations

Project description

DisSModel ๐ŸŒ

License: MIT Python 3.10+ PyPI version 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, SpatialModel

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 dissmodel-ca
DisSModel-SysDyn System Dynamics (SIR, Predator-Prey, Lorenz) pip install dissmodel-sysdyn
coastal-dynamics Coastal flooding and mangrove succession models pip install coastal-dynamics
DisSLUCC Land Use and Cover Change models (CLUE-inspired) pip install disslucc

๐Ÿ›  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 Discussions
  • ๐Ÿ“ Improve docs โ†’ Fork, edit, and submit a PR

๐ŸŽ“ Citation

@software{dissmodel2026,
  author = {Costa, Sรฉrgio and Santos Junior, Nerval},
  title = {DisSModel: A Discrete Spatial Modeling Framework for Python},
  year = {2026},
  publisher = {LambdaGeo, Federal University of Maranhรฃo (UFMA)},
  url = {https://github.com/DisSModel/dissmodel},
  version = {0.5.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.5.0.tar.gz (60.2 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.5.0-py3-none-any.whl (72.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dissmodel-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e1ddfbb6e30353173f025d411b8592c89da8148163da900b30ec76e8dff2999e
MD5 e2827a93575ec8f2f8570a8356027126
BLAKE2b-256 7448321211fc0c3811fc30b8d4f931bb5481ad8d5b67f31eee6852c34882657b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dissmodel-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 72.4 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f72affd3eaae53835dcc6a7b4500c98e60d79f7171fd444aaf11472358ad353f
MD5 91f6f67ced40af383e70020030b292f3
BLAKE2b-256 70524119c155d07ee36d313f13165fc100714959fe041c17d13bdafc1bc20f6c

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