Open In Colab

astrohack

Antenna position correction tutorial

extract_locit and locit are utilities designed to help determine antenna position shifts after antenna relocation. To do so they rely on a phase gain calibration table created by CASA from antenna pointing data. The process in CASA consists of: 1. split out the actual pointing data from the original pointing measurement set (MS), it might contain data taken while the antennas are still slewing. 2. fringe_fit the MS using a single source with no delay rates, this is done to flatten a spectral window. 3. apply_cal the fringe_fit solution. 4. Channel average the MS using split. 5. Compute an average phase gain solution for each source using gaincal

To simplify the process in CASA a script is distributed within astrohack that the user can simply fill in the parameters for the data reduction and then run it within CASA.

[1]:
import os

try:
    import astrohack

    print('AstroHACK version', astrohack.__version__, 'already installed.')
except ImportError as e:
    print(e)
    print('Installing AstroHACK')

    os.system("pip install astrohack")

    import astrohack
    print('astrohack version', astrohack.__version__, ' installed.')
No module named 'auror'
Installing AstroHACK
Looking in indexes: https://casa-pip.nrao.edu/repository/pypi-group/simple, https://pypi.org/simple/
Requirement already satisfied: astrohack in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (0.4.3)
Requirement already satisfied: astropy in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (5.2.2)
Requirement already satisfied: auror in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (0.3.10)
Requirement already satisfied: dask in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (2023.5.0)
Requirement already satisfied: distributed in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (2023.5.0)
Requirement already satisfied: matplotlib in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (3.7.4)
Requirement already satisfied: menrva in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (0.0.14)
Requirement already satisfied: numba>=0.57.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (0.58.1)
Requirement already satisfied: numpy in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (1.24.4)
Requirement already satisfied: prettytable in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (3.9.0)
Requirement already satisfied: pytest in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (7.4.3)
Requirement already satisfied: pytest-cov in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (4.1.0)
Requirement already satisfied: pytest-html in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (4.1.1)
Requirement already satisfied: scikit-image in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (0.21.0)
Requirement already satisfied: scikit-learn in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (1.3.2)
Requirement already satisfied: scipy in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (1.10.1)
Requirement already satisfied: rich in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (13.7.0)
Requirement already satisfied: skriba in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (0.3.13)
Requirement already satisfied: xarray in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (2023.1.0)
Requirement already satisfied: zarr in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (2.16.1)
Requirement already satisfied: bokeh in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from astrohack) (2.4.2)
Requirement already satisfied: jupyterlab in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (4.0.11)
Requirement already satisfied: python-casacore>=3.5.2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from astrohack) (3.5.2)
Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from numba>=0.57.0->astrohack) (0.41.1)
Requirement already satisfied: importlib-metadata in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from numba>=0.57.0->astrohack) (7.0.0)
Requirement already satisfied: six in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from python-casacore>=3.5.2->astrohack) (1.16.0)
Requirement already satisfied: pyerfa>=2.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from astropy->astrohack) (2.0.0.1)
Requirement already satisfied: PyYAML>=3.13 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from astropy->astrohack) (6.0)
Requirement already satisfied: packaging>=19.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from astropy->astrohack) (21.3)
Requirement already satisfied: cerberus in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from auror->astrohack) (1.3.5)
Requirement already satisfied: tqdm in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from auror->astrohack) (4.62.3)
Requirement already satisfied: Jinja2>=2.9 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from bokeh->astrohack) (3.1.3)
Requirement already satisfied: pillow>=7.1.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from bokeh->astrohack) (10.1.0)
Requirement already satisfied: tornado>=5.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from bokeh->astrohack) (6.4)
Requirement already satisfied: typing-extensions>=3.10.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from bokeh->astrohack) (4.0.1)
Requirement already satisfied: click>=8.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from dask->astrohack) (8.1.7)
Requirement already satisfied: cloudpickle>=1.5.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from dask->astrohack) (3.0.0)
Requirement already satisfied: fsspec>=2021.09.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from dask->astrohack) (2023.12.1)
Requirement already satisfied: partd>=1.2.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from dask->astrohack) (1.4.1)
Requirement already satisfied: toolz>=0.10.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from dask->astrohack) (0.12.0)
Requirement already satisfied: locket>=1.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (1.0.0)
Requirement already satisfied: msgpack>=1.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (1.0.7)
Requirement already satisfied: psutil>=5.7.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (5.9.6)
Requirement already satisfied: sortedcontainers>=2.0.5 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (2.4.0)
Requirement already satisfied: tblib>=1.6.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (3.0.0)
Requirement already satisfied: urllib3>=1.24.3 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from distributed->astrohack) (1.26.7)
Requirement already satisfied: zict>=2.2.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from distributed->astrohack) (3.0.0)
Requirement already satisfied: async-lru>=1.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (2.0.4)
Requirement already satisfied: importlib-resources>=1.4 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyterlab->astrohack) (5.4.0)
Requirement already satisfied: ipykernel in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyterlab->astrohack) (6.6.1)
Requirement already satisfied: jupyter-core in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (5.5.0)
Requirement already satisfied: jupyter-lsp>=2.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (2.2.1)
Requirement already satisfied: jupyter-server<3,>=2.4.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (2.12.0)
Requirement already satisfied: jupyterlab-server<3,>=2.19.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (2.25.2)
Requirement already satisfied: notebook-shim>=0.2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (0.2.3)
Requirement already satisfied: tomli in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyterlab->astrohack) (1.2.2)
Requirement already satisfied: traitlets in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab->astrohack) (5.14.0)
Requirement already satisfied: contourpy>=1.0.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from matplotlib->astrohack) (1.1.1)
Requirement already satisfied: cycler>=0.10 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from matplotlib->astrohack) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from matplotlib->astrohack) (4.28.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from matplotlib->astrohack) (1.3.2)
Requirement already satisfied: pyparsing>=2.3.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from matplotlib->astrohack) (3.0.6)
Requirement already satisfied: python-dateutil>=2.7 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from matplotlib->astrohack) (2.8.2)
Requirement already satisfied: dask-jobqueue in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from menrva->astrohack) (0.8.2)
Requirement already satisfied: graphviper in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from menrva->astrohack) (0.0.5)
Requirement already satisfied: wcwidth in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from prettytable->astrohack) (0.2.5)
Requirement already satisfied: iniconfig in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from pytest->astrohack) (1.1.1)
Requirement already satisfied: pluggy<2.0,>=0.12 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from pytest->astrohack) (1.0.0)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from pytest->astrohack) (1.2.0)
Requirement already satisfied: coverage>=5.2.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from coverage[toml]>=5.2.1->pytest-cov->astrohack) (7.3.2)
Requirement already satisfied: pytest-metadata>=2.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from pytest-html->astrohack) (3.0.0)
Requirement already satisfied: markdown-it-py>=2.2.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from rich->astrohack) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from rich->astrohack) (2.17.2)
Requirement already satisfied: networkx>=2.8 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-image->astrohack) (3.1)
Requirement already satisfied: imageio>=2.27 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-image->astrohack) (2.33.0)
Requirement already satisfied: tifffile>=2022.8.12 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-image->astrohack) (2023.7.10)
Requirement already satisfied: PyWavelets>=1.1.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-image->astrohack) (1.4.1)
Requirement already satisfied: lazy_loader>=0.2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-image->astrohack) (0.3)
Requirement already satisfied: joblib>=1.1.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-learn->astrohack) (1.3.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from scikit-learn->astrohack) (3.2.0)
Requirement already satisfied: colorama in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from skriba->astrohack) (0.4.6)
Requirement already satisfied: pandas>=1.3 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from xarray->astrohack) (1.3.5)
Requirement already satisfied: asciitree in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from zarr->astrohack) (0.3.3)
Requirement already satisfied: fasteners in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from zarr->astrohack) (0.19)
Requirement already satisfied: numcodecs>=0.10.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from zarr->astrohack) (0.12.1)
Requirement already satisfied: zipp>=0.5 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from importlib-metadata->numba>=0.57.0->astrohack) (3.7.0)
Requirement already satisfied: MarkupSafe>=2.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from Jinja2>=2.9->bokeh->astrohack) (2.1.3)
Requirement already satisfied: anyio>=3.1.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (3.4.0)
Requirement already satisfied: argon2-cffi in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (21.3.0)
Requirement already satisfied: jupyter-client>=7.4.4 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (7.4.9)
Requirement already satisfied: jupyter-events>=0.9.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.9.0)
Requirement already satisfied: jupyter-server-terminals in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.4.4)
Requirement already satisfied: nbconvert>=6.4.4 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (7.12.0)
Requirement already satisfied: nbformat>=5.3.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (5.9.2)
Requirement already satisfied: overrides in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (7.4.0)
Requirement already satisfied: prometheus-client in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.12.0)
Requirement already satisfied: pyzmq>=24 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (25.1.2)
Requirement already satisfied: send2trash>=1.8.2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.8.2)
Requirement already satisfied: terminado>=0.8.3 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.12.1)
Requirement already satisfied: websocket-client in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.2.3)
Requirement already satisfied: platformdirs>=2.5 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-core->jupyterlab->astrohack) (4.1.0)
Requirement already satisfied: babel>=2.10 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (2.13.1)
Requirement already satisfied: json5>=0.9.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (0.9.6)
Requirement already satisfied: jsonschema>=4.18.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (4.20.0)
Requirement already satisfied: requests>=2.31 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (2.31.0)
Requirement already satisfied: mdurl~=0.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from markdown-it-py>=2.2.0->rich->astrohack) (0.1.2)
Requirement already satisfied: pytz>=2017.3 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from pandas>=1.3->xarray->astrohack) (2021.3)
Requirement already satisfied: pyarrow in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from graphviper->menrva->astrohack) (15.0.0)
Requirement already satisfied: graphviz in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from graphviper->menrva->astrohack) (0.20.1)
Requirement already satisfied: xradio in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from graphviper->menrva->astrohack) (0.0.16)
Requirement already satisfied: debugpy<2.0,>=1.0.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipykernel->jupyterlab->astrohack) (1.5.1)
Requirement already satisfied: ipython>=7.23.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipykernel->jupyterlab->astrohack) (7.30.1)
Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipykernel->jupyterlab->astrohack) (0.1.3)
Requirement already satisfied: nest-asyncio in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipykernel->jupyterlab->astrohack) (1.5.4)
Requirement already satisfied: idna>=2.8 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (3.3)
Requirement already satisfied: sniffio>=1.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.2.0)
Requirement already satisfied: setuptools>=18.5 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (68.0.0)
Requirement already satisfied: jedi>=0.16 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (0.18.1)
Requirement already satisfied: decorator in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (5.1.0)
Requirement already satisfied: pickleshare in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (0.7.5)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (3.0.24)
Requirement already satisfied: backcall in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (0.2.0)
Requirement already satisfied: pexpect>4.3 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (4.8.0)
Requirement already satisfied: attrs>=22.2.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (23.1.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (2023.11.2)
Requirement already satisfied: pkgutil-resolve-name>=1.3.10 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (1.3.10)
Requirement already satisfied: referencing>=0.28.4 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (0.31.1)
Requirement already satisfied: rpds-py>=0.7.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (0.13.2)
Requirement already satisfied: entrypoints in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jupyter-client>=7.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.3)
Requirement already satisfied: python-json-logger>=2.0.4 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.0.7)
Requirement already satisfied: rfc3339-validator in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.1.4)
Requirement already satisfied: rfc3986-validator>=0.1.1 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.1.1)
Requirement already satisfied: beautifulsoup4 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (4.12.2)
Requirement already satisfied: bleach!=5.0.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (4.1.0)
Requirement already satisfied: defusedxml in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.7.1)
Requirement already satisfied: jupyterlab-pygments in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.1.2)
Requirement already satisfied: mistune<4,>=2.0.3 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (3.0.2)
Requirement already satisfied: nbclient>=0.5.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.5.9)
Requirement already satisfied: pandocfilters>=1.4.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.5.0)
Requirement already satisfied: tinycss2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.2.1)
Requirement already satisfied: fastjsonschema in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from nbformat>=5.3.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.19.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from requests>=2.31->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (2.0.9)
Requirement already satisfied: certifi>=2017.4.17 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from requests>=2.31->jupyterlab-server<3,>=2.19.0->jupyterlab->astrohack) (2021.10.8)
Requirement already satisfied: ptyprocess in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from terminado>=0.8.3->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.7.0)
Requirement already satisfied: argon2-cffi-bindings in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from argon2-cffi->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (21.2.0)
Requirement already satisfied: casadata in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from xradio->graphviper->menrva->astrohack) (2024.1.22)
Requirement already satisfied: gdown in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from xradio->graphviper->menrva->astrohack) (4.7.1)
Requirement already satisfied: webencodings in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from bleach!=5.0.0->nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (0.5.1)
Requirement already satisfied: parso<0.9.0,>=0.8.0 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel->jupyterlab->astrohack) (0.8.3)
Requirement already satisfied: fqdn in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.5.1)
Requirement already satisfied: isoduration in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (20.11.0)
Requirement already satisfied: jsonpointer>1.13 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.4)
Requirement already satisfied: uri-template in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.3.0)
Requirement already satisfied: webcolors>=1.11 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.13)
Requirement already satisfied: cffi>=1.0.1 in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.15.0)
Requirement already satisfied: soupsieve>1.2 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from beautifulsoup4->nbconvert>=6.4.4->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.5)
Requirement already satisfied: filelock in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from gdown->xradio->graphviper->menrva->astrohack) (3.13.1)
Requirement already satisfied: pycparser in /export/home/ajax/jhoskins/.local/lib/python3.8/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.21)
Requirement already satisfied: arrow>=0.15.0 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (1.3.0)
Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from requests[socks]->gdown->xradio->graphviper->menrva->astrohack) (1.7.1)
Requirement already satisfied: types-python-dateutil>=2.8.10 in /export/home/ajax/jhoskins/.conda/envs/holo-3.8/lib/python3.8/site-packages (from arrow>=0.15.0->isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->jupyterlab->astrohack) (2.8.19.14)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_1927579/3141342790.py in <module>
      3 try:
