astro-snr-calc
astro-snr-calc is a small Python library and command-line tool for modelling point-source signal-to-noise ratio for astronomical imaging systems.
It supports two operating modes:
- Analytic mode: build a diffraction-limited Airy PSF from first-order telescope parameters in a TOML file.
- Zemax mode on Windows: load a
.zmxdesign through the ZOS-API and compute PSFs from OpticStudio.
The package produces SNR maps over exposure time and source magnitude, reports the SNR-optimal aperture, and marks regions where the brightest pixel saturates.
Features
- Model telescope, sensor, bandpass, and sky background terms.
- Evaluate SNR on a 2D grid of exposure time and apparent magnitude.
- Optimize the photometric aperture from the PSF itself.
- Plot SNR contours and saturation boundaries.
- Use a built-in Sony IMX267 sensor model or load a sensor from TOML.
- Optionally drive PSF generation from Zemax OpticStudio on Windows.
Installation
From the project root:
pip install .
From PyPI:
pip install astro-snr-calc
For editable development installs:
pip install -e .
The package requires Python 3.10 or newer.
Command-Line Usage
After installation, the console entry point is:
SNRCalc <telescope.toml> [detector.toml] [options]
Current CLI options:
usage: cli.py [-h] [-p PUPIL_SAMPLING] [-i IMAGE_SAMPLING]
[-f [FIELD_INDEX ...]] [--no-plots] [--no-save]
telescope [detector]
Examples:
SNRCalc telescope.toml
SNRCalc telescope.toml detector.toml
SNRCalc telescope.toml --no-plots
On Windows, you can also pass a Zemax design file instead of a telescope TOML file:
SNRCalc design.zmx detector.toml --field 1 3 --no-save
In analytic mode, the tool prints a model summary and saves an SNR map as a PNG file named after the telescope configuration stem.
Configuration Files
Telescope TOML
The telescope file describes the first-order optical model used in analytic mode.
name = "Example Telescope"
aperture = "80 mm"
effl = "400 mm"
wfno = 5.0
throughput = 0.85
Fields:
name: descriptive telescope name.aperture: entrance aperture diameter.effl: effective focal length.wfno: working f-number.throughput: end-to-end transmission as a fraction from 0 to 1.
Detector TOML
If you do not supply a detector file, the CLI uses a built-in Sony IMX267 uncooled model.
name = "Custom Sensor"
pixel_pitch = "3.45 um"
qe = 0.64
read_noise_e = 2.4
dark_rate = "3 1 / s"
full_well_e = 10700
Fields:
name: descriptive detector name.pixel_pitch: detector pixel pitch.qe: quantum efficiency as a fraction from 0 to 1.read_noise_e: read noise in electrons RMS.dark_rate: dark current in electrons per second per pixel.full_well_e: full well capacity in electrons.
Unit-bearing values are parsed with astropy.units.Quantity, so values such as "80 mm", "3.45 um", and "3 1 / s" are accepted.
Python API
You can also use the package directly from Python.
import astropy.units as u
from snr_calc import (
ExposureGrid,
PhotometricBand,
SNRResult,
Sensor,
SkyBrightness,
Telescope,
)
sensor = Sensor(
name="Sony IMX267 (uncooled)",
pixel_pitch=3.45 * u.um,
qe=0.64,
read_noise_e=2.4,
dark_rate=3.0 / u.s,
full_well_e=10700.0,
)
telescope = Telescope(
name="Example Telescope",
aperture=80 * u.mm,
effl=400 * u.mm,
wfno=5.0,
throughput=0.85,
)
model = telescope.build(
sensor=sensor,
band=PhotometricBand.johnson_v(),
sky=SkyBrightness.dark_sky(),
)
result = SNRResult.from_model(model, *ExposureGrid.default().arrays())
print(model.summary())
Top-level exports include:
SensorTelescopePhotometricBandSkyBrightnessExposureGridDetectorPSFSNRModelSNRResultSNRMapPlotter
Zemax Support
Zemax integration is only available on Windows. The module raises an import error on other platforms.
When using a .zmx file, the CLI can request FFT or Huygens PSF calculations through OpticStudio. The Windows-only CLI also supports:
--huygens: use Huygens PSF analysis instead of FFT.--as-extension: connect to a running interactive OpticStudio session.
If Zemax is not available, use analytic mode with a telescope TOML file.
Output
For each evaluated model, the CLI:
- prints a textual summary of telescope, detector, sky, PSF, and aperture parameters,
- computes SNR over a default grid of 1 ms to 100 s and magnitude 0 to 16,
- saves a PNG SNR map unless
--no-saveis used, - optionally displays the plot window unless
--no-plotsis used.
The plot includes logarithmic SNR coloring, contour overlays, and a hatched saturation boundary when the peak pixel exceeds the detector full well.
Development
To run the CLI from the source tree without installing the package:
PYTHONPATH=src python -m snr_calc.cli --help
Metadata
Release files for astro-snr-calc 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| astro_snr_calc-0.0.1.tar.gz | 27.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| astro_snr_calc-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.4 kB
Release files / astro_snr_calc-0.0.1.tar.gz
| Download URL | astro_snr_calc-0.0.1.tar.gz |
|---|---|
| Size | 27.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84a4f0a6beeff0040f69b2d63e49fd0ed6ffdcbb69326307fdce66af1e52f4c0
|
|
BLAKE2b-256 checksum How to use checksums |
48d748551c75ada97f071b8e3ee41c486ac51f64ec9a8f60880913de96ab29f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / astro_snr_calc-0.0.1-py3-none-any.whl
| Download URL | astro_snr_calc-0.0.1-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08a6a7a79abef3a02bfdf1296d1ee880674ea865c036a94d9aa273f2e0e2f440
|
|
BLAKE2b-256 checksum How to use checksums |
62cd5c5535f24752dd19dde1b84b1eb7fd6aff8061551ec6229805f00c37b763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|