{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chopping and nodding in Scopesim\n", "\n", "This notebook demonstrates how to use the `ChopNodCombiner` effect in Scopesim. Both chopping and nodding are currently defined as two-point patterns, where the throw direction is given as a 2D vector (dx, dy) in `metis[\"chop_nod\"].meta[\"chop_offsets\"]` and `metis[\"chop_nod\"].meta[\"nod_offsets\"]`. For parallel nodding, the two vectors are parallel (typically nod_offset = - chop_offset, giving a three-point pattern), for perpendicular nodding, the vectors are orthogonal. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "\n", "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.link_irdb(\"../../../../\")" ] }, { "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_n\"])\n", "metis = sim.OpticalTrain(cmd)\n", "metis[\"chop_nod\"].include = True\n", "metis[\"reference_pixel_mask\"].include = False # Hack: this would mess up the chop/nod results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The default is perpendicular nodding, with the chop throw in the x-direction and the nod throw in the y direction." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"Chop offsets:\", metis.cmds[metis[\"chop_nod\"].meta[\"chop_offsets\"]])\n", "print(\"Nod offsets: \", metis.cmds[metis[\"chop_nod\"].meta[\"nod_offsets\"]])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "src = sim.source.source_templates.star()\n", "metis.observe(src)\n", "imghdul = metis.readout(exptime=1)[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(imghdul[1].data, origin=\"lower\", vmin=-3e3, vmax=3e3)\n", "plt.colorbar();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For parallel nodding, turn the nod throw into the x-direction as well." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis[\"chop_nod\"].meta[\"nod_offsets\"] = [-3, 0]\n", "imghdu_par = metis.readout(exptime=1)[0][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(imghdu_par.data, origin=\"lower\", vmin=-3e3, vmax=3e3)\n", "plt.colorbar();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Other four-point patterns are possible:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis[\"chop_nod\"].meta[\"nod_offsets\"] = [-3, 3]\n", "imghdu_3 = metis.readout(exptime=1)[0][1]\n", "plt.imshow(imghdu_3.data, origin=\"lower\", vmin=-3e3, vmax=3e3)\n", "plt.colorbar();" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis[\"chop_nod\"].meta[\"chop_offsets\"] = [-3, 2]\n", "metis[\"chop_nod\"].meta[\"nod_offsets\"] = [2, 3]\n", "imghdu_4 = metis.readout(exptime=1)[0][1]\n", "plt.imshow(imghdu_4.data, origin=\"lower\", vmin=-3e3, vmax=3e3)\n", "plt.colorbar();" ] } ], "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.12.9" } }, "nbformat": 4, "nbformat_minor": 4 }