----> 4     import astrohack
      5

~/Development/astrohack/src/astrohack/__init__.py in <module>
      5
----> 6 from .extract_holog import *
      7 from .extract_holog import generate_holog_obs_dict

~/Development/astrohack/src/astrohack/extract_holog.py in <module>
     10
---> 11 import auror.parameter
     12 import dask

ModuleNotFoundError: No module named 'auror'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_1927579/3141342790.py in <module>
     11     os.system("pip install astrohack")
     12
---> 13     import astrohack
     14     print('astrohack version', astrohack.__version__, ' installed.')

~/Development/astrohack/src/astrohack/__init__.py in <module>
      4 __version__ = version('astrohack')
      5
----> 6 from .extract_holog import *
      7 from .extract_holog import generate_holog_obs_dict
      8 from .extract_pointing import *

~/Development/astrohack/src/astrohack/extract_holog.py in <module>
      9 import multiprocessing
     10
---> 11 import auror.parameter
     12 import dask
     13 import numpy as np

ModuleNotFoundError: No module named 'auror'

Download Tutorial data

[2]:
# The Cal table used here is a place holder, there should be a better dataset to be used with the tutorial
graphviper.utils.data.download('locit-input-pha.cal', folder='data')

Position and locit Data File API

As part of the astroHACK API a set of functions to allow users to easily open on disk locit and position files has been provided. Each function takes an astroHACK locit or position file name as an argument and returns an object related to the given file type. Each object allows the user to access data via dictionary keys with values consisting of the relevant dataset. Each object also provides a summary() helper function to list available keys for each file. An example call for each file type is show below and the API documentation for all data-io functions can be found here.

