{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chopping and nodding in Scopesim\n", "\n", "This notebook demonstrates how to use the `ChopNod` 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": [ "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_n'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis = sim.OpticalTrain(cmd)\n", "metis['chop_nod'].include = True" ] }, { "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()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metis.observe(src, update=True)\n", "imghdu = metis.readout()[0][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(imghdu.data, origin='lower', vmin=-5e7, vmax=5e7)\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]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "imghdu_par = metis.readout()[0][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(imghdu_par.data, origin='lower', vmin=-5e7, vmax=5e7)" ] }, { "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()[0][1]\n", "plt.imshow(imghdu_3.data, origin='lower', vmin=-5e7, vmax=5e7)" ] }, { "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()[0][1]\n", "plt.imshow(imghdu_4.data, origin='lower', vmin=-5e7, vmax=5e7)" ] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 4 }