Skip to content

Commit 1c617ef

Browse files
committed
fix some edge cases discovered with HERA and full freq MWA beams
1 parent 79bf774 commit 1c617ef

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/pyuvdata/uvbeam/uvbeam.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,20 +1479,26 @@ def efield_to_feed_iresponse(
14791479
for va_i in range(beam_object.Naxes_vec):
14801480
for f_i in range(beam_object.Nfeeds):
14811481
az_angles = np.angle(np.squeeze(flip_array[va_i, f_i, :, zenith_ind]))
1482+
az_angles = az_angles.reshape((beam_object.Nfreqs, beam_object.Naxes1))
14821483
az_angles[az_angles < 0] += 2 * np.pi
1483-
az_flip = abs(az_angles - np.unwrap(az_angles, period=np.pi)) > 1
1484+
az_angle_diff = abs(az_angles - np.unwrap(az_angles, period=np.pi))
1485+
az_flip = np.logical_and(az_angle_diff > 1, az_angle_diff < 4)
14841486
# az_flip is shape (Nfreqs, Naxis1), need to reorder to get
14851487
# those axes adjacent
14861488
flip_array = np.transpose(flip_array, axes=(0, 1, 2, 4, 3))
1487-
flip_array[va_i, f_i, :, az_flip[0]] *= -1
1489+
flip_array[va_i, f_i, az_flip] *= -1
14881490
# now switch back
14891491
flip_array = np.transpose(flip_array, axes=(0, 1, 2, 4, 3))
14901492
# check if zenith response is mostly negative now, if so make it
14911493
# positive
14921494
# use mean instead of max because can occasionally get max
14931495
# values just above zero
1494-
if np.mean(flip_array[va_i, f_i, :, zenith_ind]) < 0:
1495-
flip_array[va_i, f_i] *= -1
1496+
# this is frequency dependent because the earlier flips are
1497+
# frequency dependent so keep the freq axis
1498+
mean_zen_val = np.mean(
1499+
np.squeeze(flip_array[va_i, f_i, :, zenith_ind].real), axis=-1
1500+
)
1501+
flip_array[va_i, f_i, mean_zen_val < 0] *= -1
14961502

14971503
# to compute the time delay, first sum the flipped array across the vector
14981504
# direction axis -- this gives us what is common to each instrumental

0 commit comments

Comments
 (0)