from astrohack.dio import open_locit
from astrohack.dio import open_position

locit_data = open_holog(file='./data/locit-input-pha.locit.zarr')
position_data = open_image(file='./data/locit-input-pha.position.zarr')

Setup Dask Local Cluster

The local Dask client handles scheduling and worker managment for the parallelization. The user has the option of choosing the number of cores and memory allocations for each worker howerver, we recommend a minimum of 1Gb per core with standard settings.

A significant amount of information related to the client and scheduling can be found using the Dask Dashboard. This is a built in dashboard native to Dask and allows the user to monitor the workers during processing. This is especially useful for profilling. For those that are interested in working soley within Jupyterlab a dashboard extension is available for Jupyterlab.

dashboard

[3]:
from graphviper.dask.client import local_client

client = local_client(cores=4, memory_limit='1GB')
client
[2024-01-12 12:13:28,213]     INFO      menrva:  Checking parameter values for client.local_client
[2024-01-12 12:13:28,227]  WARNING   astrohack:  It is recommended that the local cache directory be set using the `dask_local_dir` parameter.
[2024-01-12 12:13:30,918]     INFO   astrohack:  Created client <MenrvaClient: 'tcp://127.0.0.1:34981' processes=4 threads=4, memory=3.73 GiB>
[3]:

Client

MenrvaClient-ac3c4d97-b17e-11ee-8ca1-c858c0afdf93

Connection method: Cluster object Cluster type: distributed.LocalCluster
Dashboard: http://127.0.0.1:8787/status

Cluster Info

Extract locit

The first step in determining the antenna position corrections is to extract the data from the phase gains calibration table and store it in a convenient format for further processing.

In the calibration table the data is organized by time, but we want organized by antenna -> DDI -> time for simplicity of processing in locit.

Also the data in the calibration table may contain more than one reference antenna, which would scramble the results obtained by locit, hence we throw away data that has a different reference antenna than the main reference antenna in extract_locit

[4]:
cal_table = './data/locit-input-pha.cal'
locit_name = './data/locit-input-pha.locit.zarr'
position_name = './data/locit-input-pha.position.zarr'
[5]:
%%time
from astrohack.extract_locit import extract_locit

locit_mds = extract_locit(
    cal_table,                # The calibration table containing the phase gains
    locit_name=locit_name,    # The name for the created locit file
    ant="all",                # Antenna selection, None means 'All'
    ddi="all",                # DDI selection, None means 'ALL'
    overwrite=True
)
[2024-01-12 12:13:30,998]     INFO   astrohack:  Checking parameter values for extract_locit.extract_locit
[2024-01-12 12:13:31,002]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:31,003]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:31,004]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:35,118]     INFO   astrohack:  Finished processing
CPU times: user 4.09 s, sys: 342 ms, total: 4.43 s
Wall time: 4.6 s

extract_locit creates a file that is called a locit file. This file contains the phase gains for each antenna but also contains two important tables, the source and antenna tables.

extract_locit also returns the opened locit file as a locit_mds object. The first step in interacting with the locit_mds object is calling its summary

[6]:
locit_mds.summary()
####################################################################################################
###                                         Summary for:                                         ###
###                              ./data/locit-input-pha.locit.zarr                               ###
####################################################################################################

Full documentation for AstrohackLocitFile objects' API at:
https://astrohack.readthedocs.io/en/stable/_api/autoapi/astrohack/mds/index.html#astrohack.mds.AstrohackLocitFile

Input Parameters:
+------------+-----------------------------------+
| Parameter  | Value                             |
+------------+-----------------------------------+
| cal_table  | ./data/locit-input-pha.cal        |
| locit_name | ./data/locit-input-pha.locit.zarr |
| ant        | all                               |
| ddi        | all                               |
| overwrite  | True                              |
| version    | 0.4.2                             |
| origin     | extract_locit                     |
+------------+-----------------------------------+

Contents:
+----------+--------------------+
| Antenna  | Contents           |
+----------+--------------------+
| ant_ea08 | ['ddi_0', 'ddi_1'] |
| ant_ea23 | ['ddi_0', 'ddi_1'] |
| ant_ea12 | ['ddi_0', 'ddi_1'] |
| ant_ea24 | ['ddi_0', 'ddi_1'] |
| ant_ea21 | ['ddi_0', 'ddi_1'] |
| ant_ea26 | ['ddi_0', 'ddi_1'] |
| ant_ea01 | ['ddi_0', 'ddi_1'] |
| ant_ea15 | ['ddi_0', 'ddi_1'] |
| ant_ea09 | ['ddi_0', 'ddi_1'] |
| ant_ea05 | ['ddi_0', 'ddi_1'] |
| ant_ea19 | ['ddi_0', 'ddi_1'] |
| ant_ea13 | ['ddi_0', 'ddi_1'] |
| ant_ea04 | ['ddi_0', 'ddi_1'] |
| ant_ea07 | ['ddi_0', 'ddi_1'] |
| ant_ea28 | ['ddi_0', 'ddi_1'] |
| ant_ea11 | ['ddi_0', 'ddi_1'] |
| ant_ea22 | ['ddi_0', 'ddi_1'] |
| ant_ea27 | ['ddi_0', 'ddi_1'] |
| ant_ea18 | ['ddi_0', 'ddi_1'] |
| ant_ea10 | ['ddi_0', 'ddi_1'] |
| ant_ea02 | ['ddi_0', 'ddi_1'] |
| ant_ea16 | ['ddi_0', 'ddi_1'] |
| ant_ea25 | ['ddi_0', 'ddi_1'] |
| ant_ea17 | ['ddi_0', 'ddi_1'] |
| ant_ea06 | ['ddi_0', 'ddi_1'] |
| ant_ea20 | ['ddi_0', 'ddi_1'] |
+----------+--------------------+

Available methods:
+---------------------------+----------------------------------------------------------------------+
| Methods                   | Description                                                          |
+---------------------------+----------------------------------------------------------------------+
| summary                   | Prints summary of the AstrohackLocitFile object, with available      |
|                           | data, attributes and available methods                               |
| print_source_table        | Prints a table with the sources observed for antenna location        |
|                           | determination                                                        |
| print_array_configuration | Prints a table containing the array configuration                    |
| plot_source_positions     | Plot source positions in either FK5 or precessed right ascension and |
|                           | declination.                                                         |
| plot_array_configuration  | Plot antenna positions.                                              |
+---------------------------+----------------------------------------------------------------------+

