# mdebony/baccmod architecture

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

- Interactive diagram: https://gitdiagram.com/mdebony/baccmod
- Repository: https://github.com/mdebony/baccmod

## Overview

##### Main Components
a. Interface Layer (Top)
b. Core Processing Layer (Middle)
c. Data Management Layer (Bottom)

##### Component Details

a. Interface Layer:
- Two main acceptance map creator classes:
- RadialAcceptanceMapCreator
- Grid3DAcceptanceMapCreator
- To a common base class (BaseAcceptanceMapCreator)

b. Core Processing Layer:
- Following components:
- Modeling Component (modeling.py)
- Background Collection Handler (bkg_collection.py)
- Toolbox Utilities (toolbox.py)

c. Data Management Layer:
- External Dependencies:
- Gammapy
- Astropy
- Numpy/Scipy
- Regions

##### Data Flow and Interactions
- Input: Observation data → Acceptance Map Creators
- Processing: Through the core layer components
- Output: Background models in FITS format
- Zenith binning
- Interpolation
- OFF runs processing

##### Special Features to Highlight
- Basic acceptance map creation
- Run-wise normalization
- Zenith-binned modeling
- Zenith interpolation

##### Technical Details
- Annotations for key parameters:
- Energy axis configuration
- Offset axis settings
- Zenith binning parameters
- A note about telescope position requirements

##### Integration Points
- Integration with external systems:
- Input: DataStore from gammapy
- Output: FITS file format
- Pickle serialization for model storage

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef interface fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef core fill:#ffb366,stroke:#333,stroke-width:2px
    classDef data fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px
    classDef mode fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Interface Layer
    subgraph Interface
        BaseCreator["BaseAcceptanceMapCreator"]
        RadialCreator["RadialAcceptanceMapCreator"]
        Grid3DCreator["Grid3DAcceptanceMapCreator"]
    end

    %% Core Processing Layer
    subgraph Core
        Modeling["Modeling Component"]
        BkgHandler["Background Collection Handler"]
        Toolbox["Toolbox Utilities"]
        ErrorHandler["Error Handling"]
    end

    %% Data Management Layer
    subgraph External
        Gammapy["Gammapy"]
        Astropy["Astropy"]
        NumPy["NumPy/SciPy"]
        Regions["Regions"]
    end

    %% Processing Modes
    subgraph Modes
        Basic["Basic Acceptance"]
        RunWise["Run-wise Normalization"]
        ZenithBin["Zenith-binned Modeling"]
        ZenithInterp["Zenith Interpolation"]
    end

    %% Relationships
    BaseCreator --> RadialCreator
    BaseCreator --> Grid3DCreator
    RadialCreator --> Modeling
    Grid3DCreator --> Modeling
    Modeling --> BkgHandler
    BkgHandler --> Toolbox
    ErrorHandler --> BaseCreator

    %% External Dependencies
    Gammapy --> BaseCreator
    Astropy --> BaseCreator
    NumPy --> Modeling
    Regions --> Modeling

    %% Mode Connections
    Modeling --> Basic
    Modeling --> RunWise
    Modeling --> ZenithBin
    Modeling --> ZenithInterp

    %% Click Events
    click BaseCreator "https://github.com/mdebony/BAccMod/blob/main/baccmod/base_acceptance_map_creator.py"
    click RadialCreator "https://github.com/mdebony/BAccMod/blob/main/baccmod/radial_acceptance_map_creator.py"
    click Grid3DCreator "https://github.com/mdebony/BAccMod/blob/main/baccmod/grid3d_acceptance_map_creator.py"
    click Modeling "https://github.com/mdebony/BAccMod/blob/main/baccmod/modeling.py"
    click BkgHandler "https://github.com/mdebony/BAccMod/blob/main/baccmod/bkg_collection.py"
    click Toolbox "https://github.com/mdebony/BAccMod/blob/main/baccmod/toolbox.py"
    click ErrorHandler "https://github.com/mdebony/BAccMod/blob/main/baccmod/exception.py"

    %% Style Applications
    class BaseCreator,RadialCreator,Grid3DCreator interface
    class Modeling,BkgHandler,Toolbox,ErrorHandler core
    class Gammapy,Astropy,NumPy,Regions external
    class Basic,RunWise,ZenithBin,ZenithInterp mode
```
