Skip to main content

PyEchelle

PyEchelle is a simulation tool, to generate realistic 2D spectra, in particular cross-dispersed echelle spectra. However, it is not limited to echelle spectrographs, but allows simulating arbitrary spectra for any fiber-fed or slit spectrograph, where a model file is available. Optical aberrations are treated accurately, the simulated spectra include photon and read-out noise.

PyEchelle uses numba for implementing fast Python-based simulation code. It also comes with CUDA support for major speed improvements.

Example usage

You can use PyEchelle directly from the console:

pyechelle --spectrograph MaroonX --fiber 2-4 --sources Phoenix --phoenix_t_eff 3500 -t 10 --rv 100 -o mdwarf.fit

If you rather script in python, you can do the same as above with the following python script:

from pyechelle.simulator import Simulator
from pyechelle.sources import Phoenix
from pyechelle.spectrograph import ZEMAX

sim = Simulator(ZEMAX("MaroonX"))
sim.set_fibers([2, 3, 4])
sim.set_sources(Phoenix(t_eff=3500))
sim.set_exposure_time(10.)
sim.set_radial_velocities(100.)
sim.set_output('mdwarf.fits', overwrite=True)
sim.run()

Both times, a PHOENIX M-dwarf spectrum with the given stellar parameters, and a RV shift of 100m/s for the MAROON-X spectrograph is simulated.

The output is a 2D raw frame (.fits) and will look similar to:

Check out the Documentation for more examples.

Pyechelle is the successor of Echelle++ which has a similar functionality but was written in C++. This package was rewritten in python for better maintainability, easier package distribution and for smoother cross-platform development.

Installation

As simple as

pip install pyechelle

Check out the Documentation for alternative installation instruction.

Usage

See

pyechelle -h

for all available command line options.

See Documentation for more examples.

Model and output locations

PyEchelle stores downloaded spectrograph models and default outputs in platform-specific user directories (via platformdirs) instead of writing into the package installation folder.

  • Model lookup order: user data models dir, user cache models dir, current working directory, legacy package models folder.
  • Model download targets: user data models dir first, then user cache models dir.
  • Default simulation output path (if -o/--output or Simulator.set_output(path=...) is not set): user data outputs dir.

You can inspect these paths directly:

from pyechelle.paths import model_data_dir, model_cache_dir, default_output_dir

print(model_data_dir())
print(model_cache_dir())
print(default_output_dir())

Migration note: existing models in the current working directory or legacy package models directory are still detected. For new setups, storing models in the user data directory is recommended.

Concept:

The basic idea is that any spectrograph can be modelled with a set of wavelength-dependent transformation matrices and point spread functions which describe the spectrographs' optics:

First, wavelength-dependent affine transformation matrices are extracted from the ZEMAX model of the spectrograph. As the underlying geometric transformations (scaling, rotation, shearing, translation) vary smoothly across an echelle order, these matrices can be interpolated for any intermediate wavelength.

Second, a wavelength-dependent point spread functions (PSFs) is applied on the transformed slit images to properly account for optical aberrations. Again, the PSF is only slowly varying across an echelle order, allowing for interpolation at intermediate wavelength.

Echelle simulation

Both, the matrices and the PSFs have to be extracted from ZEMAX only once. It is therefore possible to simulate spectra without access to ZEMAX

Citation

Please cite this paper if you find this work useful in your research.

Metadata

Release files for pyechelle 0.4.2

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

Source distribution (sdist)

Source distribution for pyechelle 0.4.2
File Size Uploaded
pyechelle-0.4.2.tar.gz 57.3 kB Details

Built distribution (wheel)

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

Total release size: 122.0 kB

Release files / pyechelle-0.4.2.tar.gz

Download URL pyechelle-0.4.2.tar.gz
Size 57.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4657de3500ca08e2beeb1998d65875f34720f2554c5a9c36fc23a0f3eb26dc06
BLAKE2b-256 checksum
How to use checksums
837f49ddcf27afc9bbc00683841c181da348aaf23b9eb7b1d3d8cd8bc4f73bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyechelle-0.4.2-py3-none-any.whl

Download URL pyechelle-0.4.2-py3-none-any.whl
Size 64.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fea877033c3ea15fbb1d76044c9c807668278500a96a2c06cf666a221ba54c6
BLAKE2b-256 checksum
How to use checksums
15a600b32fd553d6475b5f0df14122459d7b2818717cf5a9780ba32a58453f83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

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