Skip to content

Commit

Permalink
generalizing jones matrix for Nfeeds=1,2
Browse files Browse the repository at this point in the history
  • Loading branch information
slosar authored and bhazelton committed Jan 28, 2025
1 parent c93c507 commit a81053d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/pyuvsim/antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_beam_jones(
"""
Calculate the jones matrix for this antenna in the direction of sources.
A 2 x 2 x Nsources array of Efield vectors in Az/Alt.
A Nfeeds x 2 x Nsources array of Efield vectors in Az/Alt.
Parameters
----------
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_beam_jones(
Returns
-------
jones_matrix : array_like of float
Jones matricies for each source location, shape (2,2, Ncomponents). The
Jones matricies for each source location, shape (Nfeeds,2, Ncomponents). The
first axis is feed, the second axis is vector component on the sky in az/za.
"""
Expand Down Expand Up @@ -137,17 +137,14 @@ def get_beam_jones(
interp_data = bi.compute_response(**interp_kwargs)

Ncomponents = source_za.shape[-1]

Nfeeds = interp_data.shape[1]
# interp_data has shape:
# (Naxes_vec, Nfeeds, 1 (freq), Ncomponents (source positions))
jones_matrix = np.zeros((2, 2, Ncomponents), dtype=complex)
jones_matrix = np.zeros((Nfeeds, 2, Ncomponents), dtype=complex)

# first axis is feed, second axis is theta, phi (opposite order of beam!)
jones_matrix[0, 0] = interp_data[1, 0, 0, :]
jones_matrix[1, 1] = interp_data[0, 1, 0, :]
jones_matrix[0, 1] = interp_data[0, 0, 0, :]
jones_matrix[1, 0] = interp_data[1, 1, 0, :]

jones_matrix[:, 0] = interp_data[1, :, 0, :]
jones_matrix[:, 1] = interp_data[0, :, 0, :]
return jones_matrix

def __eq__(self, other):
Expand Down
9 changes: 7 additions & 2 deletions src/pyuvsim/uvsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,13 @@ def make_visibility(self):
# Sum over source component axis:
vij = np.sum(vij, axis=2)

# Reshape to be [xx, yy, xy, yx]
vis_vector = np.asarray([vij[0, 0], vij[1, 1], vij[0, 1], vij[1, 0]])
Nfeeds = vij.shape[0]
assert (Nfeeds<=2)
# Reshape to be [xx] for one feed or [xx, yy, xy, yx] for two feeds
if Nfeeds == 1:
vis_vector = np.asarray([vij[0,0]])

Check warning on line 398 in src/pyuvsim/uvsim.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvsim/uvsim.py#L398

Added line #L398 was not covered by tests
elif Nfeeds == 2:
vis_vector = np.asarray([vij[0, 0], vij[1, 1], vij[0, 1], vij[1, 0]])
return vis_vector


Expand Down

0 comments on commit a81053d

Please sign in to comment.