# jarodgr12/lenspipe architecture

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

- Interactive diagram: https://gitdiagram.com/jarodgr12/lenspipe
- Repository: https://github.com/jarodgr12/lenspipe

## Overview

lenspipe turns calibrated multi-epoch UV-FITS visits into per-image spectra, flux ratios, and science plots through three project-directory stages. Users can drive the same workflow from the CLI or local web console; a separate CASA module can prepare Stage 1 inputs. The graph preserves the documented analysis, combined-visit, and console capabilities. Some internal stage and UI wiring is inferred only from documented responsibilities and paths because those implementations were not sampled.

Main entry points: [`src/lenspipe/cli.py`](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/cli.py) (CLI commands), [`src/lenspipe/stage2.py`](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2.py) (Stage 2 spectra), [`src/lenspipe/stage3/analysis.py`](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/analysis.py) (Stage 3 analysis), [`src/lenspipe/stage1.py`](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage1.py) (Stage 1 calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Project and control"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_project_layout["Project layout<br/>[project.py]"]
  node_configuration["Configuration<br/>[config.py]"]
  node_job_manager["Job management<br/>[jobs.py]"]
end

subgraph group_pipeline["Calibration and stages"]
  node_casa["CASA calibration<br/>[calibration.py]"]
  node_stage1["Stage 1 calibration<br/>[stage1.py]"]
  node_stage2["Stage 2 spectra<br/>[stage2.py]"]
  node_shards["Stage 2 shards<br/>[stage2_shards.py]"]
  node_quicklook["Quick-look plots"]
  node_difmap["DifMAP execution<br/>[runner.py]"]
  node_logparse["DifMAP log parsing<br/>[logparse.py]"]
  node_uvfits["UV-FITS handling<br/>[uvfits.py]"]
end

subgraph group_science["Science products"]
  node_stage3["Stage 3 analysis<br/>[analysis.py]"]
  node_fitting["Spectral fitting<br/>[fitting.py]"]
  node_combined["Multi-visit summaries<br/>[combined.py]"]
  node_plotting["Publication plots<br/>[plotting.py]"]
end

subgraph group_console["Web console"]
  node_web_app["Local web app<br/>[app.py]"]
  node_console_state["Console state<br/>[state.py]"]
  node_console_pages["Console pages<br/>[pages_results.py]"]
  node_interactive["Interactive figures<br/>[interactive.py]"]
end

node_user(("Researcher"))
node_inputs["UV-FITS and model inputs"]
node_stage2_products["Spectra and metadata"]
node_science_products["Science tables and figures"]
node_result_store[("Project products")]
node_difmap_service["DifMAP"]

node_user -->|"runs commands"| node_cli
node_cli -->|"opens project"| node_project_layout
node_cli -->|"loads settings"| node_configuration
node_user -.->|"calibrates data"| node_casa
node_casa -.->|"exports inputs"| node_inputs
node_inputs -->|"provides data"| node_stage1
node_cli -->|"runs stage"| node_stage1
node_cli -->|"runs stage"| node_stage2
node_cli -->|"runs stage"| node_stage3
node_stage1 -->|"runs scripts"| node_difmap
node_stage1 -->|"reads data"| node_uvfits
node_stage1 -->|"writes calibrated products"| node_result_store
node_stage2 -->|"splits fit ranges"| node_shards
node_stage2 -->|"runs fits"| node_difmap
node_stage2 -->|"parses logs"| node_logparse
node_stage2 -->|"makes diagnostics"| node_quicklook
node_stage2 -->|"writes spectra"| node_result_store
node_result_store -->|"provides spectra"| node_stage3
node_stage3 -->|"fits spectra"| node_fitting
node_stage3 -->|"summarizes visits"| node_combined
node_stage3 -->|"renders figures"| node_plotting
node_stage3 -->|"writes products"| node_result_store
node_cli -->|"starts console"| node_web_app
node_web_app -->|"serves state"| node_console_state
node_console_state -->|"manages jobs"| node_job_manager
node_console_pages -->|"uses state"| node_console_state
node_console_pages -->|"builds plots"| node_interactive
node_interactive -->|"reads metadata"| node_result_store
node_difmap -->|"invokes"| node_difmap_service

click node_cli "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/cli.py"
click node_project_layout "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/project.py"
click node_configuration "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/config.py"
click node_casa "https://github.com/jarodgr12/lenspipe/blob/master/casa/calibration.py"
click node_stage1 "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage1.py"
click node_stage2 "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2.py"
click node_shards "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2_shards.py"
click node_quicklook "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2_quicklook.py"
click node_difmap "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/difmap/runner.py"
click node_logparse "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/difmap/logparse.py"
click node_uvfits "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/uvfits.py"
click node_stage3 "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/analysis.py"
click node_fitting "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/fitting.py"
click node_combined "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/combined.py"
click node_plotting "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/plotting.py"
click node_job_manager "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/jobs.py"
click node_web_app "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/app.py"
click node_console_state "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/state.py"
click node_console_pages "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/pages_results.py"
click node_interactive "https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/interactive.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_cli,node_project_layout,node_configuration,node_job_manager toneBlue
class node_casa,node_stage1,node_stage2,node_shards,node_quicklook,node_difmap,node_logparse,node_uvfits,node_result_store toneAmber
class node_stage3,node_fitting,node_combined,node_plotting toneMint
class node_web_app,node_console_state,node_console_pages,node_interactive toneRose
class node_user,node_inputs,node_stage2_products,node_science_products,node_difmap_service toneIndigo
```

## Components

### Project and control

- [CLI commands](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/cli.py): `src/lenspipe/cli.py`
- [Project layout](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/project.py): `src/lenspipe/project.py`
- [Configuration](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/config.py): `src/lenspipe/config.py`
- [Job management](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/jobs.py): `src/lenspipe/jobs.py`

### Calibration and stages

- [CASA calibration](https://github.com/jarodgr12/lenspipe/blob/master/casa/calibration.py): `casa/calibration.py`
- [Stage 1 calibration](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage1.py): `src/lenspipe/stage1.py`
- [Stage 2 spectra](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2.py): `src/lenspipe/stage2.py`
- [Stage 2 shards](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2_shards.py): `src/lenspipe/stage2_shards.py`
- [Quick-look plots](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage2_quicklook.py): `src/lenspipe/stage2_quicklook.py`
- [DifMAP execution](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/difmap/runner.py): `src/lenspipe/difmap/runner.py`
- [DifMAP log parsing](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/difmap/logparse.py): `src/lenspipe/difmap/logparse.py`
- [UV-FITS handling](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/uvfits.py): `src/lenspipe/uvfits.py`

### Science products

- [Stage 3 analysis](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/analysis.py): `src/lenspipe/stage3/analysis.py`
- [Spectral fitting](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/fitting.py): `src/lenspipe/stage3/fitting.py`
- [Multi-visit summaries](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/combined.py): `src/lenspipe/stage3/combined.py`
- [Publication plots](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/stage3/plotting.py): `src/lenspipe/stage3/plotting.py`

### Web console

- [Local web app](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/app.py): `src/lenspipe/ui/app.py`
- [Console state](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/state.py): `src/lenspipe/ui/state.py`
- [Console pages](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/pages_results.py): `src/lenspipe/ui/pages_results.py`
- [Interactive figures](https://github.com/jarodgr12/lenspipe/blob/master/src/lenspipe/ui/interactive.py): `src/lenspipe/ui/interactive.py`

### Other components

- **Researcher**
- **UV-FITS and model inputs**
- **Spectra and metadata**
- **Science tables and figures**
- **Project products**
- **DifMAP**

## Connections

- Researcher → CLI commands: runs commands
- CLI commands → Project layout: opens project
- CLI commands → Configuration: loads settings
- Researcher → CASA calibration: calibrates data
- CASA calibration → UV-FITS and model inputs: exports inputs
- UV-FITS and model inputs → Stage 1 calibration: provides data
- CLI commands → Stage 1 calibration: runs stage
- CLI commands → Stage 2 spectra: runs stage
- CLI commands → Stage 3 analysis: runs stage
- Stage 1 calibration → DifMAP execution: runs scripts
- Stage 1 calibration → UV-FITS handling: reads data
- Stage 1 calibration → Project products: writes calibrated products
- Stage 2 spectra → Stage 2 shards: splits fit ranges
- Stage 2 spectra → DifMAP execution: runs fits
- Stage 2 spectra → DifMAP log parsing: parses logs
- Stage 2 spectra → Quick-look plots: makes diagnostics
- Stage 2 spectra → Project products: writes spectra
- Project products → Stage 3 analysis: provides spectra
- Stage 3 analysis → Spectral fitting: fits spectra
- Stage 3 analysis → Multi-visit summaries: summarizes visits
- Stage 3 analysis → Publication plots: renders figures
- Stage 3 analysis → Project products: writes products
- CLI commands → Local web app: starts console
- Local web app → Console state: serves state
- Console state → Job management: manages jobs
- Console pages → Console state: uses state
- Console pages → Interactive figures: builds plots
- Interactive figures → Project products: reads metadata
- DifMAP execution → DifMAP: invokes
