Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+^ look_in_catalog avoid unrelated keys for cat_type #1506

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
- ATA has been added to the list of known telescopes.

### Fixed
- Bug in the `look_in_catalog` utility function that expected keys which could be
radonnachie marked this conversation as resolved.
Show resolved Hide resolved
optional for some phase-center catalog-entry types. This was noticed as an issue when
adding two uvh5 objects that were of type "sidereal" which did not have "cat_times"
entries in their phase-center catalogs.
- Bug in selecting baselines on a UVData object using `bls` keyword with 3-tuples and
more than one polarization (introduced in 3.1.2).

Expand Down
3 changes: 2 additions & 1 deletion src/pyuvdata/utils/phase_center_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def look_in_catalog(
tol_dict[key][1],
)
else:
cat_diffs += check_dict[key] is not None
cat_diffs += check_dict.get(key) is not None

radonnachie marked this conversation as resolved.
Show resolved Hide resolved
if (cat_diffs == 0) or (cat_name == name):
if cat_diffs < match_diffs:
# If our current match is an improvement on any previous matches,
Expand Down
28 changes: 28 additions & 0 deletions tests/utils/test_phase_center_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
# Licensed under the 2-clause BSD License
"""Tests for phase center catalog utility functions."""

import os

import pytest

import pyuvdata.utils.phase_center_catalog as ps_cat_utils
from pyuvdata import UVData
from pyuvdata.data import DATA_PATH

casa_tutorial_uvfits = os.path.join(
DATA_PATH, "day2_TDEM0003_10s_norx_1src_1spw.uvfits"
)


def test_generate_new_phase_center_id_errs():
Expand All @@ -13,3 +21,23 @@ def test_generate_new_phase_center_id_errs():

with pytest.raises(ValueError, match="Provided cat_id was found in reserved_ids"):
ps_cat_utils.generate_new_phase_center_id(cat_id=1, reserved_ids=[1, 2, 3])


def test_look_in_catalog_missing_entries():
casa_uvfits = UVData()
casa_uvfits.read(casa_tutorial_uvfits)
phase_cat = casa_uvfits.phase_center_catalog

# Try that this works normally if we do nothing
assert ps_cat_utils.look_in_catalog(
phase_cat, cat_name=phase_cat[0]["cat_name"]
) == (0, 5)

# Now delete some keys
for value in phase_cat.values():
if "cat_times" in value:
del value["cat_times"]
# Now re-run the above and verify things work as expected
assert ps_cat_utils.look_in_catalog(
phase_cat, cat_name=phase_cat[0]["cat_name"]
) == (0, 5)
Loading