How to use get_rm_from_skycoord

This example script shows how to get ionospheric rotation measures for a give source, observer location and array of times. This script uses the default ionospheric settings, which are good for most purposes.

[1]:
from __future__ import annotations

import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
from astropy.coordinates import EarthLocation, SkyCoord
from astropy.time import Time
from astropy.visualization import quantity_support, time_support
from spinifex import get_rm
[2]:
### Required to load local data for example - not needed for normal use
from importlib import resources

with resources.as_file(resources.files("spinifex.data.tests")) as datapath:
    spinifex_data = datapath
###
[3]:
times = Time("2020-01-08T01:00:00") + np.arange(10) * 25 * u.min
# create source object
source = SkyCoord(ra=350.85 * u.deg, dec=58.815 * u.deg)
# create Earth Location
lon = 6.367 * u.deg
lat = 52.833 * u.deg
dwingeloo = EarthLocation(lon=lon, lat=lat, height=0 * u.km)
# get rotation measures
rm = get_rm.get_rm_from_skycoord(
    loc=dwingeloo,
    times=times,
    source=source,
    # We set these options to use the data packaged with spinifex
    # Unsetting them will cause the function to download the data from the internet
    prefix="cod",
    output_directory=spinifex_data,
)
INFO models - parse_iono_kwargs: Using ionospheric model <function get_density_ionex_single_layer at 0x7fd855e32160> with options server=<Servers.CHAPMAN: 'chapman'> prefix='cod' url_stem=None time_resolution=None solution='final' output_directory=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/spinifex/checkouts/latest/spinifex/data/tests') correct_uqrg_rms=True height=<Quantity 350. km> remove_midnight_jumps=True
INFO get_ipp - _get_ipp_simple: Calculating ionospheric piercepoints
INFO get_rm - _get_rm: Calculating rotation measure
WARNING ionex_download - _download_ionex_coro: Chapman server primarily supports uqr prefix. You provided cod, this may fail
INFO download - download_or_copy_url: File /home/docs/checkouts/readthedocs.org/user_builds/spinifex/checkouts/latest/spinifex/data/tests/codg0080.20i.Z already exists. Skipping download.
WARNING ionex_download - _download_ionex_coro: Chapman server primarily supports uqr prefix. You provided cod, this may fail
INFO download - download_or_copy_url: File /home/docs/checkouts/readthedocs.org/user_builds/spinifex/checkouts/latest/spinifex/data/tests/codg0090.20i.Z already exists. Skipping download.
[4]:
# print to screen
rotation_measures = rm.rm
rm_times = rm.times
elevations = rm.elevation
azimuths = rm.azimuth
print("time      RM (rad/lambda^2)      azimuth (deg)      elevation (deg)")
for myrm, tm, az, el in zip(rotation_measures, rm_times, azimuths, elevations):
    print(f"{tm.isot} {myrm} {az:3.2f} {el:2.2f}")
time      RM (rad/lambda^2)      azimuth (deg)      elevation (deg)
2020-01-08T01:00:00.000 0.06872635189626707 336.91 26.95
2020-01-08T01:25:00.000 0.053535212385881596 340.16 25.56
2020-01-08T01:50:00.000 0.04280172678648565 343.48 24.38
2020-01-08T02:15:00.000 0.034542892492907394 346.86 23.41
2020-01-08T02:40:00.000 0.028860508220481293 350.28 22.66
2020-01-08T03:05:00.000 0.019887305874568266 353.73 22.13
2020-01-08T03:30:00.000 0.011745544767178994 357.20 21.83
2020-01-08T03:55:00.000 0.006328514081643477 0.68 21.76
2020-01-08T04:20:00.000 0.004463500259752872 4.16 21.92
2020-01-08T04:45:00.000 0.004932882901509586 7.62 22.31
[5]:
with time_support(), quantity_support():
    fig, ax = plt.subplots()
    im = ax.errorbar(rm.times.datetime, rm.rm, rm.rm_error, fmt=".")
    ax.set_ylabel("RM / rad/m$^2$")
    plt.xticks(rotation=20)
../_images/examples_get_rm_from_skycoord_6_0.png