From the summary, we can see that the locit file contains 26 antennas and 2 DDIs per antenna, as well as 4 different methods related to the visualization of the source and antenna tables. To inspect the data contained in a DDI for an antenna, we simply access the dictionary keys as so,

[7]:
locit_mds['ant_ea06']['ddi_0']
[7]:
<xarray.Dataset>
Dimensions:         (p0_time: 33, p1_time: 34)
Coordinates:
  * p0_time         (p0_time) float64 6.018e+04 6.018e+04 ... 6.018e+04
  * p1_time         (p1_time) float64 6.018e+04 6.018e+04 ... 6.018e+04
Data variables:
    P0_FIELD_ID     (p0_time) int32 dask.array<chunksize=(33,), meta=np.ndarray>
    P0_PHASE_GAINS  (p0_time) float32 dask.array<chunksize=(33,), meta=np.ndarray>
    P1_FIELD_ID     (p1_time) int32 dask.array<chunksize=(34,), meta=np.ndarray>
    P1_PHASE_GAINS  (p1_time) float32 dask.array<chunksize=(34,), meta=np.ndarray>
Attributes:
    bandwidth:            [128000000.0]
    frequency:            8223000000.0
    polarization_scheme:  ['R', 'L']

Inspecting the Sources in the dataset

When trying to determine the antenna position correction, we are always interested in knowing the distribution in the sky of the sources used in the pointing observation. The antenna position corrections in X and Y are affected by the hour-angle coverage of the observations, while the Z position correction is affected by the declination coverage of the observations.

First we will print the source table, and second we will plot the sources on a simplified sky plot for easier visualization.

[8]:
locit_mds.print_source_table()

Sources:
+----+----------+---------------+----------------+---------------+----------------+
| Id | Name     | RA FK5        | DEC FK5        | RA precessed  | DEC precessed  |
+----+----------+---------------+----------------+---------------+----------------+
| 0  | 2023+544 | 20h23m55.833s | +54°27m35.789s | 20h23m21.769s | +54°32m16.844s |
| 1  | 2005+778 | 20h05m30.999s | +77°52m43.247s | 20h03m29.593s | +77°56m51.192s |
| 2  | 0841+708 | 08h41m24.365s | +70°53m42.174s | 08h42m30.408s | +70°48m38.004s |
| 3  | 1419+543 | 14h19m46.597s | +54°23m14.787s | 14h19m21.177s | +54°17m02.436s |
| 4  | 1549+506 | 15h49m17.469s | +50°38m05.788s | 15h48m45.517s | +50°34m04.200s |
| 5  | 1734+389 | 17h34m20.579s | +38°57m51.443s | 17h33m56.032s | +38°57m07.858s |
| 6  | 2052+365 | 20h52m52.050s | +36°35m35.309s | 20h52m36.284s | +36°41m01.557s |
| 7  | 2236+284 | 22h36m22.471s | +28°28m57.413s | 22h36m17.552s | +28°36m19.785s |
| 8  | 1824+107 | 18h24m02.855s | +10°44m23.774s | 18h23m57.669s | +10°45m15.862s |
| 9  | 1743-038 | 17h43m58.856s | -03°50m04.617s | 17h44m01.506s | -03°50m38.554s |
| 10 | 1957-387 | 19h57m59.819s | -38°45m06.356s | 19h58m23.302s | -38°41m20.677s |
| 11 | 2109-411 | 21h09m33.189s | -41°10m20.605s | 21h09m53.676s | -41°04m35.841s |
| 12 | 2158-150 | 21h58m06.282s | -15°01m09.327s | 21h58m11.952s | -14°54m20.025s |
| 13 | 2212+239 | 22h12m05.966s | +23°55m40.543s | 22h12m00.818s | +24°02m43.254s |
| 14 | 0010+174 | 00h10m33.991s | +17°24m18.762s | 00h10m35.414s | +17°32m13.416s |
| 15 | 0204-170 | 02h04m57.674s | -17°01m19.840s | 02h04m53.468s | -16°54m21.691s |
| 16 | 0339-017 | 03h39m30.938s | -01°46m35.803s | 03h39m30.282s | -01°41m51.278s |
| 17 | 0541+532 | 05h41m16.170s | +53°12m24.810s | 05h41m57.080s | +53°13m00.171s |
| 18 | 0251+432 | 02h51m34.537s | +43°15m15.829s | 02h51m54.884s | +43°20m58.310s |
| 19 | 2255+420 | 22h55m36.708s | +42°02m52.533s | 22h55m30.074s | +42°10m25.423s |
| 20 | 2230+697 | 22h30m36.470s | +69°46m28.077s | 22h30m06.312s | +69°53m41.036s |
| 21 | 1048+717 | 10h48m27.620s | +71°43m35.939s | 10h48m54.061s | +71°36m15.652s |
| 22 | 1436+636 | 14h36m45.802s | +63°36m37.866s | 14h36m05.678s | +63°30m46.884s |
| 23 | 1635+381 | 16h35m15.493s | +38°08m04.500s | 16h34m52.902s | +38°05m24.487s |
| 24 | 1850+284 | 18h50m27.590s | +28°25m13.120s | 18h50m11.904s | +28°27m01.772s |
| 25 | 2136+006 | 21h36m38.586s | +00°41m54.214s | 21h36m39.595s | +00°48m19.125s |
| 26 | 2000-178 | 20h00m57.090s | -17°48m57.672s | 20h01m07.016s | -17°45m02.504s |
| 27 | 2151-304 | 21h51m55.524s | -30°27m53.698s | 21h52m06.987s | -30°21m12.141s |
| 28 | 2230-397 | 22h30m40.279s | -39°42m52.067s | 22h30m52.146s | -39°35m31.857s |
| 29 | 0024-420 | 00h24m42.990s | -42°02m03.953s | 00h24m41.747s | -41°54m02.091s |
+----+----------+---------------+----------------+---------------+----------------+
[9]:
locit_plot_folder = 'locit_mds_plots'

