# Namaster

> Guide to NaMaster (pymaster), the DESC pseudo-Cl angular power spectrum estimator. Use this skill whenever the user imports pymaster; works with NmtField, NmtBin, NmtWorkspace, or NmtCovarianceWorkspace; calls compute_full_master, compute_coupled_cell, decouple_cell, or mask_apodization; computes pseudo-Cl power spectra for spin-0 or spin-2 (shear) fields; handles masks, mode-coupling matrices, or workspace serialization; asks about bandpower binning, EE/BB/EB spectrum ordering, or apodization; writes TXPipe Fourier-space stages (TXTwoPointFourier, TXFourierNamasterCovariance); or needs Gaussian covariance estimates.

- Skill: `jfcrenshaw/namaster` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add jfcrenshaw/namaster`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jfcrenshaw/namaster/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jfcrenshaw (https://skillmd.com/u/jfcrenshaw)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/jfcrenshaw/namaster

---


# NaMaster — pseudo-Cl power spectra for masked fields

You're helping a user write code with NaMaster (pymaster), DESC's pseudo-Cl angular power spectrum estimator (Alonso et al. 2019).
NaMaster is the Fourier-space workhorse of TXPipe: `TXTwoPointFourier` and its subclasses use it for all 3×2pt Cl measurements, and `TXFourierNamasterCovariance` uses it for Gaussian covariance estimation.

## Overview

**Four core objects** (import as `import pymaster as nmt`):

| Object | Role |
|---|---|
| `NmtField` | Wraps maps + mask + optional beam/templates |
| `NmtBin` | Defines ell bandpower binning |
| `NmtWorkspace` | Stores mode-coupling matrix; used to decouple pseudo-Cls |
| `NmtCovarianceWorkspace` | Stores coupling coefficients for Gaussian covariance |

**Minimal workflow:**
```python
import pymaster as nmt
import healpy as hp

nside = 512
mask = hp.read_map("mask.fits")
mask = nmt.mask_apodization(mask, aposize=1.0, apotype="Smooth")

# Spin-0 (density/convergence): one map
f0 = nmt.NmtField(mask, [delta_map], n_iter=0)

# Spin-2 (shear): two maps [g1, g2]
f2 = nmt.NmtField(mask, [g1, g2], n_iter=0, lmax=lmax)

# Binning
b = nmt.NmtBin.from_nside_linear(nside, nlb=40)   # linear, width-40 bands
# OR: b = nmt.NmtBin.from_edges(ell_lo, ell_hi)

# Compute coupling matrix once, reuse across tomographic bins
w = nmt.NmtWorkspace.from_fields(f0, f0, b)  # or w.compute_coupling_matrix(f0, f0, b)
w.write_to("workspace.fits")   # persist to disk

# Two equivalent approaches:
# (A) all-in-one (recomputes MCM internally — slow if reusing)
cl = nmt.compute_full_master(f0, f0, b)

# (B) decouple manually (fast when workspace is precomputed)
pcl = nmt.compute_coupled_cell(f0, f0)
cl  = w.decouple_cell(pcl)
```

**Spin-2 output ordering** — cross-correlating two spin-2 fields returns 4 spectra: `[EE, EB, BE, BB]` at indices 0–3.
Shear×density returns `[E, B]`.

See [`references/api.md`](references/api.md) for detailed parameter tables and gotchas.

## TXPipe usage

NaMaster is TXPipe's Fourier-space workhorse: `TXTwoPointFourier`, `TXTwoPointFourierCatalog`, `TXFourierNamasterCovariance`, and the CMB lensing cross-spectrum stage all use it.
See [`references/txpipe.md`](references/txpipe.md) for stage details, workspace management, noise estimation, the `choose_ell_bins` helper, and the `flip_g2` sign convention.

## Reference

| Topic | Reference |
|---|---|
| API details, gotchas, covariance | [`references/api.md`](references/api.md) |
| TXPipe stage details | [`references/txpipe.md`](references/txpipe.md) |

