Skip to main content

A Python toolkit for computing Soil Moisture Memory (SMM) based on drydown analysis and exponential decay fitting, as described in Farmani et al. (2025), Hydrology and Earth System Sciences.

Project description

🛰️ Soil Moisture Memory (SMM) Toolkit

TestPyPI PyPI License: MIT DOI

This repository provides a Python package for computing Soil Moisture Memory (SMM), as applied in the paper:

Farmani, M. A., Behrangi, A., Gupta, A., Tavakoly, A., Geheran, M.,
“Do land models miss key soil hydrological processes controlling soil moisture memory?”
Hydrology and Earth System Sciences (HESS), 29, 547–564, 2025.
https://doi.org/10.5194/hess-29-547-2025
© Author(s) 2025. This work is distributed under the Creative Commons Attribution 4.0 License.


🌿 Overview

The SMM Toolkit detects and analyzes soil moisture drydowns and computes short-term soil moisture memory timescales (Ts) from time series of soil moisture and precipitation.

Key features:

  • 📈 Automatic drydown detection
  • 🧪 Exponential curve fitting and R² filtering
  • 🕒 Short-term timescale (Ts) computation for positive increments
  • 📊 Plotting and result export
  • 🧰 YAML-based configuration for reproducible runs
  • ⚡ PyPI installable & CI tested

🧰 Installation

You can install the package directly from PyPI:

pip install smm-toolkit

Or from TestPyPI for development testing:

pip install -i https://test.pypi.org/simple/ smm-toolkit

🚀 Quick Start

import logging
from pathlib import Path
from smm.main import SMM
from smm.utils.logger import setup_logger

if __name__ == "__main__":
    setup_logger()
    config_path = Path("/path/to/config.yml")
    logging.info(f"Starting SMM analysis using config: {config_path}")
    SMM(config_path)

🧾 Example YAML Configuration

data:
  sm_file: "/path/to/SM.nc"
  prcp_file: "/path/to/precip_2019-01.nc"
  var_sm: "SM_Var_Name"
  var_prcp: "PREC_Var_Name"
  lat: 431          # can be index or actual coordinate
  lon: -111.2       # can be index or actual coordinate

parameters:
  thickness: 0.1
  threshold_factor: 0.12
  min_length: 3
  max_zeros: 0
  max_consecutive_positives: 1
  max_gap_days: 6
  r2_threshold: 0.8
  dim: "time"
  precip_length_unit: mm
  precip_time_unit: s
  sm_timestep: day

output:
  save_dir: "path/to/output"
  plot: true
  save_csv: true

🧪 Development Setup

git clone https://github.com/mfarmani95/SMM-Toolkit.git
cd SMM-Toolkit
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

For conda users:

conda env create -f environment.yml
conda activate smm-toolkit

🧰 Useful Makefile Commands

Command Description
make install Install package in editable mode
make dev Install dev dependencies
make test Run test suite with pytest
make format Auto-format code with Black
make lint Run static checks with Ruff
make build Build distribution package
make upload-test Upload to TestPyPI
make upload Upload to PyPI

📜 Citation

If you use this toolkit, please cite:

Farmani, M. A., Behrangi, A., Gupta, A., Tavakoly, A., Geheran, M. (2025).
Do land models miss key soil hydrological processes controlling soil moisture memory?
Hydrology and Earth System Sciences, 29, 547–564.
DOI: 10.5194/hess-29-547-2025


📜 License

This project is licensed under the MIT License.
© 2025 Mohammad A. Farmani.


💧 Acknowledgements

Developed as part of hydrologic research at the University of Arizona.
Inspired by the need for reproducible, transparent, and flexible soil moisture memory analysis tools for land–atmosphere interaction studies.

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

smm_toolkit-0.1.4.2.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

smm_toolkit-0.1.4.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file smm_toolkit-0.1.4.2.tar.gz.

File metadata

  • Download URL: smm_toolkit-0.1.4.2.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for smm_toolkit-0.1.4.2.tar.gz
Algorithm Hash digest
SHA256 8e887eb11987c5455b17ef09d451f08e12c324f30bd3d7ec837e0ac56b0aa3c5
MD5 2eb54902ba8d5aa22f5b6251d0e341b3
BLAKE2b-256 0f347371d53ae6d74a300718c19181d409787dcf1612c228546ce1b8ce4170c8

See more details on using hashes here.

File details

Details for the file smm_toolkit-0.1.4.2-py3-none-any.whl.

File metadata

  • Download URL: smm_toolkit-0.1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for smm_toolkit-0.1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cabc0d7d36eb09089cae4053cc92e9d4442db6e0693c004e47b098bb996cd101
MD5 453e2f8f705b8f0cacbd2839c02800be
BLAKE2b-256 a363e6245f04b49142212dd4dde0fbf6c084b947f70461b0d4457c14fedbacb3

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