Skip to main content

Add a short description here!

Project description

ReadTheDocs PyPI-Server Binder Project generated with PyScaffold

SMADI

Soil Moisture Anomaly Detection Indicators

SMADI is a workflow designed to compute climate normals and detect anomalies for satellite soil moisture data, with a primary focus on ASCAT surface soil moisture (SSM) products. The climatology, or climate normals, is computed to establish the distribution of SSM for each period and location. Subsequently, anomalies are computed accordingly.

The core objective of SMADI is to leverage these anomaly indicators to identify and highlight extreme events such as droughts and floods, providing valuable insights for environmental monitoring and management. Additionally, SMADI is applicable to various meteorological variables.

Germany SM Anomaly Maps July 2021

Germany SM Anomaly Maps July 2021

Installation

User Installation

For users who simply want to use smadi, you can install it via pip:

pip install smadi

Developer Installation

If you’re a developer or contributor, follow these steps to set up smadi:

  1. Clone the repository:

git clone https://github.com/MuhammedM294/smadi
  1. Navigate to the cloned directory:

cd smadi
  1. Create and activate a virtual environment using Conda or virtualenv:

For Conda:

conda create --name smadi_env python=3.8
conda activate smadi_env

For virtualenv:

virtualenv smadi_env
source smadi_env/bin/activate  # On Unix or MacOS
.\smadi_env\Scripts\activate    # On Windows
  1. Install dependencies from requirements.txt:

pip install -r requirements.txt

Usage

Here are some basic examples to demonstrate how to use smadi:

For Single Point

  1. Import the package:

from smadi.data_reader import read_grid_point
  1. Load your ASCAT data:

data_path = "path/to/data"

loc = (lon,lat)

data = read_grid_point(loc=loc, ascat_sm_path=data_path, read_bulk=False)

ascat_ts = data.get("ascat_ts")

# Filter the time series to get only the soil moisture data
sm_ts = ascat_ts.get("sm")
  1. Compute the climatology

from smadi.climatology import Climatology

# Create a climatology object
cl = Climatology(df=ascat_ts, variable="sm")

# Set the time step for computing the climatology
cl.time_step = "month"  # Supported time steps are "month", "bimonth", "dekad","week", "day"


cl_df = cl.compute_normals()

# Set mutiple metrics for computing the climatology
cl.normal_metrics = ["mean", "median", "min", "max"]  # Default is ['mean']

cl_df = cl.compute_normals()
  1. Compute Anomalies

from smadi.anomaly_detectors import (
 ZScore,
 SMAPI,
 SMDI,
 SMCA,
 SMAD,
 SMCI,
 SMDS,
 ESSMI,
 ParaDis,
 AbsoluteAnomaly)


# Zscore Usage Example
zscore = ZScore( df=ascat_ts,
 variable="sm",
 fillna=True,
 fillna_window_size=3,
 smoothing=True,
 smooth_window_size=31,
 time_step="month",
)
anomaly_df = zscore.detect_anomaly()



# SMAPI Usage Example
   smapi = SMAPI(
    df=ascat_ts,
    variable="sm",
    fillna=True,
    fillna_window_size=3,
    smoothing=True,
    smooth_window_size=31,
    time_step="month",
    normal_metrics=["mean", "median"],
   )

   anomaly_df = smapi.detect_anomaly()

For Country Scale Computation

To apply the workflow on a country scale, utilize the ‘run’ command specifying either the country name or bounding box (bbox) to set the area of interest (AOI) using coordinates (minlon, maxlon, minlat, maxlat). For more information on the available arguments, you can run run -h command.

# Run the workflow for a country
run "path/to/data" \
    "country_name" \
    "time_step" \
     --year <> \
     --month <>  \
     --method <>  \
     --save_to <>

# Run the workflow for bbox
run "path/to/data"\
    "minlon, maxlon, minlat, maxlat"\
    "time_step" \
    --year <> \
    --month <>  \
    --method <>  \
    --save_to <>
Note

This project has been set up using PyScaffold 4.5. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

smadi-0.2.8.tar.gz (162.8 kB view hashes)

Uploaded Source

Built Distribution

smadi-0.2.8-py3-none-any.whl (26.7 kB view hashes)

Uploaded Python 3

Supported by

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