{ "cells": [ { "cell_type": "markdown", "id": "framed-clerk", "metadata": {}, "source": [ "# Wide-field observations of PSF variations with SCAO\n", "\n", "In this example we will show the effect of the off-axis AO correction on the shape of the PSF when observing with the SCAO mode.\n", "To make a semi-realistic observation, we will observe an open cluster created by the ``ScopeSim_Templates`` package.\n", "This cluster extends over the full MICADO field of view.\n", "As such it should show the full extend of the expected PSF variations over the field.\n", "\n", "It should be noted that adding PSF field variations is a computationally expensive process. ScopeSim does it's best to reduce the level of complexity by discretising the PSF variation into different zones over the field of view.\n", "Occasionally the borders between these zones is visible " ] }, { "cell_type": "code", "execution_count": null, "id": "unlimited-cliff", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from astropy import units as u\n", "\n", "import scopesim as sim\n", "import scopesim_templates as sim_tp" ] }, { "cell_type": "markdown", "id": "about-darwin", "metadata": {}, "source": [ "The PSF field-variation is complex and computationally expensive.\n", "Hence this functionality is not inluded in the ``MICADO`` package.\n", "For use cases requireing field variations we must use the pipeline-oriented ``MICADO`` package.\n", "As we will be using the SCAO mode, we can ignore the ``MORFEO`` module.\n", "\n", " sim.download_packages([\"Armazones\", \"ELT\", \"MORFEO\", \"MICADO\"])\n", " \n", ".. note:: In ScopeSim v0.5 both download_packages (new format) and download_package (old format) exist.\n", "\n", "If we would like to keep the instrument packages in a separate directory, we can set the following config value:\n", "\n", " sim.rc.__config__[\"!SIM.file.local_packages_path\"] = \"path/to/packages\"" ] }, { "cell_type": "markdown", "id": "formed-metabolism", "metadata": {}, "source": [ "## Set up an open cluster ``Source`` object\n", "\n", "The first step is to create a ``Source`` object. \n", "Here we take advantage of the ``cluster`` function from the ``ScopeSim_Templates.stellar.clusters`` submodule.\n", "The ``cluster`` function draws masses from an standard Kroupa IMF until the ``mass`` limit has been reached.\n", "It then generates randomly draw positions from a 2D gaussian distribution with a HWHM equal to the given ``core_radius`` in parsec.\n", "The ``distance`` parameter sets the distance in parsec to the centre of the cluster.\n", "This allows the final on-sky star positions in units of ``arcsec`` from the centre of the cluster to be calculated.\n", "Spectra for all the stars are taken from the Pickles (1998) catalogue and are imported from the ``Pyckles`` python packages.\n", "\n", "Here we choose a cluster with a mass of 10000 solar masses (~250000 stars) with a core radius of 0.5 parsec, located at a distance of 8 kpc from the Earth.\n", "This essentially gives us a cluster that covers the whole MICADO filed of view in wide-field mode (4mas / pixel)." ] }, { "cell_type": "code", "execution_count": null, "id": "altered-paris", "metadata": {}, "outputs": [], "source": [ "cluster = sim_tp.cluster(mass=10000, core_radius=0.5, distance=8000)" ] }, { "cell_type": "code", "execution_count": null, "id": "9f3f68de-ca2a-470f-928e-6b2c95da4415", "metadata": {}, "outputs": [], "source": [ "cluster.plot();" ] }, { "cell_type": "markdown", "id": "enhanced-strip", "metadata": {}, "source": [ "## Set up the MICADO optical system for SCAO and include a field-varying PSF\n", "\n", "The next step is the standard proceedure - set the instrument to ``MICADO`` and the modes to ``SCAO`` and ``IMG_4mas``, then create an ``Simulation`` object." ] }, { "cell_type": "code", "execution_count": null, "id": "continent-springer", "metadata": {}, "outputs": [], "source": [ "micado = sim.Simulation(\"MICADO\", [\"SCAO\", \"IMG_4mas\"])" ] }, { "cell_type": "markdown", "id": "identified-archive", "metadata": {}, "source": [ "By default the PSF model in the pipeline-oriented ``MICADO`` package is set to use a field-constant PSF cube.\n", "We need to change this to use a Field-Varying PSF model.\n", "\n", "**Note:** to view all the optical effects contained within the optical model, use the ``.effects`` attribute in the ``OpticalTrain`` class.\n", "\n", "Here we see the PSF model in the 4th last line:" ] }, { "cell_type": "code", "execution_count": null, "id": "peripheral-monday", "metadata": {}, "outputs": [], "source": [ "micado.optical_train" ] }, { "cell_type": "markdown", "id": "ruled-lounge", "metadata": {}, "source": [ "We can access the PSF model using the standard python dictionary notion using the name of the element.\n", "In this case it is called ``relay_psf`` as this refers to the internal MICADO relay optics which are connected to the SCAO system.\n", "\n", "We do not want to use the default ``relay_psf`` object, so we need to tell ScopeSim not to include it" ] }, { "cell_type": "code", "execution_count": null, "id": "subjective-parallel", "metadata": {}, "outputs": [], "source": [ "micado.optical_train[\"relay_psf\"].include = False" ] }, { "cell_type": "markdown", "id": "threatened-steam", "metadata": {}, "source": [ "Next we want to add a ``FieldVaryingPSF`` object from the ScopeSim library of optical effect.\n", "Before we initialise the object though, we will need the correct PSF cube.\n", "\n", "A small library of precomputed PSFs can be found on the ScopeSim server: https://scopesim.univie.ac.at/InstPkgSvr/psfs/\n", "\n", "Once we have downloaded the PSF cube of our choice (in this case the cube corresponding to ESO median atmospheric conditions) we can pass the file path to the ``FieldVaryingPSF`` object.\n", "\n", "