Skip to content

Commit

Permalink
Fix up MS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton committed Jul 21, 2017
1 parent 4c89d07 commit dce82dc
Showing 1 changed file with 7 additions and 41 deletions.
48 changes: 7 additions & 41 deletions pyuvdata/tests/test_ms.py
Expand Up @@ -66,11 +66,14 @@ def test_readMSreadUVFITS():
uvfits_uv.history = ""

# the objects won't be equal because uvfits adds some optional parameters
# and the ms sets default antenna diameters even thoug the uvfits file doesn't have them
nt.assert_false(uvfits_uv == ms_uv)
# they are equal if only required parameters are checked:
nt.assert_true(uvfits_uv.__eq__(ms_uv, check_extra=False))

# set those parameters to none to check that the rest of the objects match
ms_uv.antenna_diameters = None

for p in uvfits_uv.extra():
fits_param = getattr(uvfits_uv, p)
ms_param = getattr(ms_uv, p)
Expand Down Expand Up @@ -139,45 +142,6 @@ def test_readMSWriteMiriad():
del(miriad_uv)


def test_readUVFITS_readMS():
"""
Test reading in an ms produced by casa importuvfits and compare to original uvfits
"""
ms_uv = UVData()
uvfits_uv = UVData()
ms_file = os.path.join(DATA_PATH, 'day2_TDEM0003_10s_norx_1src_1spw.ms')
uvfits_file = os.path.join(
DATA_PATH, 'day2_TDEM0003_10s_norx_1src_1spw.uvfits')
uvtest.checkWarnings(uvfits_uv.read_uvfits, [uvfits_file],
message='Telescope EVLA is not')
uvtest.checkWarnings(ms_uv.read_ms, [ms_file],
message='Telescope EVLA is not',
nwarnings=0)
# Casa scrambles the history parameter. Replace for now.
ms_uv.history = uvfits_uv.history

# the objects won't be equal because uvfits adds some optional parameters
nt.assert_false(uvfits_uv == ms_uv)
# they are equal if only required parameters are checked:
nt.assert_true(uvfits_uv.__eq__(ms_uv, check_extra=False))

# set those parameters to none to check that the rest of the objects match
for p in uvfits_uv.extra():
fits_param = getattr(uvfits_uv, p)
ms_param = getattr(ms_uv, p)
if fits_param.name in UVFITS.uvfits_required_extra and ms_param.value is None:
fits_param.value = None
setattr(uvfits_uv, p, fits_param)

# extra keywords are also different, set both to empty dicts
uvfits_uv.extra_keywords = {}
ms_uv.extra_keywords = {}

nt.assert_equal(ms_uv, uvfits_uv)
del(ms_uv)
del(uvfits_uv)


def test_multi_files():
"""
Reading multiple files at once.
Expand All @@ -186,20 +150,22 @@ def test_multi_files():
uv_multi = UVData()
uvfits_file = os.path.join(
DATA_PATH, 'day2_TDEM0003_10s_norx_1src_1spw.uvfits')
uvtest.checkWarnings(uv_full.read_uvfits, [
uvfits_file], message='Telescope EVLA is not')
uvtest.checkWarnings(uv_full.read_uvfits, [uvfits_file], message='Telescope EVLA is not')
testfile1 = os.path.join(DATA_PATH, 'multi_1.ms')
testfile2 = os.path.join(DATA_PATH, 'multi_2.ms')
uv_multi.read_ms([testfile1, testfile2])
# Casa scrambles the history parameter. Replace for now.
uv_multi.history = uv_full.history

# the objects won't be equal because uvfits adds some optional parameters
# and the ms sets default antenna diameters even thoug the uvfits file doesn't have them
nt.assert_false(uv_multi == uv_full)
# they are equal if only required parameters are checked:
nt.assert_true(uv_multi.__eq__(uv_full, check_extra=False))

# set those parameters to none to check that the rest of the objects match
uv_multi.antenna_diameters = None

for p in uv_full.extra():
fits_param = getattr(uv_full, p)
ms_param = getattr(uv_multi, p)
Expand Down

0 comments on commit dce82dc

Please sign in to comment.