locit_mds.plot_source_positions(
    locit_plot_folder,   # destination for the plot
    labels=True,         # Display source labels on plot
    precessed=False,     # Plot FK5 (J2000) coordinates instead of prcessed coordinates
    display=True
)
[2024-01-12 12:13:35,740]     INFO   astrohack:  Checking parameter values for mds.AstrohackLocitFile.plot_source_positions
[2024-01-12 12:13:35,742]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:35,744]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:35,745]     INFO   astrohack:  Searching file system for configuration files, please wait ...
_images/locit_tutorial_19_1.png

Inspecting the array configuration in the dataset

Another important piece of information when determining antenna position corrections is which antennas are present in the observations and where are they located in the array. We have introduced two methods to display this information, the first, print_array_configuration, displays all the antennas for the array, accompanied by their positions if they are present in the dataset. The second method, plot_array_configuration, plots the positions of the antennas in the dataset; antennas not present are simply skipped.

[10]:
locit_mds.print_array_configuration(relative=False) # antenna positions printed are relative to the array center
[2024-01-12 12:13:36,420]     INFO   astrohack:  Checking parameter values for mds.AstrohackLocitFile.print_array_configuration
[2024-01-12 12:13:36,423]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:36,426]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:36,429]     INFO   astrohack:  Searching file system for configuration files, please wait ...

EVLA antennas, # of antennas 26:
+------------+---------+-----------------+----------------+--------------+
|    Name    | Station |    Longitude    |    Latitude    |  Radius [m]  |
+------------+---------+-----------------+----------------+--------------+
|    ea01    |   W32   | -107°39m54.777s | +33°52m27.200s | 6373591.7591 |
|    ea02    |   N72   | -107°38m10.526s | +34°04m12.216s | 6373536.5113 |
|    ea03    |   N/A   |       N/A       |      N/A       |     N/A      |
|    ea04    |   E48   | -107°30m56.082s | +33°51m38.381s | 6373617.9185 |
|    ea05    |   W40   | -107°41m13.482s | +33°51m43.069s | 6373588.2127 |
|    ea06    |   MAS   | -107°37m41.283s | +33°53m41.999s | 6373580.9899 |
|    ea07    |   E16   | -107°36m09.822s | +33°53m40.005s | 6373579.2062 |
|    ea08    |   N56   | -107°37m47.893s | +34°00m38.380s | 6373545.7480 |
|    ea09    |   W24   | -107°38m49.036s | +33°53m04.046s | 6373590.5071 |
|    ea10    |   N40   | -107°37m29.504s | +33°57m44.409s | 6373559.2211 |
|    ea11    |   W56   | -107°44m26.689s | +33°49m54.626s | 6373595.3443 |
|    ea12    |   E08   | -107°36m48.898s | +33°53m55.133s | 6373576.7701 |
|    ea13    |   W16   | -107°37m57.387s | +33°53m32.978s | 6373581.2948 |
|    ea14    |   N/A   |       N/A       |      N/A       |     N/A      |
|    ea15    |   N16   | -107°37m10.878s | +33°54m47.970s | 6373570.5968 |
|    ea16    |   E24   | -107°35m13.358s | +33°53m18.138s | 6373593.7134 |
|    ea17    |   N64   | -107°37m58.700s | +34°02m20.511s | 6373539.3645 |
|    ea18    |   N32   | -107°37m22.024s | +33°56m33.579s | 6373563.0524 |
|    ea19    |   E32   | -107°34m01.480s | +33°52m50.288s | 6373605.2045 |
|    ea20    |   W64   | -107°46m20.056s | +33°48m50.918s | 6373597.0976 |
|    ea21    |   E72   | -107°24m42.347s | +33°49m18.007s | 6373584.7068 |
|    ea22    |   N24   | -107°37m16.123s | +33°55m37.653s | 6373567.7498 |
|    ea23    |   N08   | -107°37m07.487s | +33°54m15.819s | 6373574.9212 |
|    ea24    |   W72   | -107°48m23.996s | +33°47m41.208s | 6373594.9645 |
|    ea25    |   E56   | -107°29m04.138s | +33°50m54.915s | 6373622.6190 |
|    ea26    |   W48   | -107°42m44.329s | +33°50m52.098s | 6373595.5052 |
|    ea27    |   E40   | -107°32m35.422s | +33°52m16.922s | 6373618.9935 |
| ea28 (ref) |   W08   | -107°37m21.648s | +33°53m52.993s | 6373578.4916 |
+------------+---------+-----------------+----------------+--------------+
[11]:
locit_mds.plot_array_configuration(
    locit_plot_folder,     # Folder in which to save the plot
    stations=True,         # Toggle to display the station name alongside the antenna name
    zoff=False,            # Toggle to display the antenna elevation offset by its name
    unit='km',             # Length unit for the plot
    box_size=5,            # Size of the box for the inner array in the unit specified in unit
    display=True
)
[2024-01-12 12:13:36,485]     INFO   astrohack:  Checking parameter values for mds.AstrohackLocitFile.plot_array_configuration
[2024-01-12 12:13:36,486]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:36,488]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:36,489]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:36,532]  WARNING   astrohack:  Destination folder already exists, results may be overwritten
_images/locit_tutorial_22_1.png

Locit

