How to get RMs for a measurement set and write them to an h5parm

[1]:
from __future__ import annotations

from pathlib import Path

from spinifex import h5parm_tools
from spinifex.vis_tools import ms_tools
[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

Set the name of your measurement set

[3]:
ms = "test.MS"
[4]:
# Unpacking of local test.MS - not needed for normal use

import shutil

with resources.as_file(resources.files("spinifex.data.tests")) as test_data:
    zipped_ms = test_data / "test.ms.zip"
    shutil.unpack_archive(zipped_ms, "./")
[5]:
# create a Path object for ms
ms_path = Path(ms)
[6]:
# get metadata from ms, needed to get station_names
ms_metadata = ms_tools.get_metadata_from_ms(ms_path)
[7]:
# get a dictionary with rm objects, keys are the station names
rms = ms_tools.get_rm_from_ms(
    ms_path,
    use_stations=ms_metadata.station_names,
    # 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 0x719c8031c540> 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 ms_tools - _get_iono_from_ms: Getting DTEC per station
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.
INFO get_ipp - _get_ipp_simple: Calculating ionospheric piercepoints
INFO get_rm - _get_rm: Calculating rotation measure
INFO get_ipp - _get_ipp_simple: Calculating ionospheric piercepoints
WARNING ionex_download - _download_ionex_coro: Chapman server primarily supports uqr prefix. You provided cod, this may fail
INFO get_rm - _get_rm: Calculating rotation measure
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
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.
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.
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.
[8]:
# write to an h5parm object, this can be a new or existing h5parm
h5parm_name = "test.h5"
h5parm_tools.write_rm_to_h5parm(rms=rms, h5parm_name=h5parm_name)
[ ]: