{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "from matplotlib.colors import LogNorm\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import scopesim as sim\n", "sim.bug_report()\n", "\n", "# Edit this path if you have a custom install directory, otherwise comment it out. [For ReadTheDocs only]\n", "sim.rc.__config__[\"!SIM.file.local_packages_path\"] = \"../../../\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you haven't got the instrument packages yet, uncomment the following cell." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# sim.download_package([\"instruments/METIS\", \"telescopes/ELT\", \"locations/Armazones\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=['lss_n'],\n", " properties={\"!OBS.exptime\": 3600,\n", " \"!SIM.spectral.spectral_bin_width\": 3.0e-3})\n", "metis = sim.OpticalTrain(cmd)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cube_01 = \"AGN_sim_prepared.fits\"\n", "cube_02 = \"AGN_sim_rotated_50.fits\"\n", "\n", "src_01 = sim.Source(cube=cube_01)\n", "src_02 = sim.Source(cube=cube_02)\n", "\n", "sky = sim.source.source_templates.empty_sky()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We observe each of the two sources and the blank sky; this takes a few minutes." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src_01, update=True)\n", "hdul_01 = metis.readout(detector_readout_mode=\"auto\")[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src_02, update=True)\n", "hdul_02 = metis.readout(detector_readout_mode=\"auto\")[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(sky, update=True)\n", "hdul_sky = metis.readout(detector_readout_mode=\"auto\")[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(16, 8))\n", "plt.subplot(121)\n", "plt.imshow(hdul_01[1].data - hdul_sky[1].data + 1e5, origin='lower', norm=LogNorm(vmin=1e5, vmax=5e8))\n", "plt.subplot(122)\n", "plt.imshow(hdul_02[1].data - hdul_sky[1].data + 1e5, origin='lower', norm=LogNorm(vmin=1e5, vmax=5e8))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Save the simulation results in FITS files for analysis with external tools." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hdul_01.writeto(\"AGN_prepared-scopesim_lss_n.fits\", overwrite=True)\n", "hdul_02.writeto(\"AGN_rotated_50-scopesim_lss_n.fits\", overwrite=True)\n", "hdul_sky.writeto(\"AGN_background-scopesim_lss_n.fits\", overwrite=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 4 }