Flat3DCalibration#
- class Flat3DCalibration(simulation=None)[source]#
Bases:
VirtualFlat3D flat-field calibration target, from a spatially uniform source.
Wraps a
Simulationwhose scene contains only a background component (no point source, no host), so that the full IFU field is illuminated uniformly, for wavelength-dependent flat-field calibration. It is normally built withfrom_spectrum,from_blackbodyorfrom_febryperot.- Parameters:
simulation (
slicersim.simulation.Simulation, optional) – The simulation the target wraps. Default is None.
See also
slicersim.lazuli.Lazuli3DFlatThe Lazuli flavour of this target.
Methods
Change the detector read-out configuration.
Change any mutable parameter of the simulation.
Change the spectrograph configuration.
Build a 3D flat calibration target from a blackbody lamp.
Build a 3D flat calibration target from a blackbody seen through a Fabry-Perot.
Load the instance from a scene configuration.
Load the instance from an already-built simulation.
Build a 3D flat calibration target from a reference spectrum.
Get the signal-to-noise ratio over a wavelength range.
Get the simulated cube in the current configuration.
Get the data volume of the observation.
Not implemented for the generic VirtualTarget class.
Get the exposure time of the current configuration.
Get parameter values of the target's simulation.
Get the current MACC mode and number of ramps.
Not implemented for the generic VirtualFlat class.
Get the contribution of each noise source to the variance.
Not implemented for the generic VirtualFlat class.
Project the simulated cube onto a detector image.
Attributes
Names of the mutable parameters of the point source (list of str).
The
Simulationwrapped by the target.- change_detector(nmd=None, max_group=None, nramps=None)#
Change the detector read-out configuration.
Parameters set to None are left unchanged.
- change_properties(**kwargs)#
Change any mutable parameter of the simulation.
Shortcut to
update.- Parameters:
**kwargs – The parameters to change, as
name=value(e.g.redshift=0.5orpointsource__phase=-2).- Returns:
- change_spectrograph(spatial_shape=None, spatial_scale=None)#
Change the spectrograph configuration.
- Parameters:
- Returns:
- classmethod from_blackbody(temperature, instrument=None, mag=15, band='sdssr', magsys='ab', lbda_range=[3000, 20000], lbda_bin=2000, **kwargs)[source]#
Build a 3D flat calibration target from a blackbody lamp.
- Parameters:
temperature (
float) – Temperature of the blackbody in Kelvin.instrument (
strordict, optional) – Instrument configuration (file name or dict). If None, the class default_INSTRUMENTis used. Default is None.mag (
float, optional) – Magnitude the blackbody spectrum is normalised to. Default is 15.band (
str, optional) – Name of the bandpass used for the normalisation (any sncosmo bandpass name). Default is"sdssr".magsys (
str, optional) – Name of the sncosmo magnitude system. Default is"ab".lbda_range (
listoffloat, optional) –[min, max]wavelength range in Angstrom. Default is[3_000, 20_000].lbda_bin (
int, optional) – Number of wavelength samples. Default is 2000.**kwargs – Goes to
from_spectrum.
- Returns:
Flat3DCalibration– An instance of the class.- Raises:
ValueError – If no instrument is given and the class defines no default
_INSTRUMENT.
See also
slicersim.scene.sources.blackbody.get_blackbody_fluxThe blackbody source.
- classmethod from_febryperot(temperature, fp_throughput, instrument=None, mag=15, band='sdssr', magsys='ab', lbda_range=[3000, 20000], lbda_bin=2000, **kwargs)[source]#
Build a 3D flat calibration target from a blackbody seen through a Fabry-Perot.
The blackbody continuum is multiplied by the Fabry-Perot transmission, which turns it into the comb of spectral features used for wavelength calibration.
- Parameters:
temperature (
float) – Temperature of the blackbody in Kelvin.fp_throughput (callable) – Fabry-Perot transmission as a function of wavelength in Angstrom.
instrument (
strordict, optional) – Instrument configuration (file name or dict). If None, the class default_INSTRUMENTis used. Default is None.mag (
float, optional) – Magnitude the blackbody spectrum is normalised to, before the Fabry-Perot transmission is applied. Default is 15.band (
str, optional) – Name of the bandpass used for the normalisation (any sncosmo bandpass name). Default is"sdssr".magsys (
str, optional) – Name of the sncosmo magnitude system. Default is"ab".lbda_range (
listoffloat, optional) –[min, max]wavelength range in Angstrom. Default is[3_000, 20_000].lbda_bin (
int, optional) – Number of wavelength samples. Default is 2000.**kwargs – Goes to
from_spectrum.
- Returns:
Flat3DCalibration– An instance of the class.- Raises:
ValueError – If no instrument is given and the class defines no default
_INSTRUMENT.
See also
from_blackbodySame source, without the Fabry-Perot etalon.
- classmethod from_scene(scene=None, instrument=None, **kwargs)#
Load the instance from a scene configuration.
- Parameters:
scene (
dictorstr, optional) –Scene configuration (see
get_scene), in the format:scene = {"scene": {"pointsource": {}, # PSF "background": {}, # spatially flat "host": {}}} # structured background
or the name of a scene configuration file. Default is None.
instrument (
strordict, optional) – Configuration of the instrument, if any. If None, the class_INSTRUMENTis used when defined. Default is None.**kwargs – Goes to
get_config, overriding thesceneandinstrumentconfiguration.
- Returns:
VirtualTarget– An instance of the class.
- classmethod from_simulation(simulation)#
Load the instance from an already-built simulation.
- Parameters:
simulation (
slicersim.simulation.Simulation) – The simulation the target wraps.- Returns:
VirtualTarget– An instance of the class.
See also
from_sceneBuild the simulation from a scene configuration.
- classmethod from_spectrum(lbda, flux, instrument=None, **kwargs)[source]#
Build a 3D flat calibration target from a reference spectrum.
The spectrum is loaded as a spatially uniform
Background, and the scene is built with neither point source nor host, so that the full IFU field is illuminated uniformly.- Parameters:
lbda (array_like) – Wavelength array in Angstrom.
flux (array_like) – Flux of the reference spectrum in erg/s/cm^2/A.
instrument (
strordict, optional) – Instrument configuration (file name or dict). If None, the class default_INSTRUMENTis used. Default is None.**kwargs – Goes to
from_spectrum, overriding the defaultsmag=None,band="bessellb"andmeta={}.
- Returns:
Flat3DCalibration– An instance of the class, wrapping the corresponding simulation.- Raises:
ValueError – If no instrument is given and the class defines no default
_INSTRUMENT.
Notes
magdefaults to None, so the reference spectrum keeps its native amplitude and is not photometrically renormalised.
- get_band_snr(lbda_range, frame='obs', per_resolution=True, statistic=<function nanmean>, **kwargs)#
Get the signal-to-noise ratio over a wavelength range.
- Parameters:
lbda_range (
tupleoffloatorlistoftuple) – Wavelength range(min, max)in Angstrom (or a list of them).frame (
str, optional) – Reference frame oflbda_range:"rest"or"obs". Default is"obs".per_resolution (
bool, optional) – If True, return the SNR per spectral resolution element, otherwise per wavelength bin. Default is True.statistic (callable, optional) – Function used to summarise the signal and variance over
lbda_range. Default isnumpy.nanmean.**kwargs – Goes to
get_band_snr(e.g.switch_off).
- Returns:
floatornumpy.ndarray– The SNR, one per wavelength range if a list is given. If any detector pixel saturates,numpy.infis returned.
- get_cube()#
Get the simulated cube in the current configuration.
- Returns:
cube (
numpy.ndarray) – Data cube in ADU, of shape(nlbda, ny, nx).varcube (
numpy.ndarray) – Variance cube in ADU^2, same shape.
See also
get_cubeThe underlying method.
- get_data_volume(units='GB', per_ramp=False)#
Get the data volume of the observation.
- Parameters:
- Returns:
float– Data volume inunits.
See also
get_data_volumeThe underlying method.
- get_detector_image(mapper, cubes=None, **kwargs)#
Not implemented for the generic VirtualTarget class.
- Parameters:
mapper (
slicersim.mapper.SlicerMapper) – Mapper describing where each slice falls on the detector.cubes (
tuple, optional) – Pre-computed cubes to project, to avoid regenerating them. Default is None.**kwargs – Goes to the subclass implementation.
- Raises:
NotImplementedError – Always raised; the projection depends on how the instrument lays its fields out on the detector, so instrument-specific subclasses must override this method. See e.g.
VirtualLazuliTarget.
- get_exposure_time(snr=None, full=False, **kwargs)#
Get the exposure time of the current configuration.
- Parameters:
snr (
float, optional) – Currently has no effect on the returned time:setup_to_snris called withinplace=False, so the configuration used for the exposure time remains the current one. Default is None.full (
bool, optional) – If True, return all timing details; otherwise only the total exposure time. Default is False.**kwargs – Goes to
setup_to_snr. Ignored ifsnris None.
- Returns:
floatordict– Total exposure time in seconds (all ramps included), or, iffullis True, a dict of times in seconds with keys"integration_time","exposure_time"(one ramp),"tframe","tgroup"and"total_exptime".
- get_properties(which, default=None, as_dict=True)#
Get parameter values of the target’s simulation.
Shortcut to
get_parameter.- Parameters:
which (
strorlistofstr) – Name(s) of the parameter(s), e.g."redshift"or["nmd", "nramps"].default (
object, optional) – Value returned if a parameter is not found. Default is None.as_dict (
bool, optional) – Only used whenwhichis a single name that is not found: if True,{which: default}is returned instead ofdefault. Default is True.
- Returns:
objectordict– The parameter value ifwhichis a str, a dict{name: value}if it is a list.
- get_readout_config()#
Get the current MACC mode and number of ramps.
- Returns:
dict– Read-out configuration, with keys:"nmd":(n_groups, n_frames_per_group, n_drops)."nramps": number of ramps, each ramp following thenmdMACC mode.
- get_spectrum(*args, **kwargs)#
Not implemented for the generic VirtualFlat class.
- Parameters:
*args – Ignored.
**kwargs – Ignored.
- Raises:
NotImplementedError – Always raised; subclasses must override this method.
- get_variance_contribution()#
Get the contribution of each noise source to the variance.
- Returns:
pandas.DataFrame– One row per wavelength, with columns"lbda"(Angstrom),"flux"and"variance"(ADU, ADU^2), and one column per variance source (seevariance_sources, e.g."dark","ron","pointsource","background","thermal") giving its contribution to the variance in ADU^2.
- setup_to_snr(*args, **kwargs)#
Not implemented for the generic VirtualFlat class.
- Parameters:
*args – Ignored.
**kwargs – Ignored.
- Raises:
NotImplementedError – Always raised; subclasses must override this method.
- to_image(mapper, sliceid, image=None, **kwargs)#
Project the simulated cube onto a detector image.
- Parameters:
mapper (
slicersim.mapper.SlicerMapper) – Mapper describing where each slice falls on the detector.sliceid (
intor array_like) – Identifier(s) of the slice(s) the cube is projected onto.image (
numpy.ndarray, optional) – Existing detector image this projection is added to. If None, only the contribution of this target is returned. Default is None.**kwargs – Goes to
get_cube. The genericget_cubeaccepts none; use them with subclasses such asVirtualLazuliTarget.
- Returns:
numpy.ndarray– 2D detector image. Whenimageis given, the sum ofimageand of the projected cube;imageitself is left unchanged.
- pointsource_properties#
Names of the mutable parameters of the point source (list of str).
- simulation#
The
Simulationwrapped by the target.