SynthImage#
- class specreduce.utils.synth_data.SynthImage(nx: int = 3000, ny: int = 1000, wcs: WCS | None = None, extent=(3500, 7000), wave_unit: Unit = Unit('Angstrom'), seed: int | None = None)[source]#
Bases:
objectImmutable, composable builder for synthetic 2D spectroscopic images.
Build an image by chaining
add_*methods, then render it with one of theto_*terminal methods. Eachadd_*returns a newSynthImage; the original is never mutated, so a base configuration can be safely branched.- Parameters:
- nx
Size of the image along the X (dispersion) axis.
- ny
Size of the image along the Y (spatial) axis.
- wcs
Optional 2D WCS with a single spectral axis. If not provided and arc layers are present, a linear
WAVE/PIXELWCS is built fromextentandwave_unit.- extent
Beginning and end wavelengths used to build a default WCS when
wcsis not supplied and arc layers are present.- wave_unit
Wavelength unit for the default WCS.
- seed
Seed for the random number generator used by the noise layers. If
None, noise is non-deterministic.
Examples
Build a traced continuum source with background and noise, then render it:
from astropy.modeling import models from specreduce.utils.synth_data import SynthImage image = ( SynthImage(nx=1024, ny=400, seed=42) .add_background(5) .add_source(profile=models.Moffat1D(amplitude=20, alpha=0.1)) .add_poisson_noise() .add_read_noise(3) .to_ccddata() )
See the Synthetic Data guide for more examples, including tilted arc lines and modeling a non-linear dispersion relation.
Methods Summary
add_arcs([linelists, line_fwhm, ...])Add emission lines from one or more pypeit calibration line lists.
add_background(level)Add a constant background level (counts).
Apply Poisson noise to the rendered signal (requires photutils).
add_rdnoise(sigma)Add Gaussian read noise of standard deviation
sigma(counts).add_read_noise(sigma)Add Gaussian read noise of standard deviation
sigma(counts).add_skylines([linelists])Add night-sky airglow emission lines (OH lists), wrapping
add_arcs.add_source([profile, trace_center, ...])Add a source with a Chebyshev-traced spatial profile.
to_array()Render and return the image as a plain
numpy.ndarray(counts).Render and return the image as a
CCDData.Render and return the image as a
Spectrum.Methods Documentation
- add_arcs(linelists=('HeI',), line_fwhm: float = 5.0, amplitude_scale: float = 1.0, wave_air: bool = False, tilt_func: Model = None) SynthImage[source]#
Add emission lines from one or more pypeit calibration line lists.
- add_background(level: float) SynthImage[source]#
Add a constant background level (counts).
- add_poisson_noise() SynthImage[source]#
Apply Poisson noise to the rendered signal (requires photutils).
- add_rdnoise(sigma: float) SynthImage#
Add Gaussian read noise of standard deviation
sigma(counts).
- add_read_noise(sigma: float) SynthImage[source]#
Add Gaussian read noise of standard deviation
sigma(counts).
- add_skylines(linelists='OH_GMOS', **kwargs) SynthImage[source]#
Add night-sky airglow emission lines (OH lists), wrapping
add_arcs.
- add_source(profile: Model = None, trace_center: float | None = None, trace_order: int = 3, trace_coeffs: dict | None = None, spectrum: Spectrum = None) SynthImage[source]#
Add a source with a Chebyshev-traced spatial profile.
- Parameters:
- profile
Astropy model describing the cross-dispersion spatial profile of the source. Defaults to
Moffat1D(amplitude=10, alpha=0.1).- trace_center
Central cross-dispersion position of the trace. Defaults to the middle of the image.
- trace_order
Polynomial order of the Chebyshev trace.
- trace_coeffs
Coefficients of the Chebyshev trace, e.g.
{"c0": 0, "c1": 50}.- spectrum
Optional 1D
Spectrumdescribing the dispersion-axis flux of the source. Its flux is resampled onto the image wavelength grid (requiring a resolvable WCS) and normalized so its peak within the image extent is one. Wavelengths outside the spectrum’s range are set to zero. The normalized flux multiplies the spatial profile column by column, so the source amplitude varies with wavelength. WhenNone(default) the source has a flat continuum.