Skip to content

Commit

Permalink
added tests in uvdata.check for non-zero uvw of autocorr and near-zer…
Browse files Browse the repository at this point in the history
…o uvw of cross corr
  • Loading branch information
nkern authored and bhazelton committed Jul 10, 2018
1 parent e7cf23c commit 4f330f1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pyuvdata/tests/test_uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,22 @@ def test_check(self):
== self.uv_object.ant_2_array)[0])
nt.assert_true(self.uv_object.check())

# test auto and cross corr uvw_array
uvd = UVData()
uvd.read_miriad(os.path.join(DATA_PATH, "zen.2457698.40355.xx.HH.uvcA"))
autos = np.isclose(uvd.ant_1_array - uvd.ant_2_array, 0.0)
auto_inds = np.where(autos)[0]
cross_inds = np.where(~autos)[0]

# make auto have non-zero uvw coords, assert ValueError
uvd.uvw_array[auto_inds[0], 0] = 0.1
nt.assert_raises(ValueError, uvd.check)

# make cross have |uvw| zero, assert ValueError
uvd.read_miriad(os.path.join(DATA_PATH, "zen.2457698.40355.xx.HH.uvcA"))
uvd.uvw_array[cross_inds[0]][:] = 0.0
nt.assert_raises(ValueError, uvd.check)

def test_nants_data_telescope(self):
self.uv_object.Nants_data = self.uv_object.Nants_telescope - 1
nt.assert_true(self.uv_object.check)
Expand Down
11 changes: 10 additions & 1 deletion pyuvdata/uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self):
self._uvw_array = uvp.UVParameter('uvw_array', description=desc,
form=('Nblts', 3),
expected_type=np.float,
acceptable_range=(0.0, 1e8), tols=.001)
acceptable_range=(0, 1e8), tols=1e-3)

desc = ('Array of times, center of integration, shape (Nblts), '
'units Julian Date')
Expand Down Expand Up @@ -384,6 +384,15 @@ def check(self, check_extra=True, run_check_acceptability=True):
'which will raise an error when writing uvfits or '
'miriad file types'.format(key=key))

# check auto and cross-corrs have sensible uvws
autos = np.isclose(self.ant_1_array - self.ant_2_array, 0.0)
if not np.all(np.isclose(self.uvw_array[autos], 0.0)):
raise ValueError("Some auto-correlations have non-zero "
"uvw_array coordinates.")
if np.any(np.isclose([np.linalg.norm(uvw) for uvw in self.uvw_array[~autos]], 0.0)):
raise ValueError("Some cross-correlations have near-zero "
"uvw_array magnitudes.")

return True

def set_drift(self):
Expand Down

0 comments on commit 4f330f1

Please sign in to comment.