# yumorishita/licsbas2 architecture

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

- Interactive diagram: https://gitdiagram.com/yumorishita/licsbas2
- Repository: https://github.com/yumorishita/licsbas2

## Overview

##### Project type and purpose
- LiCSBAS2 is a research‐oriented, open-source command-line package (Python + bash) for InSAR time-series analysis, ingesting unwrapped interferograms and coherence maps from the COMET-LiCS portal and producing displacement time series, velocities, and visualizations.

##### File structure
- bin/ : top-level CLI entrypoints – one script per processing step (01_get_geotiff.py → 16_filt_ts.py, plus utility scripts).
- LiCSBAS_lib/ : core Python libraries organized by functionality:
- LiCSBAS_io_lib.py – data I/O (reading GeoTIFFs, metadata).
- LiCSBAS_loop_lib.py – loop closure routines.
- LiCSBAS_inv_lib.py – inversion algorithms (SB, least‐squares).
- LiCSBAS_plot_lib.py – plotting (time series, velocity maps).
- LiCSBAS_tools_lib.py – utility routines (masking, reprojection).
- colormap subfolders (GMT/, SCM/, cmocean/, colorcet/) – static colormap definitions.
- shell scripts to extract colormaps.
- Configuration: LiCSBAS_requirements.txt (dependencies), bashrc_LiCSBAS.sh & batch scripts.

##### README for additional insights
- Confirms pipeline‐style workflow: download (01), prep (02), apply corrections (03-05), QC (11), inversion (12-13), postprocessing (14-16), plotting.
- Mentions use of external tools/standards: GMT colormaps, ScientificColourMaps, Python imaging libs.

a. Main components
1. User CLI layer (bin/*.py & bash wrappers)
2. Core Python libraries (LiCSBAS_lib)
3. Static resources (colormap packages under LiCSBAS_lib)
4. External data source (COMET-LiCS Portal / Sentinel‐1 products)
5. External dependencies (Python runtime & packages, GMT, bash)
6. Output artifacts (GeoTIFFs, time series plots, velocity fields)
b. Relationships & interactions
- Subsequent pipeline scripts invoke LiCSBAS_io_lib, LiCSBAS_tools_lib, LiCSBAS_loop_lib, LiCSBAS_inv_lib in sequence.
- Plotting scripts call LiCSBAS_plot_lib + colormap modules to render outputs.
- All scripts run under the bashrc_LiCSBAS environment.
c. Architectural patterns / principles
- Modular pipeline pattern: each step is a thin wrapper around core libs.
- Layered separation: CLI layer, library layer, resource layer.
- Reuse of external static resources (colormaps).
d. Key technologies & libraries
- Python 3.x, NumPy, SciPy, matplotlib, rasterio (implied by GeoTIFF I/O).
- GMT colormaps, ScientificColourMaps (SCM), cmocean, colorcet.
- Bash environment and shell scripting.

##### Final advice
- Be highly detailed: break out each major library module, each pipeline stage.
- Essential flows: data ingestion, processing loops, inversion, visualization.
- Use annotations to note configuration points (requirements file, bashrc).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    ExternalData["COMET-LiCS Portal / Sentinel-1"]:::external
    Dependencies["Dependencies\n(Python, GMT, Bash)"]:::external

    %% CLI Layer
    CLI["User CLI (bin/)"]:::runtime

    %% Core Libraries
    subgraph "Core Libs" 
        IO["LiCSBAS_io_lib.py"]:::runtime
        Loop["LiCSBAS_loop_lib.py"]:::runtime
        Inv["LiCSBAS_inv_lib.py"]:::runtime
        Plot["LiCSBAS_plot_lib.py"]:::runtime
        Tools["LiCSBAS_tools_lib.py"]:::runtime
    end

    %% Colormap Resources
    subgraph "Colormap Resources" 
        GMT["GMT/"]:::resource
        SCM["SCM/"]:::resource
        CMO["cmocean/"]:::resource
        CC["colorcet/"]:::resource
        ExtractGMT["extract_cmaps_GMT.sh"]:::resource
        ExtractSCM["extract_cmaps_SCM.sh"]:::resource
    end

    %% Configuration & Ancillary
    Config["Configuration\n(requirements, bashrc, batch)"]:::optional
    Ancillary["Ancillary Files\n(QGIS XML, README, LICENSE, YML)"]:::optional

    %% Outputs
    Outputs["Outputs\n(GeoTIFFs, Time Series Plots, Velocity Maps)"]:::runtime

    %% Flows
    ExternalData -->|ingest| CLI
    CLI -->|"calls I/O"| IO
    CLI -->|uses tools| Tools
    CLI -->|runs loops| Loop
    CLI -->|runs inversion| Inv
    CLI -->|renders plots| Plot
    Plot -->|loads colormaps| GMT
    Plot -->|loads colormaps| SCM
    Plot -->|loads colormaps| CMO
    Plot -->|loads colormaps| CC
    CLI & CoreLibs --> Dependencies
    CLI --> Outputs
    IO --> Outputs
    Config -.-> CLI
    Config -.-> CoreLibs
    Ancillary -.-> CoreLibs

    %% Click Events
    click CLI "https://github.com/yumorishita/licsbas2/tree/master/bin/"
    click IO "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/LiCSBAS_io_lib.py"
    click Loop "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/LiCSBAS_loop_lib.py"
    click Inv "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/LiCSBAS_inv_lib.py"
    click Plot "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/LiCSBAS_plot_lib.py"
    click Tools "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/LiCSBAS_tools_lib.py"
    click GMT "https://github.com/yumorishita/licsbas2/tree/master/LiCSBAS_lib/GMT/"
    click SCM "https://github.com/yumorishita/licsbas2/tree/master/LiCSBAS_lib/SCM/"
    click CMO "https://github.com/yumorishita/licsbas2/tree/master/LiCSBAS_lib/cmocean/"
    click CC "https://github.com/yumorishita/licsbas2/tree/master/LiCSBAS_lib/colorcet/"
    click ExtractGMT "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/extract_cmaps_GMT.sh"
    click ExtractSCM "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_lib/extract_cmaps_SCM.sh"
    click Config "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS_requirements.txt"
    click Config "https://github.com/yumorishita/licsbas2/blob/master/bashrc_LiCSBAS.sh"
    click Config "https://github.com/yumorishita/licsbas2/blob/master/batch_LiCSBAS.sh"
    click Ancillary "https://github.com/yumorishita/licsbas2/blob/master/cm_insar_qgis.xml"
    click Ancillary "https://github.com/yumorishita/licsbas2/blob/master/README.md"
    click Ancillary "https://github.com/yumorishita/licsbas2/tree/master/LICENSE"
    click Ancillary "https://github.com/yumorishita/licsbas2/blob/master/LiCSBAS.yml"

    %% Styles
    classDef external fill:#a8d5e2,stroke:#333,stroke-width:1px
    classDef runtime fill:#b3cde3,stroke:#333,stroke-width:1px
    classDef resource fill:#fdae61,stroke:#333,stroke-width:1px
    classDef optional stroke-dasharray: 5 5,fill:#fff,stroke:#777,stroke-width:1px
```
