# weijini777/dataacceleratorchemrixs architecture

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

- Interactive diagram: https://gitdiagram.com/weijini777/dataacceleratorchemrixs
- Repository: https://github.com/weijini777/dataacceleratorchemrixs

## Overview

#### Purpose and Entry Points
ChemRIXS is a Python analysis/reduction library for chemistry resonant inelastic X-ray scattering (RIXS) data. Its practical entry points are importable modules under `src/chemrixs/` and exploratory reduction/calibration notebooks under `jupyter_notebook/`. Reduction behavior is driven by YAML ROI and calibration inputs such as `roi_input.yml`, `conf.yml`, and `mono_calib.yml`.

#### Package Layout and Core API
The package is source-layout Python, rooted at `src/chemrixs/__init__.py`. Its architecture separates event-level detector handling, per-shot extraction, scan/run processing, aggregation, and persisted “small data” access:
- `src/chemrixs/detector.py`
- `src/chemrixs/singleshot.py`
- `src/chemrixs/process.py`
- `src/chemrixs/integrating.py`
- `src/chemrixs/smalldata.py`

#### Detector and ROI Interpretation
Detector-specific operations and region-of-interest selection are centralized in `src/chemrixs/detector.py`, with reusable transformations in `src/chemrixs/utils.py`. YAML files define detector regions and reduction parameters; examples include `roi_input.yml`, `roi_inputTT.yml`, and `BGroi_input.yml`. This creates a boundary between experiment-specific geometry/configuration and general reduction code.

#### Single-Shot Reduction
`src/chemrixs/singleshot.py` represents the event-level analysis stage: raw detector frames and associated per-shot metadata are converted into extracted spectral/intensity measurements. It depends on detector/ROI semantics rather than embedding experiment configuration. Timing-tool exploration and calibration workflows supporting this stage are represented in `jupyter_notebook/TT_test.ipynb`, `jupyter_notebook/calibration.ipynb`, and `jupyter_notebook/tt_funcs.py`.

#### Run and Scan Processing
`src/chemrixs/process.py` orchestrates reduction across shots or runs, applying configured extraction to build scan-level outputs. It is the likely control-flow boundary between raw/small-data input and analysis products. Supported experimental scan forms are reflected by representative HDF5 fixtures:
- `tests/data/mono_scan_testfile_Run0000.h5`
- `tests/data/mono_fly_testfile_Run0000.h5`
- `tests/data/delay_scan_testfile_Run0000.h5`

#### Integration and Aggregation
`src/chemrixs/integrating.py` performs integration-oriented reduction, while `src/chemrixs/average.py` provides aggregation/averaging of reduced measurements. The expected flow is detector frame → single-shot extraction → process orchestration → integration/averaging into run- or scan-level spectra. `jupyter_notebook/correlations.ipynb` and `jupyter_notebook/eaxmple_run.ipynb` are user-facing examples of downstream analysis.

#### Small-Data and Storage Boundary
`src/chemrixs/smalldata.py` abstracts access to compact run data, with HDF5 as the material persisted-data format evidenced by files in `tests/data/` and `jupyter_notebook/Run0023.h5`. This module forms the external data boundary: the core reduction pipeline operates on data retrieved from HDF5/small-data structures rather than requiring a web service or application server.

#### Runtime, Dependencies, and Validation
The project uses Python packaging via `pyproject.toml`; environment setup is additionally described through `conf.yml`. It has no indicated deployed service infrastructure. Core behavior is validated around processing, integration, and small-data handling in `tests/test_process.py`, `tests/test_integrating.py`, and `tests/test_smalldata.py`. An older implementation path, `src/chemrixs/old/reduce_funcs.py`, should be treated as legacy rather than a primary extension point.