After we have inspected the locit_mds object we can now use locit to obtain antenna position corrections. In this dataset a single antenna, ea06 has been moved, and hence we could skip the other antennas and get position corrections for only it and the reference antenna, ea28. But here we will be getting corrections for all antennas as this can help point out systematic errors with the dataset, such as choosing a bad reference antenna. We include the reference antenna in the fit as a sanity check, the position corrections for the reference antenna, as well as the fixed delay and delay rate are by construction, 0, if they aren’t there is something wrong with the code.

[12]:
%%time
from astrohack.locit import locit

position_mds = locit(
    locit_name,
    position_name=position_name,   # Name of the position file to be created by locit
    elevation_limit=10.0,          # Elevation under which no sources are considered
    polarization='both',           # Combine both R and L polarization phase gains for increased SNR
    fit_engine='scipy',            # Fit data using scipy
    fit_kterm=False,
    fit_delay_rate=True,           # Fit delay rate
    ant="all",                     # Select all antennas
    ddi="all",                     # Select all DDIs
    combine_ddis='simple',         # Combine delays from all DDIs to obtain a single solution with increased SNR
    parallel=True,                 # Do fitting in parallel
    overwrite=True                 # Overwrite previously created position file
)
[2024-01-12 12:13:37,433]     INFO   astrohack:  Checking parameter values for locit.locit
[2024-01-12 12:13:37,435]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:37,436]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:37,436]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:46,171]     INFO   astrohack:  Finished processing
CPU times: user 2.48 s, sys: 166 ms, total: 2.65 s
Wall time: 9.05 s

locit creates a file that is called a position file. This file contains the delays, and the fitted delay model for each antenna

locit also returns the opened position file as a position_mds object. The first step in interacting with the position_mds object is calling its summary

[13]:
position_mds.summary()
####################################################################################################
###                                         Summary for:                                         ###
###                             ./data/locit-input-pha.position.zarr                             ###
####################################################################################################

Full documentation for AstrohackPositionFile objects' API at:
https://astrohack.readthedocs.io/en/stable/_api/autoapi/astrohack/mds/index.html#astrohack.mds.AstrohackPositionFile

Input Parameters:
+-----------------+--------------------------------------+
| Parameter       | Value                                |
+-----------------+--------------------------------------+
| locit_name      | ./data/locit-input-pha.locit.zarr    |
| position_name   | ./data/locit-input-pha.position.zarr |
| elevation_limit | 10.0                                 |
| polarization    | both                                 |
| fit_engine      | scipy                                |
| fit_kterm       | False                                |
| fit_delay_rate  | True                                 |
| ant             | all                                  |
| ddi             | all                                  |
| combine_ddis    | simple                               |
| parallel        | True                                 |
| overwrite       | True                                 |
| version         | 0.4.2                                |
| origin          | locit                                |
+-----------------+--------------------------------------+

Contents:
+----------+
| Antenna  |
+----------+
| ant_ea08 |
| ant_ea23 |
| ant_ea12 |
| ant_ea24 |
| ant_ea21 |
| ant_ea26 |
| ant_ea01 |
| ant_ea15 |
| ant_ea09 |
| ant_ea05 |
| ant_ea19 |
| ant_ea13 |
| ant_ea04 |
| ant_ea07 |
| ant_ea28 |
| ant_ea11 |
| ant_ea22 |
| ant_ea27 |
| ant_ea18 |
| ant_ea10 |
| ant_ea02 |
| ant_ea16 |
| ant_ea25 |
| ant_ea17 |
| ant_ea06 |
| ant_ea20 |
+----------+

Available methods:
+---------------------------+----------------------------------------------------------------------+
| Methods                   | Description                                                          |
+---------------------------+----------------------------------------------------------------------+
| summary                   | Prints summary of the AstrohackpositionFile object, with available   |
|                           | data, attributes and available methods                               |
| export_fit_results        | Export antenna position fit results to a text file.                  |
| plot_sky_coverage         | Plot the sky coverage of the data used for antenna position fitting  |
| plot_delays               | Plot the delays used for antenna position fitting and optionally the |
|                           | resulting fit.                                                       |
| plot_position_corrections | Plot Antenna position corrections on an array configuration plot     |
+---------------------------+----------------------------------------------------------------------+

From the summary we can see that the position file contains simply 2 antennas and no DDIs, as well as 4 different methods: - export_fit_results exports the antenna position corrections to an ascii file. - plot_sky_coverage plots the sky coverage for an antenna and DDI (if present). - plot_delays plots the measured delays as a function of time, hour angle, declination and elevation, - plot_position_corrections Plots the position corrections on an array plot, making it easier to identify systematics

To inspect the data contained in the position file for an antenna we can then simply do:

[14]:
position_mds['ant_ea06']
[14]:
<xarray.Dataset>
Dimensions:      (time: 110)
Coordinates:
  * time         (time) float64 0.0 0.002234 0.004711 ... 0.07838 0.07992
Data variables:
    DECLINATION  (time) float64 dask.array<chunksize=(110,), meta=np.ndarray>
    DELAYS       (time) float32 dask.array<chunksize=(110,), meta=np.ndarray>
    ELEVATION    (time) float64 dask.array<chunksize=(110,), meta=np.ndarray>
    HOUR_ANGLE   (time) float64 dask.array<chunksize=(110,), meta=np.ndarray>
    LST          (time) float64 dask.array<chunksize=(110,), meta=np.ndarray>
    MODEL        (time) float64 dask.array<chunksize=(110,), meta=np.ndarray>
