# amase-project/amasedrp architecture

> Architecture diagram of the GitHub repository amase-project/amasedrp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amase-project/amasedrp
- Repository: https://github.com/amase-project/amasedrp

## Overview

1. **Repository purpose**
   - `amasedrp` is a Python data-reduction pipeline package, likely for astronomical/CCD or CMOS imaging and spectroscopy, given the presence of bias/dark calibration, bad pixel maps, and ThAr line-list data.
   - The architecture is centered on reusable reduction modules plus a script entrypoint that runs a configured pipeline.

2. **Top-level package layout**
   - The main code lives under `amasedrp/`, split into:
     - `reduction/` for processing stages
     - `utils/` for shared support code
     - `script/` for command-line execution
     - `data/` for bundled reference assets
     - `example/` for sample pipeline configuration and output artifacts

3. **Pipeline orchestration boundary**
   - `amasedrp/script/run_drp.py` is the likely execution entrypoint.
   - The YAML files in `amasedrp/example/` (`ImgPipeline.yml`, `ImgPipeline_quick.yml`) suggest the pipeline is configuration-driven, with the script reading a config to decide which reduction steps to run.
   - This is the clearest boundary between user-facing invocation and the internal processing modules.

4. **Image calibration subsystem**
   - `amasedrp/reduction/ImgCal/` contains image calibration logic.
   - `MakeMasterBias.py` and `MakeMasterDark.py` indicate creation of master calibration frames from raw inputs.
   - `preprocessing.py` likely handles frame-level preparation such as masking, subtraction, correction, or normalization before higher-level reduction.
   - This subsystem is focused on image-domain calibration rather than spectral extraction.

5. **Spectral calibration subsystem**
   - `amasedrp/reduction/SpecCal/` exists as a separate reduction area, indicating a second major branch for spectroscopy-related processing.
   - The tree does not show implementation files here, so the package boundary is present even if the detailed stages are not visible in the listing.
   - For an architecture diagram, this should be shown as a distinct downstream branch from the main reduction pipeline.

6. **Shared data abstractions**
   - `amasedrp/utils/CMOSData/CMOSData.py` likely provides a core data model or helper class for sensor/image data handling.
   - This appears to be a shared utility layer used by calibration and reduction modules rather than a standalone pipeline stage.
   - If diagramming boundaries, place this beneath the reduction modules as a common data/service abstraction.

7. **Logging and operational support**
   - `amasedrp/utils/log.py` provides logging utilities.
   - This is an operational cross-cutting concern used across pipeline stages to track progress, errors, and outputs.
   - It is likely consumed by the script entrypoint and the calibration/reduction modules.

8. **Bundled reference assets**
   - `amasedrp/data/ThAr.list` is a spectral reference line list, typically used in wavelength calibration.
   - `amasedrp/data/bad_pixel_map.fits` is a sensor-quality mask/reference file used during image cleanup or preprocessing.
   - These are static inputs that support reduction logic and should be drawn as read-only reference data feeding into the pipeline.

9. **Example configuration and expected outputs**
   - `amasedrp/example/stats.tab` appears to be sample output or diagnostic statistics.
   - The example YAML files show how to configure the reduction run, and the tabular file suggests the pipeline emits summary stats or QC artifacts.
   - This folder is useful for understanding the runtime contract: config in, calibrated products and statistics out.

10. **Package initialization and modularity**
   - Each package/subpackage has `__init__.py`, so the code is organized as importable Python modules.
   - `setup.config` indicates packaging/build configuration, implying the project is meant to be installed as a Python package and run as a scriptable tool.

11. **Likely data flow**
   - Raw sensor frames enter via the run script and pipeline config.
   - Image calibration stages use reference data such as the bad pixel map and generate master calibration frames.
   - Preprocessed frames then flow into image or spectral reduction paths.
   - Spectral calibration likely consumes processed science frames and reference line data such as `ThAr.list`.
   - Diagnostics/statistics are emitted alongside or after the main reduced products.

