# chrisswdavis/animaire-public architecture

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

- Interactive diagram: https://gitdiagram.com/chrisswdavis/animaire-public
- Repository: https://github.com/chrisswdavis/animaire-public

## Overview

##### Main Components and Architecture

The system should be represented as a layered architecture with the following main components:

a) User Interface Layer:
- Entry point through AniMAIRE.py
- Example notebooks (AniMAIRE_examples.ipynb)
- Plotting utilities (dose_plotting.py)

b) Core Processing Layer:
- Anisotropic MAIRE Engine
- Spectral Calculations Module
- Asymptotic Direction Processing

c) Data Layer:
- Response data files (NM64 responses)
- Cached magnetocosmics runs
- Investigation data

d) External Dependencies:
- MAGNETOCOSMICS (required external component)
- Python scientific stack (numpy, pandas, etc.)

##### Component Relationships

**[User Input] → [AniMAIRE Interface]**
- ↓
**[Anisotropic MAIRE Engine] ←→ [MAGNETOCOSMICS]**
- ↓                        ↓
**[Spectral Calculations] ←→ [Asymptotic Direction Processing]**
- ↓
**[Response Data] → [Dose Rate Calculations]**
- ↓
**[Output & Visualization]**

##### Detailed Component Specifications

a) AniMAIRE Interface:
- Input handlers for spectra, pitch angles, and coordinates
- Configuration management
- Run orchestration

b) Anisotropic MAIRE Engine:
- generalEngineInstance
- singleParticleEngineInstance
- Integration with MAGNETOCOSMICS

c) Spectral Calculations:
- Momenta Distribution
- Particle Distribution
- Pitch Angle Distribution
- Rigidity Spectrum

d) Data Processing:
- Response table handling
- Cache management
- Results formatting

##### Key Interactions to Highlight

- Data flow between MAGNETOCOSMICS and the core engine
- Caching mechanism for magnetocosmics runs
- Spectral calculation pipeline
- Response data integration
- Output generation and visualization flow

##### Implementation Notes

- Linux-only compatibility
- MAGNETOCOSMICS dependency requirement
- Caching behavior for performance optimization
- Supported input/output formats
- Key configuration parameters

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#9370DB,stroke:#333,stroke-width:2px
    classDef core fill:#4682B4,stroke:#333,stroke-width:2px
    classDef data fill:#3CB371,stroke:#333,stroke-width:2px
    classDef external fill:#FFA500,stroke:#333,stroke-width:2px
    classDef test fill:#B22222,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph UI
        Entry["AniMAIRE Interface"]:::ui
        Examples["Example Notebooks"]:::ui
        Plotting["Plotting Utilities"]:::ui
    end

    %% Core Processing Layer
    subgraph Core
        Engine["Anisotropic MAIRE Engine"]:::core
        GenEngine["General Engine Instance"]:::core
        SingleEngine["Single Particle Engine"]:::core
        Spectral["Spectral Calculations"]:::core
        Asymptotic["Asymptotic Direction Processing"]:::core
    end

    %% Data Layer
    subgraph Data
        Response["Response Data"]:::data
        NM64["NM64 Response Handler"]:::data
        Cache["Cached MAGNETOCOSMICS Runs"]:::data
        InvestData["Investigation Data"]:::data
    end

    %% External Dependencies
    MAGNETO["MAGNETOCOSMICS"]:::external
    SciStack["Scientific Python Stack"]:::external

    %% Testing Layer
    Tests["Test Suite"]:::test

    %% Relationships
    Entry --> Engine
    Entry --> Plotting
    Engine --> GenEngine
    Engine --> SingleEngine
    Engine <--> MAGNETO
    Engine --> Spectral
    Spectral <--> Asymptotic
    Spectral --> Response
    Response --> NM64
    MAGNETO --> Cache
    Tests --> Engine

    %% Click Events
    click Entry "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/AniMAIRE.py"
    click Examples "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE_examples.ipynb"
    click Plotting "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/dose_plotting.py"
    click Engine "https://github.com/ChrisSWDavis/AniMAIRE-public/tree/main/AniMAIRE/anisotropic_MAIRE_engine/"
    click GenEngine "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/anisotropic_MAIRE_engine/generalEngineInstance.py"
    click SingleEngine "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/anisotropic_MAIRE_engine/singleParticleEngineInstance.py"
    click Asymptotic "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/anisotropic_MAIRE_engine/AsymptoticDirectionProcessing.py"
    click Spectral "https://github.com/ChrisSWDavis/AniMAIRE-public/tree/main/AniMAIRE/anisotropic_MAIRE_engine/spectralCalculations/"
    click Response "https://github.com/ChrisSWDavis/AniMAIRE-public/tree/main/AniMAIRE/anisotropic_MAIRE_engine/data/"
    click NM64 "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/AniMAIRE/anisotropic_MAIRE_engine/data/NM64_responses.py"
    click InvestData "https://github.com/ChrisSWDavis/AniMAIRE-public/tree/main/notebooks_and_data_and_figures_for_paper/investigationData/"
    click Tests "https://github.com/ChrisSWDavis/AniMAIRE-public/blob/main/pytests/test_anisotropic_MAIRE.py"

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        Core_L["Core Processing"]:::core
        Data_L["Data Component"]:::data
        Ext_L["External Dependency"]:::external
        Test_L["Testing Component"]:::test
    end
```