Attributes:
    antenna_info:       {'geocentric_position': [-1602152.0314, -5042031.7101...
    chi_squared:        3.4313970729134775e-23
    elevation_limit:    0.17453292519943295
    fixed_delay_error:  2.133277279077352e-12
    fixed_delay_fit:    2.5331243787608035e-11
    frequency:          [8223000000.0, 8823000000.0]
    polarization:       both
    position_error:     [1.7528819363641415e-12, 1.4090763078825148e-12, 1.55...
    position_fit:       [-2.989452149668351e-11, -1.225892544315829e-11, -5.1...
    rate_error:         2.76108883923351e-11
    rate_fit:           8.518928473107703e-12

The following plot of the sky coverage of the sources for antenna ea06 gives us an idea of how good our results can be. From it we see that basically all possible hour-angles and declinations are covered, which implies that the position correction determinations are as good as they can be given the observing conditions are good and stable enough.

Weather may complicate this measurement by introducing anisotropic and time dependant delays, limiting the methods accuracy.

[15]:
position_plot_folder = 'position_mds_exports'

position_mds.plot_sky_coverage(
    position_plot_folder, # Folder to contain plot
    ant='ea06',           # Plot only antenna ea06
    ddi="all",            # DDI selection irrelevant because we are combining DDIs
    time_unit='hour',     # Unit for observation duration
    angle_unit='deg',     # Unit for sky coordinates
    display=True
)
[2024-01-12 12:13:46,628]     INFO   astrohack:  Checking parameter values for mds.AstrohackPositionFile.plot_sky_coverage
[2024-01-12 12:13:46,630]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:46,634]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:46,635]     INFO   astrohack:  Searching file system for configuration files, please wait ...
_images/locit_tutorial_30_1.png

Below we export the fit results to an ascii file and display it for analysis. In it we can see that the results for the reference antenna are all 0 and the delay RMS is very small, which is indeed what is expected.

Further, below we plot the delays and the delay model that was fitted with locit. From this plot we can see that model delays agree very well with the observed delays leading to a good confidence in the position corrections derived with locit.

[16]:
position_export_folder = 'position_mds_exports'

position_mds.export_fit_results(
    position_export_folder,           # Folder to contain antenna position corrections file
    ant = ['ea06', 'ea28','ea01'],    # select antennas ea06, ea28 and ea01
    position_unit='m',                # Unit for the position corrections
    delay_unit='nsec',                # Unit for delays
    time_unit='hour'                  # Unit for delay rate denominator
)
[2024-01-12 12:13:48,070]     INFO   astrohack:  Checking parameter values for mds.AstrohackPositionFile.export_fit_results
[2024-01-12 12:13:48,075]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:48,076]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:48,076]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:48,124]  WARNING   astrohack:  Destination folder already exists, results may be overwritten
[17]:
with open(position_export_folder+'/position_combined_simple_fit_results.txt', 'r') as file:
    for line in file:
        print(line[:-1])
+---------+------------+-----------------+-------------------+-----------------+------------------+------------------+
| Antenna | RMS [nsec] | F. delay [nsec] |    X offset [m]   |   Y offset [m]  |   Z offset [m]   | Rate [nsec/hour] |
+---------+------------+-----------------+-------------------+-----------------+------------------+------------------+
|   ea01  |  1.57e-02  |  0.015 ± 0.006  |   0.001 ± 0.001   |  0.0055 ± 0.001 | -0.0016 ± 0.001  |  0.000 ± 0.003   |
|   ea06  |  5.86e-03  |  0.025 ± 0.002  | -0.00079 ± 0.0004 | 0.0097 ± 0.0005 | -0.0015 ± 0.0005 |  0.000 ± 0.001   |
|   ea28  |  5.94e-11  |    0.0 ± 0.0    |     0.0 ± 0.0     |    0.0 ± 0.0    |    0.0 ± 0.0     |    0.0 ± 0.0     |
+---------+------------+-----------------+-------------------+-----------------+------------------+------------------+
[18]:
position_mds.plot_delays(
    position_plot_folder,  # Folder to contain plot
    ant='ea06',            # Plot only antenna ea06
    ddi='all',             # DDI selection irrelevant because we are combining DDIs
    time_unit='hour',      # Unit for observation duration
    angle_unit='deg',      # Unit for sky coordinates
    delay_unit='nsec',     # Unit for delays
    plot_model=True,       # Plot fitted delay model
    display=True
)
[2024-01-12 12:13:48,146]     INFO   astrohack:  Checking parameter values for mds.AstrohackPositionFile.plot_delays
[2024-01-12 12:13:48,148]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:48,149]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:48,150]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:48,192]  WARNING   astrohack:  Destination folder already exists, results may be overwritten
_images/locit_tutorial_34_1.png

One extra way to check for systematic errors in antenna position determinations is to plot the corrections for the whole array. If all the corrections point the same way this might be an indication that the chosen reference_antenna has an error in its position.

[19]:
position_mds.plot_position_corrections(
    position_plot_folder, # Folder to contain plot
    unit='km',            # Unit for the x and Y axes
    box_size=5,           # Size for the box containing the inner array
    scaling=250,          # scaling to be applied to corrections
    display=True
)
[2024-01-12 12:13:49,916]     INFO   astrohack:  Checking parameter values for mds.AstrohackPositionFile.plot_position_corrections
[2024-01-12 12:13:49,917]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:49,918]     INFO   astrohack:  Failed to find module configuration in environment ... attemping to check common directories ...
[2024-01-12 12:13:49,919]     INFO   astrohack:  Searching file system for configuration files, please wait ...
[2024-01-12 12:13:49,962]  WARNING   astrohack:  Destination folder already exists, results may be overwritten
_images/locit_tutorial_36_1.png