# kativmak/cess architecture

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

- Interactive diagram: https://gitdiagram.com/kativmak/cess
- Repository: https://github.com/kativmak/cess

## Overview

Based on our analysis of the file tree and README, CESS is a specialized post‐processing module designed for FLASH simulation outputs. It calculates cooling emission in optical lines from supernova remnants using precomputed collisional data from MAPPINGS V (with the corresponding tables stored in the MV_tables directory). The module is composed of several scripts that form a clear pipeline—from generating a 3D emissivity cube to applying dust attenuation with tau.py and finally projecting results via a simple radiative transfer with rt.py.

##### Project Core and Purpose
- The project is focused on processing 3D simulation data (e.g., gas temperature from gas_temp.npy, density from gas_density.npy) to compute cooling emission in optical bands.
- It leverages precomputed cooling tables provided in MV_tables (grouped by different emission line types) to determine line intensities.
- There is an optional dust attenuation step (tau.py) and a radiative transfer projection (rt.py) to generate 2D flux maps.
- Its overall function is to calculate various optical line ratios and flux maps used for understanding supernova emission properties.

##### Main Components
a. Input Data:
- Uniform Grid Simulation Data: Represented by gas_temp.npy and gas_density.npy.
b. Lookup/Reference Data:
- MAPPINGS V Tables: The MV_tables directory with various subdirectories for different emission lines (e.g., ha_full, he2_solar, etc.), which act as reference tables for collisional data.
c. Processing Modules:
- Emission Calculation Module:
- emiss_3Dcube.py: Takes the simulation grid data and table values to compute the 3D cooling emission cube.
- Dust Attenuation Module (Optional):
- tau.py: Applies dust absorption calculations based on absorption cross-sections (from Draine 2003) to generate a tau cube.
- Radiative Transfer Module:
- rt.py: Projects the 3D emission (modified by dust attenuation if applicable) to generate 2D observable flux maps.

##### Relationships and Data Flow
- The emiss_3Dcube module uses the input grid along with the MAPPINGS V cooling tables to produce an emission cube.
- Optionally, the tau module operates on the emission cube output to apply dust attenuation.
- Finally, the rt module reads the adjusted emission cube and performs a projection (radiative transfer) to 2D maps.
- If applicable, loop.sh could be conceptualized as an orchestration layer that automates the sequence (data input → emiss_3Dcube → tau → rt).

##### Architectural Patterns and Design Principles
- Pipeline Architecture: The system is structured in sequential steps where each module performs a specific task and transfers its result to the next stage.
- Modularity: Each script (emiss_3Dcube.py, tau.py, rt.py) is decoupled, enabling flexible use of modules (e.g., applying tau only when dust effects are needed).
- Separation of Concerns: Data processing is separated into core emission, dust handling, and projection, with the MAPPINGS V cooling tables maintained separately.

##### Technologies and Dependencies
- Python scripts are the primary executable components.
- Data files (npy for grid data and text/dat files in MV_tables) form the input ecosystem.
- The build/automation script (loop.sh) might be used for orchestrating the pipeline.
- External references such as FLASH simulation outputs and the collisional data from MAPPINGS V are key contextual dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        A1("gas_temp.npy"):::data
        A2("gas_density.npy"):::data
        A3("MV_tables"):::data
    end

    %% Processing Modules
    subgraph "Processing Modules"
        B1("emiss_3Dcube.py"):::process
        B2("tau.py (Optional)"):::process
        B3("rt.py"):::process
    end

    %% Orchestration Layer
    subgraph "Orchestration"
        C1("loop.sh"):::orchestration
    end

    %% Data Flow Connections
    A1 -->|"input"| B1
    A2 -->|"input"| B1
    A3 -->|"lookup"| B1
    B1 -->|"emission cube"| B2
    B1 -->|"direct output"| B3
    B2 -->|"attenuated cube"| B3
    
    %% Orchestration arrows
    C1 -->|"triggers"| A1
    C1 -->|"triggers"| A2
    C1 -->|"triggers"| A3
    C1 -->|"orchestrates"| B1
    C1 -->|"orchestrates"| B2
    C1 -->|"orchestrates"| B3

    %% Click Events
    click A1 "https://github.com/kativmak/cess/blob/main/gas_temp.npy"
    click A2 "https://github.com/kativmak/cess/blob/main/gas_density.npy"
    click A3 "https://github.com/kativmak/cess/tree/main/MV_tables"
    click B1 "https://github.com/kativmak/cess/blob/main/emiss_3Dcube.py"
    click B2 "https://github.com/kativmak/cess/blob/main/tau.py"
    click B3 "https://github.com/kativmak/cess/blob/main/rt.py"
    click C1 "https://github.com/kativmak/cess/blob/main/loop.sh"

    %% Styles
    classDef data fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef process fill:#b2df8a,stroke:#33a02c,stroke-width:2px;
    classDef orchestration fill:#fdbf6f,stroke:#ff7f00,stroke-width:2px;
```
