# shengfu2022/swade architecture

> Architecture diagram of the GitHub repository shengfu2022/swade, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shengfu2022/swade
- Repository: https://github.com/shengfu2022/swade

## Overview

##### Main Components
- Data Acquisition/Preparation:
- “DownloadNDVIFromGEETranslatedFromAxelCode.ipynb” as an optional module that downloads the NDVI training data.
- That the README recommends running the “CodeShengFu2022Landslides” folder, which contains all the processing code.
- Data Processing:
- b_read_Act_Axel_Lr.py: Likely responsible for reading and preparing the data from the input files.
- c_deno_wave.py: Implements the denoising stage using wavelet techniques.
- d_step_wise.py: Performs the stepwise linear fitting as part of the landslide dating technique.
- SWADE.py: This appears to be the central script that ties together the above modules to run the overall SWADE workflow.
- Output Generation:
- The final stage produces a figure (as indicated in the README) which is saved, most likely to an "output" subfolder (even if not shown in the file tree explicitly).

##### Relationships and Interactions
- Data flows from the acquisition module into the data reader (b_read_Act_Axel_Lr.py), which preps the raw NDVI time series.
- The preprocessed data is then sent to the denoising component (c_deno_wave.py), where wavelet-based noise reduction refines the signal.
- Next, the denoised data enters the stepwise linear fitting stage (d_step_wise.py) to detect changes associated with landslide events.
- Finally, the SWADE.py script functions as the orchestrator, calling each of these components sequentially and managing input/output processes.

##### Architectural Patterns and Design Principles
- Modular Design: Each script addresses a specific part of the workflow (data reading, denoising, fitting), supporting code separation and easier maintenance or upgrades.
- Pipeline Structure: The overall flow represents a data processing pipeline where each stage receives input, processes it, and passes results downstream.
- Reusability and Extensibility: With clearly delineated stages (and an optional NDVI download module), the system is designed for future adaptations or incorporating additional preprocessing steps.

##### Incorporate Relevant Technologies
- Python is the main programming language.
- Jupyter Notebook (for the NDVI download) and standard Python modules for data processing.
- Likely libraries include numpy, pandas, matplotlib (for plotting the results), and potentially pywavelets or similar for the denoising algorithms—although not explicitly stated, these are common choices in such contexts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Acquisition"
        NDVI["NDVI Acquisition (Notebook)"]:::external
    end

    subgraph "Data Processing"
        Reader["Data Reader/Preprocessor (b_read_Act_Axel_Lr.py)"]:::processor
        Denoising["Wavelet Denoising (c_deno_wave.py)"]:::processor
        Fitting["Stepwise Linear Fitting (d_step_wise.py)"]:::processor
    end

    subgraph "Orchestration & Output"
        Orchestrator["Orchestrator & Output Generator (SWADE.py)"]:::orchestrator
        Output["Generated Figure"]:::output
    end

    NDVI -->|"RawNDVITimeSeries"| Reader
    Reader -->|"PreprocessedData"| Denoising
    Denoising -->|"DenoisedSignal"| Fitting
    Fitting -->|"FittingResults"| Orchestrator
    Orchestrator -->|"ProducesOutput"| Output

    click NDVI "https://github.com/shengfu2022/swade/blob/main/DownloadNDVIFromGEETranslatedFromAxelCode.ipynb"
    click Reader "https://github.com/shengfu2022/swade/blob/main/b_read_Act_Axel_Lr.py"
    click Denoising "https://github.com/shengfu2022/swade/blob/main/c_deno_wave.py"
    click Fitting "https://github.com/shengfu2022/swade/blob/main/d_step_wise.py"
    click Orchestrator "https://github.com/shengfu2022/swade/blob/main/SWADE.py"

    classDef external fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef processor fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef orchestrator fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef output fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
