{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates how to use the various slits in METIS. They are defined in a `SlitWheel` effect, which works in the same way as `FilterWheel`. The notebook uses imaging mode to show the slits directly. " ] }, { "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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "%matplotlib inline" ] }, { "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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd = sim.UserCommands(use_instrument=\"METIS\", set_modes=['img_lm'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In imaging mode, `\"!OBS.slit\"` is `false` by default, i.e. there is no slit in the path. However, slits can be used in imaging as well by setting `!OBS.slit` to one of the slits available in the METIS package." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cmd['!OBS.slit'] = \"C-38_1\"" ] }, { "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 = sim.OpticalTrain(cmd)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following slits are now available and can be selected with `metis['slit_wheel'].change_slit()` as demonstrated below." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis['slit_wheel'].slits" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "implanes = dict()\n", "for slit in metis['slit_wheel'].slits:\n", " metis['slit_wheel'].change_slit(slit)\n", " metis.observe(src, update=True)\n", " implanes[slit] = metis.image_planes[0].data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(15, 5))\n", "for i, slit in enumerate(metis['slit_wheel'].slits):\n", " plt.subplot(2, 3, i+1)\n", " plt.imshow(implanes[slit][600:1450,], origin='lower')\n", " plt.title(\"Slit \" + slit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding a slit to the slit wheel\n", "\n", "The slit wheel holds a number of default slits (defined by the configuration for the instrument used). A custom slit can be added using the method `add_slit`. A \"slit\" is an object of class `ApertureMask` and the various methods for instantiating such an object can be used." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "newslit = sim.effects.ApertureMask(name=\"Square\", array_dict={\"x\": [-1, 1, 1, -1], \"y\": [-1, -1, 1, 1]}, \n", " x_unit=\"arcsec\", y_unit=\"arcsec\")\n", "metis['slit_wheel'].add_slit(newslit)\n", "metis['slit_wheel'].slits" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis['slit_wheel'].change_slit(\"Square\")\n", "metis.observe(src, update=True)\n", "implane = metis.image_planes[0].data\n", "plt.imshow(implane[600:1450,], origin='lower')\n", "plt.title(\"Slit \" + metis['slit_wheel'].current_slit.meta['name']);" ] } ], "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.2" } }, "nbformat": 4, "nbformat_minor": 4 }