Getting Started

Prerequisites

  • Python ≥ 3.11
  • git (for installing from source)

Installation

git clone https://gitlab.in2p3.fr/sauniere/psfcraft.git
cd psfcraft

python -m venv .venv
source .venv/bin/activate     # Windows: .venv\Scripts\activate

pip install -e .

With notebook support

pip install -e ".[notebooks]"
jupyter lab docs/tutorials/

With documentation build support

pip install -e ".[docs]"
mkdocs serve

No pysynphot needed

PSFCraft no longer depends on pysynphot. Polychromatic spectra are computed with a built-in Planck-law implementation (astropy constants only).


Verify the installation

import psfcraft
tel = psfcraft.NewtonianTelescope(version="0")
psf = tel.calc_psf(monochromatic=1e-6, fov_pixels=32)
print(psf.info())

You should see a FITS HDUList summary with a (32, 32) image extension.


Quick Start

1 — Perfect PSF

import psfcraft

tel = psfcraft.NewtonianTelescope(version="1_3")  # 3-arm spider aperture
tel.pixelscale = 0.1   # arcsec/pixel

psf = tel.calc_psf(monochromatic=1.2e-6, fov_pixels=64)
psfcraft.display_psf(psf)

2 — Inject Zernike wavefront aberrations

import numpy as np

# Noll indexing, coefficients in metres RMS
# index:     1   2   3    4       5       6       7       8
wfe = np.array([0,  0,  0,  50e-9,  80e-9,  80e-9,  30e-9,  30e-9])

tel.wfe_coefficients = wfe
psf_aberrated = tel.calc_psf(monochromatic=1.2e-6, fov_pixels=64)
psfcraft.display_psf(psf_aberrated)

3 — Measure Encircled Energy

psfcraft.display_ee(psf_aberrated)
ee_at_015 = psfcraft.measure_ee(psf_aberrated)(0.15)
print(f"EE within 0.15 arcsec: {ee_at_015:.3f}")

4 — Polychromatic PSF

from psfcraft.utils import build_polychromatic_star

# G-star (5800 K), J band, 7 wavelength samples
src = build_polychromatic_star(temperature=5800, filter_name="J", sampling=7)
psf_poly = tel.calc_psf(source=src, fov_pixels=64)
psfcraft.display_psf(psf_poly)

Aperture versions

version Geometry
"0" Circular only — no secondary, no spider
"1_3" Secondary + 3 evenly-spaced spider arms
"1_4" Secondary + 4 spider arms
"1_5" Secondary + 5 spider arms
"2" Euclid-like asymmetric 3-arm spider
"3" Secondary obscuration, no spider arms
"5" Hexagonal segmented primary
"6" Annular aperture

Next steps

  • Work through the tutorial series for step-by-step examples
  • Browse the API Reference for every available function
  • Try the WebUI for interactive exploration without writing code