Lazuli targets#
The LazuliTarget family of classes is the top-level interface to simulate Lazuli observations.
They let you set up the instrument to reach a desired spectrum quality (setup_to_snr()),
access the expected spectrum (get_spectrum()), change the target or instrument properties, etc.
Several flavours are available:
LazuliTarget: the most generic one, provide any spectrum you want;LazuliSupernova: a type Ia supernova, simply provide the SN properties;LazuliKilonova: a kilonova (see the dedicated notebook);LazuliCalSpec: an HST CalSpec standard star, simply provide its name;LazuliBlackBody: a blackbody of a given temperature.
They all share the same methods.
Note
A LazuliTarget is also what slicersim.lazuli_etc() returns, together with the exposure time:
exptime, lazuli_target = slicersim.lazuli_etc(lbda, flux, snr=20)
import slicersim
Any Target#
import numpy as np
# a fake flat spectrum
lbda = np.arange(3_000, 20_000, 0.5) # every 0.5 Å
flux = np.ones(lbda.shape)
Create a LazuliTarget#
You can set the target magnitude (e.g. 20 mag in "lsstg") when creating the object.
%%time
target = slicersim.LazuliTarget(lbda, flux, mag=20, band="lsstg")
CPU times: user 281 ms, sys: 36.8 ms, total: 318 ms
Wall time: 319 ms
Set up the instrument#
setup_to_snr() finds the detector readout configuration that reaches the requested
signal-to-noise ratio (SNR). Here we ask for an SNR of 15 per wavelength bin between
5000 Å and 8000 Å, using statistic=np.min so that this is the minimum SNR in that range
(the default statistic is the mean).
This takes a few seconds, the time to find the best configuration.
# setup_to_snr sets the target's detector to the found configuration,
# and returns this configuration together with the reached snr
read_config, snr = target.setup_to_snr(15, per_resolution=False,
lbda_range=[5000, 8000],
statistic=np.min)
snr
np.float64(14.777368231980565)
Get the spectrum#
You can now access the spectrum as it would be observed by Lazuli.
It can be returned in several units, e.g. "adu" (default) or "flambda" (erg/s/cm²/Å),
see get_spectrum(). With incl_error=True (default), the flux is a random realisation
given the variance; with incl_error=False, the noise-free flux is returned.
lbda, flux, variance = target.get_spectrum(unit="adu")
lbda, flux_nonoise, variance_nonoise = target.get_spectrum(unit="adu",
incl_error=False)
The variance is the same in both cases, only the flux differs:
(variance==variance_nonoise).all()
np.True_
import matplotlib.pyplot as plt
fig, (ax, ax_nonoise) = plt.subplots(nrows=2, sharex=True)
# noise applied to the flux (realistic)
ax.plot(lbda, flux, lw=1)
ax.fill_between(lbda,
flux + np.sqrt(variance),
flux - np.sqrt(variance), alpha=0.5)
ax.set_title("incl_error=True", loc="left", fontsize="small")
# noise not applied to the flux ('truth')
ax_nonoise.plot(lbda, flux_nonoise, lw=1)
ax_nonoise.fill_between(lbda,
flux_nonoise + np.sqrt(variance),
flux_nonoise - np.sqrt(variance), alpha=0.5)
ax_nonoise.set_title("incl_error=False", loc="left", fontsize="small")
ax_nonoise.set_xlabel("wavelength [Å]")
fig.supylabel("flux [adu]")
Text(0.02, 0.5, 'flux [adu]')
CalSpec standard star#
Reference stars, notably the flux-calibrated HST CalSpec stars, are routinely observed to calibrate the survey.
LazuliCalSpec loads such a star directly from its CalSpec name.
For instance, let us load BD+17°4708 ("bd_17").
lazuli_bd17 = slicersim.LazuliCalSpec("bd_17")
# Say we want an average SNR of 40 per resolution element between 4000 Å and 8000 Å
_ = lazuli_bd17.setup_to_snr(40, lbda_range=[4_000, 8_000])
Use unit="flambda" in get_spectrum() to get the spectrum in physical units.
lbda, flux, variance = lazuli_bd17.get_spectrum(unit="flambda")
fig, ax = plt.subplots()
# noise applied to the flux (realistic)
ax.plot(lbda, flux, lw=1)
ax.fill_between(lbda,
flux + np.sqrt(variance),
flux - np.sqrt(variance), alpha=0.5)
ax.set_xlabel("wavelength [Å]")
ax.set_ylabel("flux [erg/s/cm$^2$/Å]")
Text(0, 0.5, 'flux [erg/s/cm$^2$/Å]')
The names of all available CalSpec stars are listed by source_names:
sorted(set(lazuli_bd17.source_names) - {""})
['109vir',
'10lac',
'16cygb',
'1732526',
'1740346',
'1743045',
'1757132',
'1802271',
'1805292',
'1808347',
'1812095',
'1812524',
'18sco',
'2m003618',
'2m055914',
'agk_81d266',
'alpha_lyr',
'bd02d3375',
'bd11d3759',
'bd21d0607',
'bd26d2606',
'bd29d2091',
'bd54d1216',
'bd60d1753',
'bd_17d4708',
'bd_28d4211',
'bd_75d325',
'c26202',
'delumi',
'eta1dor',
'etauma',
'feige110',
'feige34',
'g191b2b',
'gd140',
'gd153',
'gd50',
'gd71',
'gj7541a',
'grw_70d5824',
'hd009051',
'hd031128',
'hd074000',
'hd101452',
'hd106252',
'hd111980',
'hd115169',
'hd116405',
'hd128998',
'hd142331',
'hd14943',
'hd158485',
'hd159222',
'hd160617',
'hd163466',
'hd165459',
'hd167060',
'hd172728',
'hd180609',
'hd185975',
'hd200654',
'hd200775',
'hd205905',
'hd209458',
'hd2811',
'hd37725',
'hd37962',
'hd38949',
'hd55677',
'hd60753',
'hd93521',
'hs2027',
'hz14',
'hz2',
'hz21',
'hz4',
'hz43',
'hz43b',
'hz44',
'kf01t5',
'kf06t1',
'kf06t2',
'kf08t3',
'ksi2ceti',
'lamlep',
'lds749b',
'mucol',
'ngc2506g31',
'ngc6681_1',
'ngc6681_10',
'ngc6681_11',
'ngc6681_12',
'ngc6681_2',
'ngc6681_3',
'ngc6681_4',
'ngc6681_5',
'ngc6681_6',
'ngc6681_7',
'ngc6681_8',
'ngc6681_9',
'p041c',
'p177d',
'p330e',
'sdss132811',
'sdssj151421',
'sf1615_001a',
'sigori',
'sirius',
'snap1',
'snap2',
'sun',
'sun_reference',
'vb8',
'wd0148_467',
'wd0227_050',
'wd0308_565',
'wd0320_539',
'wd0809_177',
'wd0859_039',
'wd0947_857',
'wd1026_453',
'wd1031_114',
'wd1052_273',
'wd1057_719',
'wd1105_048',
'wd1105_340',
'wd1202_232',
'wd1327_083',
'wd1446_286',
'wd1544_377',
'wd1657_343',
'wd1713_695',
'wd1911_536',
'wd1919_145',
'wd2039_202',
'wd2039_682',
'wd2051_208',
'wd2117_539',
'wd2126_734',
'wd2149_021',
'wd2341_322',
'wdfs0122_30',
'wdfs0248_33',
'wdfs0458_56',
'wdfs0639_57',
'wdfs0956_38',
'wdfs1055_36',
'wdfs1110_17',
'wdfs1206_27',
'wdfs1214_45',
'wdfs1302_10',
'wdfs1434_28',
'wdfs1514_00',
'wdfs1535_77',
'wdfs1557_55',
'wdfs1814_78',
'wdfs1837_70',
'wdfs1930_52',
'wdfs2317_29',
'wdfs2351_37']
Supernovae#
Supernovae are the core targets of the Lazuli spectrograph. LazuliSupernova builds the
target directly from the SN properties (redshift, SALT stretch x1 and color c, …).
lazuli_snia = slicersim.LazuliSupernova(redshift=0.9, x1=1.2, c=0.2)
# Say we want an average SNR of 20 per resolution element between 6000 Å and 7000 Å rest-frame
_ = lazuli_snia.setup_to_snr(20, lbda_range=[6000, 7000], frame="rest")
# get the noise-free flux (incl_error=False) with its expected variance
lbda, flux, variance = lazuli_snia.get_spectrum(unit="flambda", incl_error=False)
fig, ax = plt.subplots()
ax.plot(lbda, flux, lw=1)
ax.fill_between(lbda,
flux + np.sqrt(variance),
flux - np.sqrt(variance), alpha=0.5)
ax.set_xlabel("wavelength [Å]")
ax.set_ylabel("flux [erg/s/cm$^2$/Å]")
Text(0, 0.5, 'flux [erg/s/cm$^2$/Å]')
Get the exposure time#
You can get the exposure time associated with the current configuration at any time:
lazuli_snia.get_exposure_time() # in seconds
5795.84
Use full=True to get the timing details (frame time, group time, etc.):
lazuli_snia.get_exposure_time(full=True) # in seconds
{'integration_time': 1426.32,
'exposure_time': 1448.96,
'tframe': 2.83,
'tgroup': 22.64,
'total_exptime': 5795.84}
Detector readout mode#
The detector readout configuration is returned by setup_to_snr(), and you can also
access it at any time:
lazuli_snia.get_readout_config()
{'nmd': (64, 8, 0), 'nramps': 4}
By default, a single ramp can have at most 64 groups. You can change that using
change_detector(); see the notebook on changing the detector and spectrograph.