{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How how to use `get_rm_from_altaz`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also, for a given time, map the ionospheric rotation measure sky above the observer\n", "by giving a set of azimuth and elevation coordinates" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from __future__ import annotations\n", "\n", "import astropy.units as u\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from astropy.coordinates import AltAz, EarthLocation\n", "from astropy.time import Time\n", "from astropy.visualization import quantity_support, time_support\n", "from spinifex import get_rm" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### Required to load local data for example - not needed for normal use\n", "from importlib import resources\n", "\n", "with resources.as_file(resources.files(\"spinifex.data.tests\")) as datapath:\n", " spinifex_data = datapath\n", "###" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "times = Time(\"2020-01-08T01:00:00\")\n", "# create AltAz grid\n", "azangles = np.linspace(0, 360, 30)\n", "altangles = np.linspace(10, 90, 8)\n", "altazangles = np.meshgrid(azangles, altangles)\n", "az = altazangles[0] * u.deg\n", "alt = altazangles[1] * u.deg\n", "# create Earth Location\n", "lon = 6.367 * u.deg\n", "lat = 52.833 * u.deg\n", "dwingeloo = EarthLocation(lon=lon, lat=lat, height=0 * u.km)\n", "# make altaz object, including location and times\n", "# get_rm expects a flattened array of coordinates, you can reshape the returned results\n", "altaz = AltAz(az=az.flatten(), alt=alt.flatten(), location=dwingeloo, obstime=times)\n", "# get rotation measures\n", "rm = get_rm.get_rm_from_altaz(\n", " loc=dwingeloo,\n", " altaz=altaz,\n", " # We set these options to use the data packaged with spinifex\n", " # Unsetting them will cause the function to download the data from the internet\n", " prefix=\"cod\",\n", " output_directory=spinifex_data,\n", ")\n", "rotation_measures = rm.rm.reshape(az.shape)\n", "rm_times = rm.times" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with time_support(), quantity_support():\n", " fig, ax = plt.subplots()\n", " im = ax.pcolormesh(\n", " az,\n", " alt,\n", " rotation_measures,\n", " cmap=plt.cm.RdBu_r,\n", " vmin=-2,\n", " vmax=2,\n", " shading=\"auto\",\n", " )\n", " ax.set_xlabel(\"Azimuth\")\n", " ax.set_ylabel(\"Altitude\")\n", "\n", " fig.colorbar(im, label=\"Rotation Measure [rad/m$^2$]\")\n", " fig, ax = plt.subplots(subplot_kw={\"projection\": \"polar\"})\n", " im = ax.pcolormesh(\n", " az.to(u.rad).value,\n", " 90 - alt.to(u.deg).value,\n", " rotation_measures,\n", " cmap=plt.cm.RdBu_r,\n", " vmin=-2,\n", " vmax=2,\n", " shading=\"auto\",\n", " )\n", " fig.colorbar(im, label=\"Rotation Measure [rad/m$^2$]\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "spinifex", "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 }