# gseg-ethz/insituradi architecture

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

- Interactive diagram: https://gitdiagram.com/gseg-ethz/insituradi
- Repository: https://github.com/gseg-ethz/insituradi

## Overview

##### Main Components and Their Roles
- CLI / Entry Point: The module’s __main__.py (located in src/InsituRadi) acts as the starting point for the application. It accepts a project folder (containing the subfolder “input_files” with TLS point cloud data) via command-line arguments.
- Configuration Manager: The config.py file deals with reading and managing parameters for calibration. This is essential for setting up the process and may include parameters like scan settings and instrument characteristics.
- Core Processing Pipeline: The core.py module orchestrates the entire workflow. It pulls together inputs, configuration settings, and the various processing functions.
- Radiometric Compensation Engine: This is spread between radiometric_compensation.py and radiometric_models.py. They contain the algorithms for estimating measurement-configuration independent intensities (I_MCI) and applying necessary corrections.
- Data Handling and Abstraction: The radiometric_data.py module defines data structures to represent and store the TLS intensity data, while tls_pcd.py likely handles the reading and writing of TLS point cloud (PCD) files.
- External Integration: The cloudcompare_commands.py module indicates integration with CloudCompare (a third-party tool) to run or interface with external point cloud processing utilities.
- Utility Functions: The utils.py module provides supporting functions that are used across the other modules.

##### Relationships and Interactions
- The CLI layer accepts user parameters, then hands control over to the core processing module.
- The core module loads the configuration (via config.py), fetches input point clouds (possibly using tls_pcd.py), and uses the radiometric_data structures to encapsulate the measurement data.
- The radiometric compensation engine (radiometric_compensation.py and radiometric_models.py) is tasked with applying the calibration algorithm to the data.
- When required, the tool calls external commands through cloudcompare_commands.py to either invoke CloudCompare operations or further process point clouds.
- Utility functions (from utils.py) supplement these steps by handling common tasks.

##### Architectural Patterns and Design Principles
- Modular Design: The clear separation of configuration, core processing, compensation algorithms, data I/O, and external command integration reflects a modular architecture.
- Command-Line Driven: With a __main__.py entry point, the design leverages standard CLI application patterns.
- Extensibility: The separation of radiometric models and compensation logic allows for future adjustments or additions to the calibration algorithms.

##### Final Advice to the Principal Software Engineer
- Avoid oversimplification—more components (even if they’re small utility modules) should be added to capture the intent of the overall structure.
- Annotations on key processing steps, such as input reading, calibration algorithm execution, and external command invocation.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Input & Entry Layer"
        CLI["CLI / Entry Point (src/InsituRadi/__main__.py)"]:::entry
        Input["Input Files (input_files folder)"]:::input
    end

    subgraph "Processing Layer"
        Core["Core Processing Pipeline (src/InsituRadi/core.py)"]:::core
    end

    subgraph "Submodules"
        Config["Configuration Manager (config.py)"]:::config
        subgraph "Radiometric Compensation Engine"
            Comp1["Radiometric Compensation (radiometric_compensation.py)"]:::compensation
            Comp2["Radiometric Models (radiometric_models.py)"]:::compensation
        end
        subgraph "Data Handling & Abstraction"
            Data1["Radiometric Data (radiometric_data.py)"]:::data
            Data2["TLS PCD Handler (tls_pcd.py)"]:::data
        end
        Integration["External Integration (cloudcompare_commands.py)"]:::integration
        Utils["Utility Functions (utils.py)"]:::utils
    end

    Output["Calibrated TLS Output"]:::output

    CLI --> Core
    Input --> Core
    Core --> Config
    Core --> Comp1
    Core --> Comp2
    Core --> Data1
    Core --> Data2
    Core --> Integration
    Core --> Utils
    Core --> Output

click CLI "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/__main__.py"
click Config "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/config.py"
click Core "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/core.py"
click Comp1 "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/radiometric_compensation.py"
click Comp2 "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/radiometric_models.py"
click Data1 "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/radiometric_data.py"
click Data2 "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/tls_pcd.py"
click Integration "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/cloudcompare_commands.py"
click Utils "https://github.com/gseg-ethz/insituradi/blob/main/src/InsituRadi/utils.py"

classDef entry fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
classDef input fill:#ffe599,stroke:#bf9000,stroke-width:2px;
classDef core fill:#d9ead3,stroke:#6aa84f,stroke-width:2px;
classDef config fill:#c9daf8,stroke:#1155cc,stroke-width:2px;
classDef compensation fill:#fff2cc,stroke:#d6b656,stroke-width:2px;
classDef data fill:#d0e0e3,stroke:#1f648b,stroke-width:2px;
classDef integration fill:#ead1dc,stroke:#b85498,stroke-width:2px;
classDef utils fill:#fce5cd,stroke:#e69138,stroke-width:2px;
classDef output fill:#d9d2e9,stroke:#9c27b0,stroke-width:2px;
```
