{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "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)." ] }, { "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.\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_packages([\"METIS\", \"ELT\", \"Armazones\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Imaging LM-band" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=[\"img_lm\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis = sim.OpticalTrain(cmd)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "src = sim.source.source_templates.empty_sky()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "outimg = metis.readout()[0][1].data \n", "outimg /= metis.cmds[metis['summed_exposure'].meta['ndit']]\n", "\n", "full_well = metis.cmds[\"!DET.full_well\"]\n", "print(\"\\nResult\\n======\")\n", "print(\"Maximum value in readout (per DIT): {:8.1f}\".format(outimg.max()))\n", "print(\"Detector full well: {:8.1f}\".format(full_well))\n", "print(\"Fill fraction: {:8.1f} per cent\".format(100 * outimg.max()/ full_well))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Exposure time can be changed with an argument to `metis.readout()`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "outimg = metis.readout(exptime = 1000)[0][1].data \n", "outimg /= metis.cmds[metis['summed_exposure'].meta['ndit']]\n", "\n", "full_well = metis.cmds[\"!DET.full_well\"]\n", "print(\"\\nResult\\n======\")\n", "print(\"Maximum value in readout (per DIT): {:8.1f}\".format(outimg.max()))\n", "print(\"Detector full well: {:8.1f}\".format(full_well))\n", "print(\"Fill fraction: {:8.1f} per cent\".format(100 * outimg.max()/ full_well))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Imaging N-band" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=['img_n'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis = sim.OpticalTrain(cmd)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "outimg = metis.readout()[0][1].data \n", "outimg /= metis.cmds[metis['summed_exposure'].meta['ndit']]\n", "\n", "full_well = metis.cmds[\"!DET.full_well\"]\n", "print(\"\\nResult\\n======\")\n", "print(\"Maximum value in readout (per DIT): {:9.1f}\".format(outimg.max()))\n", "print(\"Detector full well: {:9.1f}\".format(full_well))\n", "print(\"Fill fraction: {:9.1f} per cent\".format(100 * outimg.max()/ full_well))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Long-slit spectroscopy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=['lss_l'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis = sim.OpticalTrain(cmd)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "outimg = metis.readout(exptime=3600.)[0][1].data \n", "outimg /= metis.cmds[metis['summed_exposure'].meta['ndit']]\n", "\n", "full_well = metis.cmds[\"!DET.full_well\"]\n", "\n", "print(\"\\nResult\\n======\")\n", "print(\"Maximum value in readout (per DIT): {:8.1f}\".format(outimg.max()))\n", "print(\"Detector full well: {:8.1f}\".format(full_well))\n", "print(\"Fill fraction: {:8.1f} per cent\".format(100 * outimg.max()/ full_well))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# What happens when the source saturates the detector?\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=[\"img_n\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis = sim.OpticalTrain(cmd)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "src = sim.source.source_templates.star()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "outimg = metis.readout()[0][1].data\n", "outimg /= metis.cmds[metis['summed_exposure'].meta['ndit']]\n", "\n", "full_well = metis.cmds[\"!DET.full_well\"]\n", "\n", "print(\"\\nResult\\n======\")\n", "print(\"Maximum value in readout (per DIT): {:9.1f}\".format(outimg.max()))\n", "print(\"Detector full well: {:9.1f}\".format(full_well))\n", "print(\"Fill fraction: {:9.1f} per cent\".format(100 * outimg.max()/ full_well))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot a cut through the star to show how its peak saturates the detector." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.plot(outimg[950:1100, 1024])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "npix = (outimg >= full_well).sum()\n", "print(\"Number of saturated pixels:\", npix)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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 }