{ "cells": [ { "cell_type": "markdown", "id": "floppy-relationship", "metadata": {}, "source": [ "# 1: A quick use case for MICADO at the ELT\n", "\n", "\n", "## A brief introduction into using ScopeSim to observe a cluster in the LMC" ] }, { "cell_type": "markdown", "id": "110aaf63", "metadata": {}, "source": [ "*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": "fatty-excellence", "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": "7358d4f0", "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": "346dd0cc", "metadata": {}, "outputs": [], "source": [ "local_package_folder = \"./inst_pkgs\"" ] }, { "cell_type": "markdown", "id": "eeefa7b2", "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": "022b83d9", "metadata": {}, "outputs": [], "source": [ "from tempfile import TemporaryDirectory\n", "local_package_folder = TemporaryDirectory().name" ] }, { "cell_type": "markdown", "id": "remarkable-outdoors", "metadata": {}, "source": [ "Download the required instrument packages for an observation with MICADO at the ELT.\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": "premier-mount", "metadata": {}, "outputs": [], "source": [ "sim.rc.__config__[\"!SIM.file.local_packages_path\"] = local_package_folder\n", "sim.download_packages([\"Armazones\", \"ELT\", \"MORFEO\", \"MICADO\"])" ] }, { "cell_type": "markdown", "id": "heard-motel", "metadata": {}, "source": [ "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": "golden-division", "metadata": {}, "outputs": [], "source": [ "cluster = sim_tp.stellar.clusters.cluster(mass=1000, # Msun\n", " distance=50000, # parsec\n", " core_radius=0.3, # parsec\n", " seed=9002)" ] }, { "cell_type": "markdown", "id": "finite-linux", "metadata": {}, "source": [ "Next, make the MICADO optical system model with ``OpticalTrain``. Observe the cluster ``Source`` object with the ``.observe()`` method and read out the MICADO detectors with ``.readout()``. This may take a few moments on slower machines.\n", "\n", "The resulting FITS file can either be returned as an ``astropy.fits.HDUList`` object, or saved to disk using the optional ``filename`` parameter" ] }, { "cell_type": "code", "execution_count": null, "id": "bronze-generator", "metadata": {}, "outputs": [], "source": [ "micado = sim.OpticalTrain(\"MICADO\")\n", "micado.observe(cluster)\n", "hdus = micado.readout()\n", "# micado.readout(filename=\"TEST.fits\")" ] }, { "cell_type": "markdown", "id": "latest-ranking", "metadata": {}, "source": [ "Display the contents the first HDU" ] }, { "cell_type": "code", "execution_count": null, "id": "undefined-flush", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,8))\n", "plt.imshow(hdus[0][1].data, norm=LogNorm(vmax=3E4, vmin=3E3), cmap=\"hot\")\n", "plt.colorbar()" ] }, { "cell_type": "markdown", "id": "romantic-description", "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": "d82e5257", "metadata": {}, "outputs": [], "source": [ "import scopesim as sim\n", "import scopesim_templates as sim_tp\n", "\n", "#sim.download_packages([\"Armazones\", \"ELT\", \"MORFEO\", \"MICADO\"])\n", "\n", "cluster = sim_tp.stellar.clusters.cluster(mass=1000, # Msun\n", " distance=50000, # parsec\n", " core_radius=0.3, # parsec\n", " seed=9002)\n", "\n", "micado = sim.OpticalTrain(\"MICADO\")\n", "micado.observe(cluster)\n", "\n", "hdus = micado.readout()\n", "# micado.readout(filename=\"TEST.fits\")" ] }, { "cell_type": "code", "execution_count": null, "id": "e8478c34", "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 }