This is a setup/test/demonstration notebook for the AutoExposure effect in Scopesim. The notebook uses the irdb/METIS configuration. The observed source is blank sky, except for the last example where a star of 0 mag is used (Vega).

[1]:
import scopesim as sim
sim.bug_report()

# Edit this path if you have a custom install directory, otherwise comment it out.
sim.rc.__config__["!SIM.file.local_packages_path"] = "../../../../"
Python:
 3.9.7 (default, Sep 28 2021, 17:45:03)
[GCC 9.3.0]

scopesim :  0.4.0
numpy :  1.22.3
scipy :  1.8.0
astropy :  5.0.1
matplotlib :  3.5.1
synphot :  1.1.1
skycalc_ipy : version number not available
requests :  2.27.1
bs4 :  4.10.0
yaml :  6.0

Operating system:  Linux
         Release:  5.11.0-1019-aws
         Version:  #20~20.04.1-Ubuntu SMP Tue Sep 21 10:40:39 UTC 2021
         Machine:  x86_64

If you haven’t got the instrument packages yet, uncomment the following cell.

[2]:
# sim.download_package(["instruments/METIS", "telescopes/ELT", "locations/Armazones"])

Imaging LM-band

[3]:
cmd = sim.UserCommands(use_instrument="METIS", set_modes="img_lm")
[4]:
metis = sim.OpticalTrain(cmd)
[5]:
src = sim.source.source_templates.empty_sky()
[6]:
metis.observe(src)
[7]:
outimg = metis.readout()[0][1].data
outimg /= sim.utils.from_currsys(metis['summed_exposure'].meta['ndit'])

full_well = sim.utils.from_currsys("!DET.full_well")
print("\nResult\n======")
print("Maximum value in readout (per DIT): {:8.1f}".format(outimg.max()))
print("Detector full well:                 {:8.1f}".format(full_well))
print("Fill fraction:                      {:8.1f} per cent".format(100 * outimg.max()/ full_well))
Requested exposure time: 1.000 s
Exposure parameters:
                DIT: 0.250 s  NDIT: 4
Total exposure time: 1.000 s

Result
======
Maximum value in readout (per DIT):  63486.1
Detector full well:                 100000.0
Fill fraction:                          63.5 per cent

Exposure time can be changed with an argument to metis.readout():

[8]:
outimg = metis.readout(exptime = 1000)[0][1].data
outimg /= sim.utils.from_currsys(metis['summed_exposure'].meta['ndit'])

full_well = sim.utils.from_currsys("!DET.full_well")
print("\nResult\n======")
print("Maximum value in readout (per DIT): {:8.1f}".format(outimg.max()))
print("Detector full well:                 {:8.1f}".format(full_well))
print("Fill fraction:                      {:8.1f} per cent".format(100 * outimg.max()/ full_well))
Requested exposure time: 1000.000 s
Exposure parameters:
                DIT: 0.298 s  NDIT: 3354
Total exposure time: 1000.000 s

Result
======
Maximum value in readout (per DIT):  75005.2
Detector full well:                 100000.0
Fill fraction:                          75.0 per cent

Imaging N-band

[9]:
cmd = sim.UserCommands(use_instrument="METIS", set_modes=['img_n'])
[10]:
metis = sim.OpticalTrain(cmd)
[11]:
metis.observe(src)
[12]:
outimg = metis.readout()[0][1].data
outimg /= sim.utils.from_currsys(metis['summed_exposure'].meta['ndit'])

full_well = sim.utils.from_currsys("!DET.full_well")
print("\nResult\n======")
print("Maximum value in readout (per DIT): {:9.1f}".format(outimg.max()))
print("Detector full well:                 {:9.1f}".format(full_well))
print("Fill fraction:                      {:9.1f} per cent".format(100 * outimg.max()/ full_well))
Requested exposure time: 1.000 s
Exposure parameters:
                DIT: 0.017 s  NDIT: 59
Total exposure time: 1.000 s

Result
======
Maximum value in readout (per DIT): 2091706.5
Detector full well:                 2800000.0
Fill fraction:                           74.7 per cent

Long-slit spectroscopy

[13]:
cmd = sim.UserCommands(use_instrument="METIS", set_modes=['lss_l'])
[14]:
metis = sim.OpticalTrain(cmd)
[15]:
metis.observe(src)
[16]:
outimg = metis.readout(exptime=3600.)[0][1].data
outimg /= sim.utils.from_currsys(metis['summed_exposure'].meta['ndit'])
full_well = sim.utils.from_currsys("!DET.full_well")

print("\nResult\n======")
print("Maximum value in readout (per DIT): {:8.1f}".format(outimg.max()))
print("Detector full well:                 {:8.1f}".format(full_well))
print("Fill fraction:                      {:8.1f} per cent".format(100 * outimg.max()/ full_well))
Requested exposure time: 3600.000 s
Exposure parameters:
                DIT: 6.040 s  NDIT: 596
Total exposure time: 3600.000 s

Result
======
Maximum value in readout (per DIT):  74938.9
Detector full well:                 100000.0
Fill fraction:                          74.9 per cent

What happens when the source saturates the detector?

Use N-band imaging of Vega. DIT is automatically set to the minimum possible value, but the centre of the star still saturates the detector. In the final image, the star’s profile is capped at the full well of the detector.

[17]:
cmd = sim.UserCommands(use_instrument="METIS", set_modes=["img_n"])
[18]:
metis = sim.OpticalTrain(cmd)
[19]:
src = sim.source.source_templates.star()
[20]:
metis.observe(src)
[21]:
outimg = metis.readout()[0][1].data
outimg /= sim.utils.from_currsys(metis['summed_exposure'].meta['ndit'])
full_well = sim.utils.from_currsys("!DET.full_well")

print("\nResult\n======")
print("Maximum value in readout (per DIT): {:9.1f}".format(outimg.max()))
print("Detector full well:                 {:9.1f}".format(full_well))
print("Fill fraction:                      {:9.1f} per cent".format(100 * outimg.max()/ full_well))
Requested exposure time: 1.000 s
Warning: The detector will be saturated!
Exposure parameters:
                DIT: 0.011 s  NDIT: 90
Total exposure time: 0.990 s

Result
======
Maximum value in readout (per DIT): 2800083.5
Detector full well:                 2800000.0
Fill fraction:                          100.0 per cent

Plot a cut through the star to show how its peak saturates the detector.

[22]:
from matplotlib import pyplot as plt
%matplotlib inline
[23]:
plt.plot(outimg[950:1100, 1024])
[23]:
[<matplotlib.lines.Line2D at 0x7f27c79637c0>]
../../../../_images/METIS_docs_example_notebooks_demos_demo_auto_exposure_30_1.png
[24]:
npix = (outimg >= full_well).sum()
print("Number of saturated pixels:", npix)
Number of saturated pixels: 33