Skip to main content

pysanepic

GLS map-making with correlated (1/f) noise for CMB experiments, in Python.

pysanepic is a Python port of SANEPIC (Patanchon et al. 2008, ApJ 681, 708). It solves the generalized least-squares problem (PᵀN⁻¹P) m = PᵀN⁻¹d with preconditioned conjugate gradients, applying N⁻¹ in Fourier space on chunks of data, and returns I, Q, U HEALPix maps.

  • Designed for experiments without HWP, where 1/f noise affects both intensity and polarization. An ideal HWP is supported too.
  • Pure Python with numba and ducc0; runs with MPI (mpi4py) and threads.
  • Supports polarization efficiency and any coordinate system.
  • Noise correlated between detectors (common modes of a wafer), with a two-level preconditioner for the large scales (GLSParameters.coarse_nside; by default on the I monopole alone, the slowest mode).
  • Noise spectra, couplings and common modes estimated from the data (estimate_noise).
  • Flagged samples: exact marginalization, offsets, ACT Legendre cut models, or fixed filling with local white noise or conditional Gaussian noise. See the flagging guide, including the model requirements and MPI seed behavior (new filling modes are unreleased).
  • Gain calibration on the dipole, fitted with the maps (CalibrationParameters), with masks for the Galactic plane.
  • Sky model as alm interpolated at the pointing (no pixelization error) (make_maps(sky_model=...)).
  • Templates fitted with the maps, as sky signals (e.g. bandpass mismatch) or TODs, with amplitudes per detector, common, or per period, and their covariance (make_maps(templates={name: Template(...)})).
  • Helpers for the templates of polarization angles and beams (FWHM, pointing offsets, ellipticity) from the sky model, and the beam parameters from the fitted amplitudes (pysanepic.templates).
  • Independent of any simulation pipeline: data are passed as plain arrays.
  • Validated against the original C++ code, which is kept in cpp/.

Documentation: https://pysanepic.readthedocs.io (sources in docs/).

Installation

pip install pysanepic
pip install "pysanepic[mpi]"                # with MPI
pip install git+https://github.com/litebird/pysanepic   # development version

Usage

With litebird_sim (on master, not yet in a release):

from pysanepic import GLSParameters

result = sim.make_sanepic_gls_map(nside=512, params=GLSParameters(chunk_s=86400.0, tol=1e-8))
result.maps       # (3, npix) I, Q, U; healpy.UNSEEN where not solved

With any other pipeline, one DetectorData per detector and stretch of time:

from pysanepic import DetectorData, OneOverFNoise, Pointing, make_maps

# angles in any coordinate system, or Pointing(pix=..., nside=..., psi=..., coordinates=...)
pointing = Pointing(theta=theta, phi=phi, psi=psi, coordinates="E")
noise = OneOverFNoise(net_ukrts=40.0, fknee_hz=0.02, alpha=1.0, fmin_hz=1e-5)  # or TabulatedNoise(freqs_hz=..., psd=...)
data = [DetectorData(tod=tod, pointing=pointing, pol_angle_rad=0.0, sampling_rate_hz=19.0, noise=noise)]
result = make_maps(data, nside=64, coordinates="G")

See the documentation for the conventions, the parameters and how to choose them, MPI, memory and benchmarks, and the notebooks.

Tests

pip install -e ".[test]"
make -C cpp ARCH=linux        # or ARCH=mac: builds the C++ reference
pytest                        # includes the comparison with C++ SANEPIC
mpirun -n 4 python tests/test_mpi.py

Documentation

pip install -e ".[docs]"
sphinx-build -b html docs docs/_build/html

License

Distributed under the GPL3 License.

Metadata

Release files for pysanepic 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysanepic 0.6.4
File Size Uploaded Provenance Actions
pysanepic-0.6.4.tar.gz 97.5 kB With provenance Details for pysanepic-0.6.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysanepic 0.6.4
File Interpreter ABI Platform Actions
pysanepic-0.6.4-py3-none-any.whl Python 3 none any Details for pysanepic-0.6.4-py3-none-any.whl

Total release size: 187.3 kB

Release files / pysanepic-0.6.4.tar.gz

Download URL pysanepic-0.6.4.tar.gz
Size 97.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d538596a6409a543c5671bbec996c8159f95c2529ede406cd8a78ac83eb96319
BLAKE2b-256 checksum
How to use checksums
f1b052b436625b73a2e7e78498ca4ff5f21ed3fea46d698f0bbea5396c9a24ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pysanepic-0.6.4-py3-none-any.whl

Download URL pysanepic-0.6.4-py3-none-any.whl
Size 89.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ab9c6e2da193e88b0545dfdac285f6ecdaaacbfa2ca967438995f8667e4f2a3
BLAKE2b-256 checksum
How to use checksums
5136b79d2a0ca8e659f8aef117ad3ab655f90faf68b572d0f69930a2e8920af3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pysanepic 0.6.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pysanepic-0.6.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page