VirtualLazuliTarget#
- class VirtualLazuliTarget[source]#
Bases:
objectMixin adding the Lazuli instrument and its two fields to a target.
This class is not meant to be used directly: it is combined with one of the generic targets of
target(e.g.LazuliSupernovainherits fromVirtualLazuliTargetandSupernova). It sets the Lazuli instrument configuration and adds the handling of the narrow and wide fields (change_spectrograph,get_spectrograph_field,get_cube,to_image).- Parameters:
simulation (
slicersim.simulation.Simulation, optional) – The simulation the target wraps. Default is None.
Methods
Change the Lazuli instrument configuration.
Change the spectrograph configuration.
Load the instance from a scene configuration.
Get the simulated cubes, for one or both Lazuli fields.
Project the narrow and wide field cubes onto a single detector image.
Get the current MACC mode and number of ramps.
Get the current spectrograph field.
Show the narrow and wide field cubes, collapsed over a wavelength range.
Project the narrow and wide field cubes onto a single detector image.
- change_configuration(which)[source]#
Change the Lazuli instrument configuration.
The corresponding configuration file (
lazuli_eol.tomlorlazuli_cbe.toml) is read and the simulation updated with it.
- change_spectrograph(field=None, spatial_shape=None, spatial_scale=None)[source]#
Change the spectrograph configuration.
- Parameters:
field (
str, optional) –Lazuli field to use (see
SPECTROGRAPH_FIELD):"narrow": finely sampled field, with 0.04 arcsec spaxels."wide": coarser field, with 0.08 arcsec spaxels.
If None, only
spatial_shapeandspatial_scaleare applied. Default is None.spatial_shape (
tupleofint, optional) – Spaxel grid shape (e.g.(40, 40)), overriding that offieldif any. Default is None.spatial_scale (
floatorlistoffloat, optional) – Spaxel size in arcsec, overriding that offieldif any. If a float, spaxels are square; if a list,(x, y). Default is None.
- Returns:
- Raises:
ValueError – If
fieldis not a known Lazuli field.
- classmethod from_scene(scene=None, **kwargs)[source]#
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.
**kwargs – Goes to
get_config, overriding thesceneand the Lazuliinstrumentconfiguration.
- Returns:
VirtualLazuliTarget– An instance of the class.
- get_cube(which='both', **kwargs)[source]#
Get the simulated cubes, for one or both Lazuli fields.
- Parameters:
- Returns:
tuple–(cube, varcube), the cube (ADU) and variance cube (ADU^2) of the requested field, or, ifwhich="both",((cube_narrow, varcube_narrow), (cube_wide, varcube_wide)).- Raises:
ValueError – If
whichis not"current"while the spectrograph is set up neither as the narrow nor the wide field.NotImplementedError – If the scene contains a host (not yet supported).
Notes
When switching field, the point source position is converted to the spaxel units of the other field. The original spectrograph setup and position are restored afterwards.
- get_detector_image(mapper, cubes=None, **kwargs)[source]#
Project the narrow and wide field cubes onto a single detector image.
Deprecated since version 1.1.1: Use
to_imageinstead, which this simply forwards to.- Parameters:
mapper (
slicersim.mapper.SlicerMapper) – Mapper describing where each slice falls on the detector.cubes (
tupleofnumpy.ndarray, optional) –(cube_narrow, cube_wide)to project. Default is None.**kwargs – Goes to
to_image.
- Returns:
numpy.ndarray– 2D detector image.- Warns:
UserWarning – Always, since this method is deprecated in favour of
to_image.
- get_readout_config()[source]#
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_spectrograph_field()[source]#
Get the current spectrograph field.
- Returns:
field (
str) – Name of the current field ("narrow"or"wide"), or"unknown"if the spectrograph matches neither (seespectroconfig_to_fieldname).config (
dict) – Current"spatial_shape"and"spatial_scale"(arcsec) of the spectrograph.
- show_cube(cubes, lbda_range, axes=None, ref_field='narrow', **kwarg)[source]#
Show the narrow and wide field cubes, collapsed over a wavelength range.
Each cube is summed over the wavelength bins within
lbda_range, and the two resulting images are displayed following the Lazuli layout: the narrow field on top of the wide field, separated by the gap between the two fields (SPECTROGRAPH_FIELD["hspace"]).- Parameters:
cubes (
tupleofnumpy.ndarray) –(cube_narrow, cube_wide), the cubes of each field, with wavelength as first axis (e.g. the cubes returned byget_cube(which="both"), without their variance).lbda_range (
listoffloat) – Wavelength range[min, max]in Angstrom (observer-frame) over which the cubes are summed. Bounds are excluded.axes (
tupleofmatplotlib.axes.Axes, optional) –(ax_narrow, ax_wide), the axes to draw the narrow and wide fields into. If None, a new figure is created with the Lazuli layout (see_get_fieldlayout_). Default is None.ref_field (
str, optional) – Field whose image sets the colour normalisation (99.8 percentile interval with an asinh stretch) shared by both images:"narrow"or"wide". Default is"narrow".**kwarg – Goes to
matplotlib.axes.Axes.imshow, overriding the default display properties (origin,norm,interpolation,aspectandcmap).
- Returns:
matplotlib.figure.Figure– The figure containing the axes.
Notes
The wide field axes is repositioned right below the narrow field axes, so its original position is changed even when
axesis given.Examples
>>> (cube_n, _), (cube_w, _) = target.get_cube(which="both") >>> fig = target.show_cube((cube_n, cube_w), lbda_range=[5000, 6000])
- to_image(mapper, cubes=None, **kwargs)[source]#
Project the narrow and wide field cubes onto a single detector image.
Both fields are generated, then each is projected onto the slices it occupies: the narrow field fills the first
nslices_narrowslices and the wide field the ones immediately above. The two projections are summed into one image.- Parameters:
mapper (
slicersim.mapper.SlicerMapper) – Mapper describing where each slice falls on the detector.cubes (
tupleofnumpy.ndarray, optional) –(cube_narrow, cube_wide)to project, to avoid regenerating them. If None, both are generated withget_cube(which="both"). Default is None.**kwargs – Goes to
get_cube. Ignored ifcubesis given.
- Returns:
numpy.ndarray– 2D detector image, summing the narrow and wide field contributions.
Notes
The slice identifiers are reversed (
[::-1]) before being handed to the mapper, because the mapper numbers slices from the top of the detector while the cubes are ordered from the bottom.