# adamfield118/mmstats architecture

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

- Interactive diagram: https://gitdiagram.com/adamfield118/mmstats
- Repository: https://github.com/adamfield118/mmstats

## Overview

MMStats is a weak-lensing mass-mapping statistics framework. Its visible workflow runs a metacalibration pipeline on a galaxy catalog, estimates shear biases with jackknife uncertainty, and writes results for the R workflow. The README also identifies resampling, error propagation, and statistical validation as product capabilities; the R filenames indicate analysis and reporting areas, but their implementations and connections were not sampled. The pipeline excerpt documents its output handoff, but does not establish links among the other R modules.

Main entry points: [`pipeline/metacal_pipeline.py`](https://github.com/adamfield118/mmstats/blob/main/pipeline/metacal_pipeline.py) (Metacal pipeline), [`R/run_all.R`](https://github.com/adamfield118/mmstats/blob/main/R/run_all.R) (R workflow entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Metacalibration"]
  node_metacal["Metacal pipeline"]
  node_bias_results["Bias results JSON"]
end

subgraph group_statistics["Statistical analysis"]
  node_run_all["R workflow entry<br/>[run_all.R]"]
  node_simulate["Simulation<br/>[simulate.R]"]
  node_bootstrap["Bootstrap<br/>[bootstrap.R]"]
  node_jackknife["KS sampling<br/>[ks_smpy.R]"]
  node_monte_carlo["Monte Carlo<br/>[mc.R]"]
  node_power["Power analysis<br/>[power.R]"]
  node_lensing["Lensing analysis<br/>[lensing.R]"]
end

subgraph group_reporting["Validation and reporting"]
  node_sanity["Sanity checks<br/>[sanity_check.R]"]
  node_analytical_test["Analytical KS check"]
  node_kappa_plot["Kappa plots<br/>[plot_kappa.R]"]
  node_report_figures["Report figures"]
end

node_user(("Analyst"))
node_catalog["Galaxy catalog"]

node_user -->|"runs"| node_metacal
node_catalog -->|"loads"| node_metacal
node_metacal -->|"writes"| node_bias_results
node_metacal -->|"provides results"| node_run_all

click node_metacal "https://github.com/adamfield118/mmstats/blob/main/pipeline/metacal_pipeline.py"
click node_run_all "https://github.com/adamfield118/mmstats/blob/main/R/run_all.R"
click node_simulate "https://github.com/adamfield118/mmstats/blob/main/R/simulate.R"
click node_bootstrap "https://github.com/adamfield118/mmstats/blob/main/R/bootstrap.R"
click node_jackknife "https://github.com/adamfield118/mmstats/blob/main/R/ks_smpy.R"
click node_monte_carlo "https://github.com/adamfield118/mmstats/blob/main/R/mc.R"
click node_power "https://github.com/adamfield118/mmstats/blob/main/R/power.R"
click node_lensing "https://github.com/adamfield118/mmstats/blob/main/R/lensing.R"
click node_sanity "https://github.com/adamfield118/mmstats/blob/main/R/sanity_check.R"
click node_analytical_test "https://github.com/adamfield118/mmstats/blob/main/R/test_ks_analytical.R"
click node_kappa_plot "https://github.com/adamfield118/mmstats/blob/main/R/plot_kappa.R"
click node_report_figures "https://github.com/adamfield118/mmstats/blob/main/R/plot_report_figures.R"

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_metacal,node_bias_results toneBlue
class node_run_all,node_simulate,node_bootstrap,node_jackknife,node_monte_carlo,node_power,node_lensing toneAmber
class node_sanity,node_analytical_test,node_kappa_plot,node_report_figures toneMint
class node_user,node_catalog toneIndigo
```

## Components

### Metacalibration

- [Metacal pipeline](https://github.com/adamfield118/mmstats/blob/main/pipeline/metacal_pipeline.py): `pipeline/metacal_pipeline.py`
- **Bias results JSON**

### Statistical analysis

- [R workflow entry](https://github.com/adamfield118/mmstats/blob/main/R/run_all.R): `R/run_all.R`
- [Simulation](https://github.com/adamfield118/mmstats/blob/main/R/simulate.R): `R/simulate.R`
- [Bootstrap](https://github.com/adamfield118/mmstats/blob/main/R/bootstrap.R): `R/bootstrap.R`
- [KS sampling](https://github.com/adamfield118/mmstats/blob/main/R/ks_smpy.R): `R/ks_smpy.R`
- [Monte Carlo](https://github.com/adamfield118/mmstats/blob/main/R/mc.R): `R/mc.R`
- [Power analysis](https://github.com/adamfield118/mmstats/blob/main/R/power.R): `R/power.R`
- [Lensing analysis](https://github.com/adamfield118/mmstats/blob/main/R/lensing.R): `R/lensing.R`

### Validation and reporting

- [Sanity checks](https://github.com/adamfield118/mmstats/blob/main/R/sanity_check.R): `R/sanity_check.R`
- [Analytical KS check](https://github.com/adamfield118/mmstats/blob/main/R/test_ks_analytical.R): `R/test_ks_analytical.R`
- [Kappa plots](https://github.com/adamfield118/mmstats/blob/main/R/plot_kappa.R): `R/plot_kappa.R`
- [Report figures](https://github.com/adamfield118/mmstats/blob/main/R/plot_report_figures.R): `R/plot_report_figures.R`

### Other components

- **Analyst**
- **Galaxy catalog**

## Connections

- Analyst → Metacal pipeline: runs (evidence: `pipeline/metacal_pipeline.py`)
- Galaxy catalog → Metacal pipeline: loads (evidence: `pipeline/metacal_pipeline.py`)
- Metacal pipeline → Bias results JSON: writes (evidence: `pipeline/metacal_pipeline.py`)
- Metacal pipeline → R workflow entry: provides results (evidence: `pipeline/metacal_pipeline.py`)