12. **Architectural boundaries to emphasize**
   - There is a clear separation between:
     - orchestration (`script/`)
     - processing logic (`reduction/`)
     - shared utilities (`utils/`)
     - static reference data (`data/`)
     - sample configs and outputs (`example/`)
   - This is a good basis for an architecture diagram showing a configuration-driven pipeline with shared utilities and external reference inputs.

13. **What is not evident from the tree**
   - No web layer, database, message queue, or cloud service integration is visible.
   - The project appears to be a local/offline scientific processing package rather than a service-oriented application.
   - Any diagram should stay focused on file-based inputs/outputs and Python module boundaries.

Main entry points: [`amasedrp/script/run_drp.py`](https://github.com/amase-project/amasedrp/blob/main/amasedrp/script/run_drp.py) (Run DRP), [`amasedrp/reduction/ImgCal`](https://github.com/amase-project/amasedrp/tree/main/amasedrp/reduction/ImgCal) (Image Cal), [`amasedrp/reduction/ImgCal/preprocessing.py`](https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/preprocessing.py) (Preprocess), [`amasedrp/utils/CMOSData/CMOSData.py`](https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/CMOSData/CMOSData.py) (CMOS Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_orchestration["Orchestration"]
  node_node_run_drp["Run DRP<br/>entrypoint<br/>[run_drp.py]"]
  node_node_script_pkg["Script Pkg"]
end

subgraph group_group_reduction["Reduction"]
  node_node_imgcal["Image Cal<br/>subsystem"]
  node_node_make_master_bias["Master Bias<br/>calibration stage<br/>[MakeMasterBias.py]"]
  node_node_make_master_dark["Master Dark<br/>calibration stage<br/>[MakeMasterDark.py]"]
  node_node_preprocessing["Preprocess<br/>frame prep<br/>[preprocessing.py]"]
  node_node_speccal["Spec Cal<br/>subsystem"]
  node_node_reduction_pkg["Reduction Pkg<br/>[__init__.py]"]
end

subgraph group_group_utils["Utilities"]
  node_node_cmos_data["CMOS Data<br/>data model<br/>[CMOSData.py]"]
  node_node_log["Logging<br/>[log.py]"]
  node_node_utils_pkg["Utils Pkg<br/>[__init__.py]"]
end

subgraph group_group_assets["Assets"]
  node_node_img_pipeline_yaml["Img Pipeline<br/>config<br/>[ImgPipeline.yml]"]
  node_node_img_pipeline_quick_yaml["Quick Pipeline<br/>config"]
  node_node_stats_tab["Stats Output<br/>example output<br/>[stats.tab]"]
  node_node_thar["ThAr Lines<br/>reference data<br/>[ThAr.list]"]
  node_node_bad_pixel_map["Bad Pixels<br/>reference data<br/>[bad_pixel_map.fits]"]
  node_node_data_pkg["Data Pkg"]
end

node_node_run_drp -->|"reads"| node_node_img_pipeline_yaml
node_node_run_drp -->|"reads"| node_node_img_pipeline_quick_yaml
node_node_run_drp -->|"orchestrates"| node_node_imgcal
node_node_run_drp -->|"orchestrates"| node_node_speccal
node_node_run_drp -->|"uses"| node_node_log
node_node_img_pipeline_yaml -.->|"enables"| node_node_make_master_bias
node_node_img_pipeline_yaml -.->|"enables"| node_node_make_master_dark
node_node_img_pipeline_yaml -.->|"configures"| node_node_preprocessing
node_node_img_pipeline_quick_yaml -.->|"configures"| node_node_preprocessing
node_node_imgcal -->|"contains"| node_node_make_master_bias
node_node_imgcal -->|"contains"| node_node_make_master_dark
node_node_imgcal -->|"contains"| node_node_preprocessing
node_node_preprocessing -->|"uses"| node_node_cmos_data
node_node_preprocessing -->|"reads"| node_node_bad_pixel_map
node_node_make_master_bias -->|"uses"| node_node_cmos_data
node_node_make_master_dark -->|"uses"| node_node_cmos_data
node_node_speccal -->|"reads"| node_node_thar
node_node_speccal -->|"uses"| node_node_cmos_data
node_node_reduction_pkg -->|"exposes"| node_node_imgcal
node_node_reduction_pkg -->|"exposes"| node_node_speccal
node_node_utils_pkg -->|"exposes"| node_node_cmos_data
node_node_utils_pkg -->|"exposes"| node_node_log
node_node_data_pkg -->|"bundles"| node_node_thar
node_node_data_pkg -->|"bundles"| node_node_bad_pixel_map
node_node_script_pkg -->|"contains"| node_node_run_drp
node_node_run_drp -.->|"emits"| node_node_stats_tab

click node_node_run_drp "https://github.com/amase-project/amasedrp/blob/main/amasedrp/script/run_drp.py"
click node_node_img_pipeline_yaml "https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/ImgPipeline.yml"
click node_node_img_pipeline_quick_yaml "https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/ImgPipeline_quick.yml"
click node_node_stats_tab "https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/stats.tab"
click node_node_imgcal "https://github.com/amase-project/amasedrp/tree/main/amasedrp/reduction/ImgCal"
click node_node_make_master_bias "https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/MakeMasterBias.py"
click node_node_make_master_dark "https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/MakeMasterDark.py"
click node_node_preprocessing "https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/preprocessing.py"
click node_node_speccal "https://github.com/amase-project/amasedrp/tree/main/amasedrp/reduction/SpecCal"
click node_node_cmos_data "https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/CMOSData/CMOSData.py"
click node_node_log "https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/log.py"
click node_node_thar "https://github.com/amase-project/amasedrp/blob/main/amasedrp/data/ThAr.list"
click node_node_bad_pixel_map "https://github.com/amase-project/amasedrp/blob/main/amasedrp/data/bad_pixel_map.fits"
click node_node_reduction_pkg "https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/__init__.py"
click node_node_utils_pkg "https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/__init__.py"
click node_node_script_pkg "https://github.com/amase-project/amasedrp/tree/main/amasedrp/script"
click node_node_data_pkg "https://github.com/amase-project/amasedrp/tree/main/amasedrp/data"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_run_drp,node_node_script_pkg toneBlue
class node_node_imgcal,node_node_make_master_bias,node_node_make_master_dark,node_node_preprocessing,node_node_speccal,node_node_reduction_pkg toneAmber
class node_node_cmos_data,node_node_log,node_node_utils_pkg toneMint
class node_node_img_pipeline_yaml,node_node_img_pipeline_quick_yaml,node_node_stats_tab,node_node_thar,node_node_bad_pixel_map,node_node_data_pkg toneRose
```

## Components

### Orchestration

User-facing pipeline entrypoint and runtime config.

- [Run DRP](https://github.com/amase-project/amasedrp/blob/main/amasedrp/script/run_drp.py): entrypoint · Command-line pipeline runner. · `amasedrp/script/run_drp.py`
- [Script Pkg](https://github.com/amase-project/amasedrp/tree/main/amasedrp/script): package · Script package boundary. · `amasedrp/script`

### Reduction

Core image and spectral processing stages.

- [Image Cal](https://github.com/amase-project/amasedrp/tree/main/amasedrp/reduction/ImgCal): subsystem · Image-domain calibration and preprocessing. · `amasedrp/reduction/ImgCal`
- [Master Bias](https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/MakeMasterBias.py): calibration stage · Builds master bias frames. · `amasedrp/reduction/ImgCal/MakeMasterBias.py`
- [Master Dark](https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/MakeMasterDark.py): calibration stage · Builds master dark frames. · `amasedrp/reduction/ImgCal/MakeMasterDark.py`
- [Preprocess](https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/ImgCal/preprocessing.py): frame prep · Frame-level cleanup and correction steps. · `amasedrp/reduction/ImgCal/preprocessing.py`
- [Spec Cal](https://github.com/amase-project/amasedrp/tree/main/amasedrp/reduction/SpecCal): subsystem · Spectroscopy calibration boundary. · `amasedrp/reduction/SpecCal`
- [Reduction Pkg](https://github.com/amase-project/amasedrp/blob/main/amasedrp/reduction/__init__.py): package · Top-level reduction package boundary. · `amasedrp/reduction/__init__.py`

### Utilities

Shared data model and operational helpers.

- [CMOS Data](https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/CMOSData/CMOSData.py): data model · Shared sensor/image data abstraction. · `amasedrp/utils/CMOSData/CMOSData.py`
- [Logging](https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/log.py): utility · Shared logging support. · `amasedrp/utils/log.py`
- [Utils Pkg](https://github.com/amase-project/amasedrp/blob/main/amasedrp/utils/__init__.py): package · Top-level utilities package boundary. · `amasedrp/utils/__init__.py`

### Assets

Bundled reference data and example pipeline files.

- [Img Pipeline](https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/ImgPipeline.yml): config · Full example pipeline configuration. · `amasedrp/example/ImgPipeline.yml`
- [Quick Pipeline](https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/ImgPipeline_quick.yml): config · Short example pipeline configuration. · `amasedrp/example/ImgPipeline_quick.yml`
- [Stats Output](https://github.com/amase-project/amasedrp/blob/main/amasedrp/example/stats.tab): example output · Sample tabular statistics artifact. · `amasedrp/example/stats.tab`
- [ThAr Lines](https://github.com/amase-project/amasedrp/blob/main/amasedrp/data/ThAr.list): reference data · Spectral line list for calibration. · `amasedrp/data/ThAr.list`
- [Bad Pixels](https://github.com/amase-project/amasedrp/blob/main/amasedrp/data/bad_pixel_map.fits): reference data · Static bad-pixel mask. · `amasedrp/data/bad_pixel_map.fits`
- [Data Pkg](https://github.com/amase-project/amasedrp/tree/main/amasedrp/data): package · Bundled reference data package boundary. · `amasedrp/data`

## Connections

- Run DRP → Img Pipeline: reads · Pipeline execution is driven by YAML configuration.
- Run DRP → Quick Pipeline: reads · Alternate quick-run configuration.
- Run DRP → Image Cal: orchestrates · Entry script dispatches image reduction stages.
- Run DRP → Spec Cal: orchestrates · Entry script can dispatch spectral calibration steps.
- Run DRP → Logging: uses · Runtime progress and error reporting.
- Img Pipeline → Master Bias: enables · Configuration may activate master bias generation.
- Img Pipeline → Master Dark: enables · Configuration may activate master dark generation.
- Img Pipeline → Preprocess: configures · Configuration drives preprocessing options.
- Quick Pipeline → Preprocess: configures · Quick pipeline targets a reduced preprocessing path.
- Image Cal → Master Bias: contains · Calibration subsystem includes bias building.
- Image Cal → Master Dark: contains · Calibration subsystem includes dark building.
- Image Cal → Preprocess: contains · Calibration subsystem includes preprocessing.
- Preprocess → CMOS Data: uses · Preprocessing operates on shared CMOS data structures.
- Preprocess → Bad Pixels: reads · Uses sensor mask/reference data during cleanup.
- Master Bias → CMOS Data: uses · Bias combination works on common sensor data objects.
- Master Dark → CMOS Data: uses · Dark combination works on common sensor data objects.
- Spec Cal → ThAr Lines: reads · Spectral calibration consumes ThAr line references.
- Spec Cal → CMOS Data: uses · Spectral steps share the common data model.
- Reduction Pkg → Image Cal: exposes · Reduction package exposes image calibration subsystem.
- Reduction Pkg → Spec Cal: exposes · Reduction package exposes spectral calibration subsystem.
- Utils Pkg → CMOS Data: exposes · Utilities package exposes the shared data abstraction.
- Utils Pkg → Logging: exposes · Utilities package exposes logging support.
- Data Pkg → ThAr Lines: bundles · Reference line list is packaged with the project.
- Data Pkg → Bad Pixels: bundles · Bad-pixel map is packaged with the project.
- Script Pkg → Run DRP: contains · Script package contains the pipeline entrypoint.
- Run DRP → Stats Output: emits · Pipeline produces diagnostic/statistical output.
