{ "cells": [ { "cell_type": "markdown", "id": "bright-preparation", "metadata": {}, "source": [ "# 2: Observing the same object with multiple telescopes\n", "\n", "A brief introduction into using ScopeSim to observe a cluster in the LMC using the 39m ELT and the 1.5m LFOA\n", "\n", "*This is a step-by-step guide. The complete script can be found at the bottom of this page/notebook.*\n", "\n", "First set up all relevant imports:" ] }, { "cell_type": "code", "execution_count": null, "id": "hairy-information", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from matplotlib.colors import LogNorm\n", "%matplotlib inline\n", "\n", "import scopesim as sim\n", "import scopesim_templates as sim_tp" ] }, { "cell_type": "markdown", "id": "c29291e8", "metadata": {}, "source": [ "Scopesim works by using so-called instrument packages, which have to be downloaded separately. For normal use, you would set the package directory (a local folder path, `local_package_folder` in this example), download the required packages *once*, and then **remove the download command**." ] }, { "cell_type": "code", "execution_count": null, "id": "0150da5d", "metadata": {}, "outputs": [], "source": [ "local_package_folder = \"./inst_pkgs\"" ] }, { "cell_type": "markdown", "id": "future-engineering", "metadata": {}, "source": [ "However, to be able to run this example on the *Readthedocs* page, we need to include a temporary directory.\n", "\n", "**Do not** copy and run this code locally, it is **only** needed to set things up for *Readthedocs*!" ] }, { "cell_type": "code", "execution_count": null, "id": "98186ac1", "metadata": {}, "outputs": [], "source": [ "from tempfile import TemporaryDirectory\n", "local_package_folder = TemporaryDirectory().name" ] }, { "cell_type": "markdown", "id": "fcb2790a", "metadata": {}, "source": [ "Download the packages for MICADO at the ELT and the viennese [1.5m telescope at the LFOA](https://foa.univie.ac.at/instrumentation/)\n", "\n", "Again, you would only need to do this **once**, not every time you run the rest of the script, assuming you set a (permanent) instrument package folder." ] }, { "cell_type": "code", "execution_count": null, "id": "unexpected-appeal", "metadata": {}, "outputs": [], "source": [ "sim.rc.__config__[\"!SIM.file.local_packages_path\"] = local_package_folder\n", "sim.download_packages([\"Armazones\", \"ELT\", \"MICADO\", \"MORFEO\", \"LFOA\"])" ] }, { "cell_type": "markdown", "id": "pursuant-crystal", "metadata": {}, "source": [ "## Create a star cluster ``Source`` object\n", "\n", "Now, create a star cluster using the scopesim_templates package. You can ignore the output that is sometimes printed. The seed argument is used to control the random number generation that creates the stars in the cluster. If this number is kept the same, the output will be consistent with each run, otherwise the position and brightness of the stars is randomised every time." ] }, { "cell_type": "code", "execution_count": null, "id": "lasting-gender", "metadata": {}, "outputs": [], "source": [ "cluster = sim_tp.stellar.clusters.cluster(mass=10000, # Msun\n", " distance=50000, # parsec\n", " core_radius=2, # parsec\n", " seed=9001) # random seed" ] }, { "cell_type": "markdown", "id": "rubber-norwegian", "metadata": {}, "source": [ "## Observe with the [1.5m telescope at the LFOA](https://foa.univie.ac.at/instrumentation/)\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "casual-strength", "metadata": {}, "outputs": [], "source": [ "lfoa = sim.OpticalTrain(\"LFOA\")\n", "lfoa.observe(cluster,\n", " properties={\"!OBS.ndit\": 10, \"!OBS.ndit\": 360},\n", " update=True)\n", "hdus_lfoa = lfoa.readout()" ] }, { "cell_type": "markdown", "id": "labeled-buying", "metadata": {}, "source": [ "## Observe the same ``Source`` with MICADO at the ELT\n", "\n", "" ] }, { "cell_type": "code", "execution_count": null, "id": "chinese-spirit", "metadata": {}, "outputs": [], "source": [ "micado = sim.OpticalTrain(\"MICADO\")\n", "micado.cmds[\"!OBS.dit\"] = 10\n", "micado.cmds[\"!OBS.ndit\"] = 360\n", "micado.update()\n", "\n", "micado.observe(cluster)\n", "hdus_micado = micado.readout()" ] }, { "cell_type": "markdown", "id": "infrared-angola", "metadata": {}, "source": [ "Plot up the results" ] }, { "cell_type": "code", "execution_count": null, "id": "directed-mother", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(12,5))\n", "\n", "plt.subplot(121)\n", "plt.imshow(hdus_lfoa[0][1].data[345:385, 525:565], norm=LogNorm(), origin=\"lower\")\n", "plt.colorbar()\n", "plt.title(\"1.5m LFOA\")\n", "\n", "plt.subplot(122)\n", "plt.imshow(hdus_micado[0][1].data, norm=LogNorm(vmax=1E6, vmin=1e5), origin=\"lower\")\n", "plt.colorbar()\n", "plt.title(\"39m ELT\")" ] }, { "cell_type": "markdown", "id": "ea56edb2", "metadata": {}, "source": [ "## Complete script\n", "\n", "Included below is the complete script for convenience, including the downloads, but not including the plotting." ] }, { "cell_type": "code", "execution_count": null, "id": "38429fa5", "metadata": {}, "outputs": [], "source": [ "import scopesim as sim\n", "import scopesim_templates as sim_tp\n", "\n", "# sim.download_packages([\"Armazones\", \"ELT\", \"MICADO\", \"MORFEO\", \"LFOA\"])\n", "\n", "cluster = sim_tp.stellar.clusters.cluster(mass=10000, # Msun\n", " distance=50000, # parsec\n", " core_radius=2, # parsec\n", " seed=9001) # random seed\n", "\n", "lfoa = sim.OpticalTrain(\"LFOA\")\n", "lfoa.observe(cluster,\n", " properties={\"!OBS.ndit\": 10, \"!OBS.ndit\": 360},\n", " update=True)\n", "hdus_lfoa = lfoa.readout()\n", "\n", "micado = sim.OpticalTrain(\"MICADO\")\n", "micado.cmds[\"!OBS.dit\"] = 10\n", "micado.cmds[\"!OBS.ndit\"] = 360\n", "micado.update()\n", "\n", "micado.observe(cluster)\n", "hdus_micado = micado.readout()\n" ] }, { "cell_type": "code", "execution_count": null, "id": "bright-stations", "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.9.16" }, "nbsphinx": { "execute": "auto" } }, "nbformat": 4, "nbformat_minor": 5 }