synospec.etc.observe module
Module used to mimic observations.
Copyright © 2020, Kyle B. Westfall
- class synospec.etc.observe.Observation(telescope, sky_spectrum, spec_aperture, exposure_time, detector, system_throughput=None, atmospheric_throughput=None, airmass=None, onsky_source_distribution=None, source_spectrum=None, extraction=None, snr_units='pixel')[source]
Bases:
objectObservation of the sky with or without a source.
- Parameters
telescope (
Telescope) – Telescope used for the observation.sky_spectrum (
Spectrum) – Sky spectrumspec_aperture (
Aperture) – On-sky entrance aperture.exposure_time (
float) – Exposure time in seconds.detector (
Detector) – Instrument detector object.system_throughput (
Efficiency, optional) – System throughput; i.e., ratio of the number of photons detected to the total number incident on the telescope primary. If None, system throughput is unity.atmospheric_throughput (
Efficiency, optional) – Atmospheric throughput; i.e., the ratio of the number of the photons incident on the telescope primary to the number of photons hitting the top of the atmosphere. If None, assume there is no atmosphere.airmass (
float, optional) – Airmass of the observation. If None, assumeatmospheric_throughputis at the correct airmass or there is no atmosphere.onsky_source_distribution (
Source, optional) – On-sky source surface-brightness distribution, including any seeing effects. If None, assume observation is only of the sky. Normalization is irrelevant; used to calculate aperture losses.source_spectrum (
Spectrum, optional) – Spectrum of the source with the flux normalized to the total source flux.extraction (
Extraction, optional) – Object used to calculate the extraction losses and tally the number of pixels included in the extraction to get the read-noise hit. TODO: Currently cannot be None; make a required argument.snr_units (
str, optional) – Units of the S/N calculation. Must be'pixel','angstrom', or'resolution'for S/N per pixel, per angstrom, or per resolution element.
- Raises
ValueError – Raised if the requested S/N units cannot be calculated (i.e., the provided spectrum does not define the resolution meaning that the S/N per resolution element is undefined) or if the unit string for the S/N is not recognized.
- simulate(sky_only=False, sky_sub=False, sky_err=0.1)[source]
Return a simulated spectrum.
- Parameters
sky_only (
bool, optional) – Only include the sky flux in the simulated spectrum (no object flux)sky_sub (
bool, optional) – Provide the object spectrum only, but include the sky flux shot noise and additional error from the sky subtraction.sky_err (
float, optional) – The fraction of the total sky error incurred due to the sky subtraction. Should be between 0 and 1; 0 means no additional error is incurred, 1 means that the sky noise from the sky subtration is the same as the sky noise from the observation itself.
- Returns
The simulated spectrum.
- Return type
- snr(sky_sub=False, sky_err=0.1)[source]
Calculate the S/N.
- Parameters
sky_sub (
bool, optional) – Provide the object spectrum only, but include the sky flux shot noise and additional error from the sky subtraction.sky_err (
float, optional) – The fraction of the total sky error incurred due to the sky subtraction. Should be between 0 and 1; 0 means no additional error is incurred, 1 means that the sky noise from the sky subtration is the same as the sky noise from the observation itself.
- Returns
The S/N spectrum. WARNING: Here,
Spectrumis used as a container class for the S/N vector; some functionality of the class will not be valid!- Return type
- synospec.etc.observe.monochromatic_image(sky, spec_aperture, spec_kernel, platescale, pixelsize, onsky_source=None, scramble=False)[source]
Generate a monochromatic image of the sky, with or with out a source, taken by a spectrograph through an aperture.
Warning
May resample the source and spec_kernel maps.
Todo
Add effect of differential atmospheric refraction
Allow a force map size and pixel sampling
- Parameters
sky (
synospec.etc.source.OnSkySource) – Sky flux distribution.spec_aperture (
synospec.etc.aperture.Aperture) – Spectrograph aperture. Aperture is expected to be oriented with the dispersion along the first axis (e.g., the slit width is along the abcissa).spec_kernel (
synospec.etc.kernel.SpectrographGaussianKernel) – Convolution kernel describing the point-spread function of the spectrograph.platescale (
float) – Platescale in mm/arcsec at the detectorpixelsize (
float) – Size of the detector pixels in mm.onsky_source (
synospec.etc.source.OnSkySource, optional) – On-sky distribution of the source flux. If None, only sky is observed through the aperture.scramble (
bool, optional) – Fully scramble the source light passing through the aperture. This should be False for slit observations. For fiber observations, this should be True and makes the nominal assumption that the focal plane incident on the fiber face is perfectly scrambled.
- synospec.etc.observe.rectilinear_twod_spectrum(spectrum, aperture_image, dispscale, wave_lim=None, oversample=1)[source]
Construct a rectilinear 2D spectrum.
Documentation TBW.
spectral dimension of aperture_image is along the first axis
aperture_image has to be odd? dispscale is A/pixel
remove rows columns with no pixels above thresh
- synospec.etc.observe.twod_spectrum(sky_spectrum, spec_aperture, spec_kernel, platescale, linear_dispersion, pixelsize, source_distribution=None, source_spectrum=None, thresh=None, scramble=False, wave_lim=None, field_coo=None, opticalmodel=None)[source]
Documentation TBW.
- if optical model is not provided:
ignore field_coo
return rectilinear 2D spectrum
platescale is in mm/arcsec linear_dispersion is in A/mm pixelsize is in mm