# omarmohamed15/scalodeep architecture

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

- Interactive diagram: https://gitdiagram.com/omarmohamed15/scalodeep
- Repository: https://github.com/omarmohamed15/scalodeep

## Overview

##### Project Type and Purpose
- SCALODEEP is an open-source scientific tool/framework (Python + Jupyter notebooks) for deep-learning–based real-time earthquake signal detection.
- It provides data‐preprocessing utilities, sliding‐window generators, model training/inference code, pretrained weights, and evaluation scripts.

##### High-Level Components
a. Data Layer
- Raw seismic data (Test40Hz.mseed)
- Preprocessed/packaged NumPy archives (Data.npz, SCALO.npz)
b. Configuration
- PreTrained_SCALODEEP.json (model architecture & hyperparameters)
- LayersWeights folder (per‐layer weight files in .npy/.npz)
c. Utilities
- SCALO_Utils.py (data loading, windowing, normalization)
- Jupyter notebooks for each pipeline stage:
– Overlapping/non-overlapping window generation
– Continuous data handling & label assignment
– Model evaluation & detection logging
d. Model Runtime
- Inference engine loading JSON + weight files → produces SCALODEEP_DETECTED.txt
e. External Interfaces
- Mega.nz download link for pretrained model
- Standard file system (local read/write of weights, outputs)

##### Relationships & Data Flow
1. Raw seismic stream (MSEED) is ingested by SCALO_Utils → transforms into numeric time windows → saved into Data.npz / SCALO.npz.
2. Jupyter notebooks reference these .npz datasets + JSON config → instantiate model architecture → load per-layer weights from LayersWeights.
3. Trained model processes new data windows → outputs detection events → writes SCALODEEP_DETECTED.txt.

##### Architectural Patterns & Principles
- Pipeline pattern: clear stages (Ingest → Preprocess → Model Construct → Inference → Output).
- Separation of concerns:
- Data I/O isolated in SCALO_Utils
- Model configuration (JSON) separated from weights (LayersWeights)
- Experiment orchestration via notebooks
- Modular extensibility: new preprocessing routines or model variants can be plugged in by updating SCALO_Utils and JSON.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    DS["Test40Hz.mseed<br/>(MSEED)"]:::data

    %% Preprocessing Module and Notebooks
    subgraph "Preprocessing Utilities"
        SU["SCALO_Utils.py<br/>(Python module)"]:::code
        NB1["SCALODEEP_ContinousData_NonOverlappingWindows.ipynb"]:::code
        NB2["SCALODEEP_ContinousData_OverlappingWindows_ReturingLabels_EvenTime.ipynb"]:::code
        NB3["SCALODEEP_GITHUT_Test_RUN.ipynb"]:::code
    end

    %% Preprocessed Data Artifacts
    DataNPZ["Data.npz<br/>(NumPy .npz)"]:::data
    SCALONpz["SCALO.npz<br/>(NumPy .npz)"]:::data

    %% Model Configuration & Weights
    Config["PreTrained_SCALODEEP.json<br/>(JSON config)"]:::data
    Weights["LayersWeights/<br/>(.npy/.npz)"]:::data

    %% Inference Engine
    IE["Inference Engine<br/>(Python Runtime)"]:::runtime

    %% Output Log
    Output["SCALODEEP_DETECTED.txt<br/>(Detection Log)"]:::data

    %% External Repository
    ExtRepo(("Mega.nz<br/>(External Cloud)")):::external

    %% Connections
    DS -->|".mseed → NumPy array"| SU
    SU -->|"save → Data.npz"| DataNPZ
    SU -->|"save → SCALO.npz"| SCALONpz

    DataNPZ -->|"+ Config + Weights →"| IE
    SCALONpz -->|"+ Config + Weights →"| IE
    Config -->|加载 JSON →| IE
    Weights -->|加载 权重 →| IE

    IE -->|".txt output"| Output

    ExtRepo -.->|download weights| Weights

    %% Notebook orchestrations (parallel)
    SU --> NB1
    SU --> NB2
    SU --> NB3
    NB1 --> DataNPZ
    NB2 --> DataNPZ
    NB3 --> Output

    %% Click Events
    click DS "https://github.com/omarmohamed15/scalodeep/blob/master/Test40Hz.mseed"
    click DataNPZ "https://github.com/omarmohamed15/scalodeep/blob/master/Data.npz"
    click SCALONpz "https://github.com/omarmohamed15/scalodeep/blob/master/SCALO.npz"
    click Config "https://github.com/omarmohamed15/scalodeep/blob/master/PreTrained_SCALODEEP.json"
    click Weights "https://github.com/omarmohamed15/scalodeep/tree/master/LayersWeights/"
    click SU "https://github.com/omarmohamed15/scalodeep/blob/master/SCALO_Utils.py"
    click NB1 "https://github.com/omarmohamed15/scalodeep/blob/master/SCALODEEP_ContinousData_NonOverlappingWindows.ipynb"
    click NB2 "https://github.com/omarmohamed15/scalodeep/blob/master/SCALODEEP_ContinousData_OverlappingWindows_ReturingLabels_EvenTime.ipynb"
    click NB3 "https://github.com/omarmohamed15/scalodeep/blob/master/SCALODEEP_GITHUT_Test_RUN.ipynb"
    click Output "https://github.com/omarmohamed15/scalodeep/blob/master/SCALODEEP_DETECTED.txt"

    %% Styles
    classDef data fill:#D6EAF8,stroke:#1F618D,color:#1B4F72
    classDef code fill:#D5F5E3,stroke:#28B463,color:#145A32
    classDef runtime fill:#FAD7A0,stroke:#D68910,color:#7E5109
    classDef external fill:#F4ECF7,stroke-dasharray: 5 5,stroke:#8E44AD,color:#512E5F
```