Main entry points: [`src/chemrixs/process.py`](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/process.py) (Run and scan processing), [`src/chemrixs/smalldata.py`](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/smalldata.py) (Small-data access), [`src/chemrixs/detector.py`](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/detector.py) (Detector and ROI), [`src/chemrixs/__init__.py`](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/__init__.py) (chemrixs package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Experiment configuration"]
  node_roi_config["ROI YAML inputs<br/>YAML configuration<br/>[roi_input.yml]"]
  node_calibration_config["Calibration YAML inputs<br/>YAML configuration<br/>[mono_calib.yml]"]
end

subgraph group_core["Reduction library"]
  node_package["chemrixs package<br/>Python package<br/>[__init__.py]"]
  node_smalldata[("Small-data access<br/>data adapter<br/>[smalldata.py]")]
  node_detector["Detector and ROI<br/>detector processing<br/>[detector.py]"]
  node_utils["Reduction utilities<br/>Python utilities<br/>[utils.py]"]
  node_singleshot["Single-shot extraction<br/>event reduction<br/>[singleshot.py]"]
  node_process["Run and scan processing<br/>orchestrator<br/>[process.py]"]
  node_integrating["Integration<br/>reduction stage<br/>[integrating.py]"]
  node_average["Averaging<br/>aggregation<br/>[average.py]"]
end

subgraph group_workflow["Interactive workflows"]
  node_calibration_notebook["Timing and calibration<br/>Jupyter workflow<br/>[calibration.ipynb]"]
  node_tt_notebook["Timing-tool exploration<br/>Jupyter workflow<br/>[TT_test.ipynb]"]
  node_downstream_notebook["Correlation analysis<br/>Jupyter workflow<br/>[correlations.ipynb]"]
end

node_hdf5_data[("HDF5 run data<br/>persisted data<br/>[Run0023.h5]")]
node_scan_fixtures[("Scan forms<br/>HDF5 fixtures")]
node_legacy["Legacy reduction functions<br/>legacy code<br/>[reduce_funcs.py]"]

node_package -->|"exposes"| node_detector
node_package -->|"exposes"| node_process
node_package -->|"exposes"| node_smalldata
node_roi_config -->|"defines ROIs"| node_detector
node_calibration_config -->|"configures"| node_process
node_utils -->|"supports"| node_detector
node_detector -->|"provides ROI semantics"| node_singleshot
node_hdf5_data -->|"read by"| node_smalldata
node_scan_fixtures -.->|"represent scan inputs"| node_smalldata
node_smalldata -->|"supplies run data"| node_process
node_singleshot -->|"extracts per-shot measurements"| node_process
node_process -->|"feeds reduced data"| node_integrating
node_integrating -->|"feeds"| node_average
node_calibration_notebook -.->|"develops calibration"| node_calibration_config
node_tt_notebook -.->|"supports timing workflow"| node_singleshot
node_process -.->|"produces analysis inputs"| node_downstream_notebook
node_legacy -.->|"superseded by"| node_process

click node_package "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/__init__.py"
click node_smalldata "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/smalldata.py"
click node_detector "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/detector.py"
click node_utils "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/utils.py"
click node_singleshot "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/singleshot.py"
click node_process "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/process.py"
click node_integrating "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/integrating.py"
click node_average "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/average.py"
click node_roi_config "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/roi_input.yml"
click node_calibration_config "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/mono_calib.yml"
click node_hdf5_data "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/Run0023.h5"
click node_scan_fixtures "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/tests/data/mono_scan_testfile_Run0000.h5"
click node_calibration_notebook "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/calibration.ipynb"
click node_tt_notebook "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/TT_test.ipynb"
click node_downstream_notebook "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/correlations.ipynb"
click node_legacy "https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/old/reduce_funcs.py"

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_roi_config,node_calibration_config toneBlue
class node_package,node_smalldata,node_detector,node_utils,node_singleshot,node_process,node_integrating,node_average toneAmber
class node_calibration_notebook,node_tt_notebook,node_downstream_notebook toneMint
class node_hdf5_data,node_scan_fixtures,node_legacy toneNeutral
```

## Components

### Experiment configuration

Experiment-specific ROI and calibration inputs.

- [ROI YAML inputs](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/roi_input.yml): YAML configuration · Defines detector regions and reduction parameters. · `roi_input.yml`
- [Calibration YAML inputs](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/mono_calib.yml): YAML configuration · Provides reduction and monochromator calibration settings. · `mono_calib.yml`

### Reduction library

Importable Python reduction pipeline.

- [chemrixs package](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/__init__.py): Python package · Source-layout public library root. · `src/chemrixs/__init__.py`
- [Small-data access](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/smalldata.py): data adapter · Reads compact persisted run data. · `src/chemrixs/smalldata.py`
- [Detector and ROI](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/detector.py): detector processing · Centralizes detector operations and ROI interpretation. · `src/chemrixs/detector.py`
- [Reduction utilities](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/utils.py): Python utilities · Reusable detector transformations. · `src/chemrixs/utils.py`
- [Single-shot extraction](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/singleshot.py): event reduction · Converts frames and shot metadata into measurements. · `src/chemrixs/singleshot.py`
- [Run and scan processing](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/process.py): orchestrator · Applies configured extraction across shots or runs. · `src/chemrixs/process.py`
- [Integration](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/integrating.py): reduction stage · Performs integration-oriented reduction. · `src/chemrixs/integrating.py`
- [Averaging](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/average.py): aggregation · Aggregates reduced measurements into spectra. · `src/chemrixs/average.py`

### Interactive workflows

Notebook-based calibration and downstream analysis.

- [Timing and calibration](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/calibration.ipynb): Jupyter workflow · Explores timing-tool and calibration workflows. · `jupyter_notebook/calibration.ipynb`
- [Timing-tool exploration](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/TT_test.ipynb): Jupyter workflow · Interactive timing-tool analysis. · `jupyter_notebook/TT_test.ipynb`
- [Correlation analysis](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/correlations.ipynb): Jupyter workflow · Downstream reduced-data analysis example. · `jupyter_notebook/correlations.ipynb`

### Other components

- [HDF5 run data](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/jupyter_notebook/Run0023.h5): persisted data · Compact input and scan data format. · `jupyter_notebook/Run0023.h5`
- [Scan forms](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/tests/data/mono_scan_testfile_Run0000.h5): HDF5 fixtures · Representative mono, fly, and delay scan inputs. · `tests/data/mono_scan_testfile_Run0000.h5`
- [Legacy reduction functions](https://github.com/weijini777/dataacceleratorchemrixs/blob/main/src/chemrixs/old/reduce_funcs.py): legacy code · Older implementation path, not a primary extension point. · `src/chemrixs/old/reduce_funcs.py`

## Connections

- chemrixs package → Detector and ROI: exposes
- chemrixs package → Run and scan processing: exposes
- chemrixs package → Small-data access: exposes
- ROI YAML inputs → Detector and ROI: defines ROIs
- Calibration YAML inputs → Run and scan processing: configures
- Reduction utilities → Detector and ROI: supports
- Detector and ROI → Single-shot extraction: provides ROI semantics
- HDF5 run data → Small-data access: read by
- Scan forms → Small-data access: represent scan inputs
- Small-data access → Run and scan processing: supplies run data
- Single-shot extraction → Run and scan processing: extracts per-shot measurements
- Run and scan processing → Integration: feeds reduced data
- Integration → Averaging: feeds
- Timing and calibration → Calibration YAML inputs: develops calibration
- Timing-tool exploration → Single-shot extraction: supports timing workflow
- Run and scan processing → Correlation analysis: produces analysis inputs
- Legacy reduction functions → Run and scan processing: superseded by
