# bu-hammerteam/pyhammer architecture

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

- Interactive diagram: https://gitdiagram.com/bu-hammerteam/pyhammer
- Repository: https://github.com/bu-hammerteam/pyhammer

## Overview

PyHammer is a desktop and command-line stellar spectral-typing suite. Users supply spectra and options; the runtime loads each spectrum, estimates spectral type and metallicity, measures spectral features, and can estimate radial-velocity shifts. It writes classification and rejection results, with optional line measurements, then offers a GUI for visual review and user corrections. The template library covers single stars and SB2 systems. The main workflow is supported by the excerpts and README; some internal calls are not shown, so those links are marked unverified rather than asserted.

Main entry points: [`spectrum.py`](https://github.com/bu-hammerteam/pyhammer/blob/master/spectrum.py) (Spectrum analysis), [`pyhammer.py`](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py) (Classification runner), [`eyecheck.py`](https://github.com/bu-hammerteam/pyhammer/blob/master/eyecheck.py) (Review interface), [`measure_allTemps_Indices.py`](https://github.com/bu-hammerteam/pyhammer/blob/master/measure_allTemps_Indices.py) (Index measurement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and settings"]
  node_settings["Run settings<br/>[pyhammer.py]"]
  node_runner["Classification runner<br/>[pyhammer.py]"]
  node_results["Classification output<br/>[pyhammer.py]"]
  node_rejected["Rejected spectra<br/>[pyhammer.py]"]
  node_lineout["Line measurements<br/>[pyhammer.py]"]
end

subgraph group_analysis["Spectral analysis"]
  node_spectrum["Spectrum analysis<br/>[spectrum.py]"]
  node_data["Spectrum data<br/>[spectrum.py]"]
  node_imports["Shared dependencies<br/>[pyhamimports.py]"]
end

subgraph group_review["Visual review"]
  node_reviewui["Review interface<br/>[eyecheck.py]"]
  node_guihelpers["GUI helpers<br/>[gui_utils.py]"]
end

subgraph group_reference["Templates and indices"]
  node_templates[("Spectral templates")]
  node_sb2templates[("SB2 templates")]
  node_lineindices[("Template line indices<br/>[tempLines.pickle]")]
  node_indexbuilder["Index measurement"]
end

node_user(("Spectrum user"))
node_reviewer(("Visual reviewer"))

node_user -->|"sets options"| node_settings
node_settings -->|"starts run"| node_runner
node_runner -.->|"loads and classifies"| node_spectrum
node_spectrum -->|"reads spectra"| node_data
node_spectrum -.->|"compares templates"| node_templates
node_spectrum -.->|"compares SB2 templates"| node_sb2templates
node_spectrum -.->|"uses line indices"| node_lineindices
node_runner -->|"writes classifications"| node_results
node_runner -->|"records rejects"| node_rejected
node_runner -->|"writes line data"| node_lineout
node_runner -.->|"opens review"| node_reviewui
node_reviewer -->|"reviews spectra"| node_reviewui
node_reviewui -->|"loads and reclassifies"| node_spectrum
node_reviewui -->|"uses widgets"| node_guihelpers
node_indexbuilder -->|"measures templates"| node_spectrum
node_indexbuilder -->|"reads templates"| node_templates
node_indexbuilder -->|"reads SB2 templates"| node_sb2templates
node_indexbuilder -->|"writes index data"| node_lineindices
node_runner -->|"imports shared tools"| node_imports
node_spectrum -->|"imports shared tools"| node_imports
node_reviewui -->|"imports shared tools"| node_imports

click node_settings "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py"
click node_runner "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py"
click node_spectrum "https://github.com/bu-hammerteam/pyhammer/blob/master/spectrum.py"
click node_data "https://github.com/bu-hammerteam/pyhammer/blob/master/spectrum.py"
click node_results "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py"
click node_rejected "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py"
click node_lineout "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py"
click node_reviewui "https://github.com/bu-hammerteam/pyhammer/blob/master/eyecheck.py"
click node_guihelpers "https://github.com/bu-hammerteam/pyhammer/blob/master/gui_utils.py"
click node_templates "https://github.com/bu-hammerteam/pyhammer/tree/master/resources/templates"
click node_sb2templates "https://github.com/bu-hammerteam/pyhammer/tree/master/resources/templates_SB2"
click node_lineindices "https://github.com/bu-hammerteam/pyhammer/blob/master/resources/tempLines.pickle"
click node_indexbuilder "https://github.com/bu-hammerteam/pyhammer/blob/master/measure_allTemps_Indices.py"
click node_imports "https://github.com/bu-hammerteam/pyhammer/blob/master/pyhamimports.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_settings,node_runner,node_results,node_rejected,node_lineout,node_user,node_reviewer toneBlue
class node_spectrum,node_data,node_imports toneAmber
class node_reviewui,node_guihelpers toneMint
class node_templates,node_sb2templates,node_lineindices,node_indexbuilder toneRose
```

## Components

### Entry and settings

- [Run settings](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py): `pyhammer.py`
- [Classification runner](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py): `pyhammer.py`
- [Classification output](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py): `pyhammer.py`
- [Rejected spectra](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py): `pyhammer.py`
- [Line measurements](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhammer.py): `pyhammer.py`

### Spectral analysis

- [Spectrum analysis](https://github.com/bu-hammerteam/pyhammer/blob/master/spectrum.py): `spectrum.py`
- [Spectrum data](https://github.com/bu-hammerteam/pyhammer/blob/master/spectrum.py): `spectrum.py`
- [Shared dependencies](https://github.com/bu-hammerteam/pyhammer/blob/master/pyhamimports.py): `pyhamimports.py`

### Visual review

- [Review interface](https://github.com/bu-hammerteam/pyhammer/blob/master/eyecheck.py): `eyecheck.py`
- [GUI helpers](https://github.com/bu-hammerteam/pyhammer/blob/master/gui_utils.py): `gui_utils.py`

### Templates and indices

- [Spectral templates](https://github.com/bu-hammerteam/pyhammer/tree/master/resources/templates): `resources/templates`
- [SB2 templates](https://github.com/bu-hammerteam/pyhammer/tree/master/resources/templates_SB2): `resources/templates_SB2`
- [Template line indices](https://github.com/bu-hammerteam/pyhammer/blob/master/resources/tempLines.pickle): `resources/tempLines.pickle`
- [Index measurement](https://github.com/bu-hammerteam/pyhammer/blob/master/measure_allTemps_Indices.py): `measure_allTemps_Indices.py`

### Other components

- **Spectrum user**
- **Visual reviewer**

## Connections

- Spectrum user → Run settings: sets options (evidence: `README.md`)
- Run settings → Classification runner: starts run (evidence: `pyhammer.py`)
- Classification runner → Spectrum analysis: loads and classifies (evidence: `pyhammer.py`)
- Spectrum analysis → Spectrum data: reads spectra (evidence: `spectrum.py`)
- Spectrum analysis → Spectral templates: compares templates
- Spectrum analysis → SB2 templates: compares SB2 templates
- Spectrum analysis → Template line indices: uses line indices
- Classification runner → Classification output: writes classifications (evidence: `pyhammer.py`)
- Classification runner → Rejected spectra: records rejects (evidence: `pyhammer.py`)
- Classification runner → Line measurements: writes line data (evidence: `pyhammer.py`)
- Classification runner → Review interface: opens review (evidence: `pyhammer.py`)
- Visual reviewer → Review interface: reviews spectra (evidence: `README.md`)
- Review interface → Spectrum analysis: loads and reclassifies (evidence: `eyecheck.py`)
- Review interface → GUI helpers: uses widgets (evidence: `eyecheck.py`)
- Index measurement → Spectrum analysis: measures templates (evidence: `measure_allTemps_Indices.py`)
- Index measurement → Spectral templates: reads templates (evidence: `measure_allTemps_Indices.py`)
- Index measurement → SB2 templates: reads SB2 templates (evidence: `measure_allTemps_Indices.py`)
- Index measurement → Template line indices: writes index data (evidence: `measure_allTemps_Indices.py`)
- Classification runner → Shared dependencies: imports shared tools (evidence: `pyhammer.py`)
- Spectrum analysis → Shared dependencies: imports shared tools (evidence: `spectrum.py`)
- Review interface → Shared dependencies: imports shared tools (evidence: `eyecheck.py`)
