Skip to content

Commit

Permalink
put observer from MS files into extra_keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton authored and plaplant committed Sep 30, 2021
1 parent e58a6f1 commit 0d4e689
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions pyuvdata/uvdata/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,13 @@ def _write_ms_observation(self, filepath):
observation_table.addcols(name_col_desc)
observation_table.putcell("TELESCOPE_LOCATION", 0, self.telescope_location)

observation_table.putcell(
"OBSERVER",
0,
self.extra_keywords["OBSERVER"]
if ("OBSERVER" in self.extra_keywords.keys())
else self.telescope_name,
)
extra_upper = [key.upper() for key in self.extra_keywords.keys()]
if "OBSERVER" in extra_upper:
key_ind = extra_upper.index("OBSERVER")
key = list(self.extra_keywords.keys())[key_ind]
observation_table.putcell("OBSERVER", 0, self.extra_keywords[key])
else:
observation_table.putcell("OBSERVER", 0, self.telescope_name)

def _write_ms_polarization(self, filepath):
"""
Expand Down Expand Up @@ -1866,6 +1866,7 @@ def read_ms(
tb_obs = tables.table(filepath + "/OBSERVATION", ack=False)
self.telescope_name = tb_obs.getcol("TELESCOPE_NAME")[0]
self.instrument = tb_obs.getcol("TELESCOPE_NAME")[0]
self.extra_keywords["observer"] = tb_obs.getcol("OBSERVER")[0]
full_antenna_positions = tb_ant.getcol("POSITION")
n_ants_table = full_antenna_positions.shape[0]
xyz_telescope_frame = tb_ant.getcolkeyword("POSITION", "MEASINFO")["Ref"]
Expand Down
4 changes: 2 additions & 2 deletions pyuvdata/uvdata/tests/test_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_cotter_ms():
def test_read_nrao_loopback(tmp_path, nrao_uv):
"""Test reading in a CASA tutorial ms file and looping it through write_ms."""
uvobj = nrao_uv
expected_extra_keywords = ["DATA_COL"]
expected_extra_keywords = ["DATA_COL", "observer"]

assert sorted(expected_extra_keywords) == sorted(uvobj.extra_keywords.keys())

Expand All @@ -114,7 +114,7 @@ def test_read_lwa(tmp_path):
"""Test reading in an LWA ms file."""
uvobj = UVData()
testfile = os.path.join(DATA_PATH, "lwasv_cor_58342_05_00_14.ms.tar.gz")
expected_extra_keywords = ["DATA_COL"]
expected_extra_keywords = ["DATA_COL", "observer"]

import tarfile

Expand Down

0 comments on commit 0d4e689

Please sign in to comment.