In the notebook LSS_AGN-01_preparation we prepared a simulated data cube of an AGN for “observation” with Scopesim/METIS. If you do not have the files AGN_sim_prepared.fits and AGN_sim_rotated_50.fits, please run the first notebook before proceeding.

[ ]:
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm
%matplotlib inline
[ ]:
import scopesim as sim
sim.bug_report()

# Edit this path if you have a custom install directory, otherwise comment it out. [For ReadTheDocs only]
sim.rc.__config__["!SIM.file.local_packages_path"] = "../../../"

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

[ ]:
# sim.download_package(["instruments/METIS", "telescopes/ELT", "locations/Armazones"])
[ ]:
cmd = sim.UserCommands(use_instrument="METIS", set_modes=['lss_n'],
                      properties={"!OBS.exptime": 3600,
                                 "!SIM.spectral.spectral_bin_width": 3.0e-3})
metis = sim.OpticalTrain(cmd)

Create two Source objects from the files. The first one is with the original field orientation, the second one has the field rotated by 50 degrees. We also define a Source that represents blank sky for background subtraction.

[ ]:
cube_01 = "AGN_sim_prepared.fits"
cube_02 = "AGN_sim_rotated_50.fits"

src_01 = sim.Source(cube=cube_01)
src_02 = sim.Source(cube=cube_02)

sky = sim.source.source_templates.empty_sky()

We observe each of the two sources and the blank sky; this takes a few minutes.

[ ]:
metis.observe(src_01, update=True)
hdul_01 = metis.readout(detector_readout_mode="auto")[0]
[ ]:
metis.observe(src_02, update=True)
hdul_02 = metis.readout(detector_readout_mode="auto")[0]
[ ]:
metis.observe(sky, update=True)
hdul_sky = metis.readout(detector_readout_mode="auto")[0]

The difference between the background-subtracted 2D-spectra of the two sources is significant. Compare to the images in the first notebook, LSS_AGN-01_preparation.ipynb.

[ ]:
plt.figure(figsize=(16, 8))
plt.subplot(121)
plt.imshow(hdul_01[1].data - hdul_sky[1].data + 1e5, origin='lower', norm=LogNorm(vmin=1e5, vmax=5e8))
plt.subplot(122)
plt.imshow(hdul_02[1].data - hdul_sky[1].data + 1e5, origin='lower', norm=LogNorm(vmin=1e5, vmax=5e8))

Save the simulation results in FITS files for analysis with external tools.

[ ]:
hdul_01.writeto("AGN_prepared-scopesim_lss_n.fits", overwrite=True)
hdul_02.writeto("AGN_rotated_50-scopesim_lss_n.fits", overwrite=True)
hdul_sky.writeto("AGN_background-scopesim_lss_n.fits", overwrite=True)