Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for array imperfections #65

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions nenupy/instru/interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,19 @@
"""

def __init__(self,
position: EarthLocation,
antenna_names: np.ndarray,
antenna_positions: np.ndarray,
antenna_gains: np.ndarray
):
position: EarthLocation,
antenna_names: np.ndarray,
antenna_positions: np.ndarray,
antenna_gains: np.ndarray,
extra_delays: np.ndarray = None,
feed_gains: np.ndarray = None,
):
self.position = position
self.antenna_names = antenna_names
self.antenna_positions = antenna_positions
self.antenna_gains = antenna_gains
self.extra_delays = extra_delays
self.feed_gains = feed_gains


def __getitem__(self, n):
Expand Down Expand Up @@ -540,6 +544,8 @@
the targeted pointing directions over the time.
:type pointing:
:class:`~nenupy.astro.pointing.Pointing`
:param return_complex:
Return complex array factor if `True` or power if `False`

:return:
Array factor of the antenna distribution shaped as ``(time, frequency, 1, coordinates)``.
Expand All @@ -558,7 +564,12 @@
# antenna position and the difference between sky and
# pointing ground projections.
geometric_delays = self._geometric_delays(sky, effective_pointing)


# Add delay errors for each antennae
# They could be cable connection errors during construction, cables of wrong length, ...
if self.extra_delays is not None:
geometric_delays += self.extra_delays[:, None, None, None, None]

Check warning on line 571 in nenupy/instru/interferometer.py

View check run for this annotation

Codecov / codecov/patch

nenupy/instru/interferometer.py#L571

Added line #L571 was not covered by tests

# Use the sky frequency attribute to compute the wavelength
# and prepare the coefficient of the exponential with
# the correct dimensions.
Expand All @@ -569,6 +580,12 @@
) # (antenna, time, frequency, polar, coord)

exponent = coeff * geometric_delays

# apply fedd gain errors if any
if self.feed_gains is not None:
print(self.feed_gains)
exponent *= self.feed_gains[:, None, None, None, None]

Check warning on line 587 in nenupy/instru/interferometer.py

View check run for this annotation

Codecov / codecov/patch

nenupy/instru/interferometer.py#L586-L587

Added lines #L586 - L587 were not covered by tests

# coord_chunk = exponent.shape[-1]//cpu_count()
# coord_chunk = 1 if coord_chunk == 0 else coord_chunk
# exponent = da.rechunk(
Expand All @@ -582,9 +599,7 @@

if return_complex:
return complex_array_factor
else:
# return np.sqrt(np.real(complex_array_factor * np.conjugate(complex_array_factor)))
return np.real(complex_array_factor * np.conjugate(complex_array_factor))
return complex_array_factor.real**2 + complex_array_factor.imag**2


def beam(self, sky: Sky, pointing: Pointing, return_complex: bool = False) -> Sky:
Expand Down
18 changes: 11 additions & 7 deletions nenupy/instru/nenufar.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ class MiniArray(Interferometer):

"""

def __init__(self, index: int = 0):
def __init__(self,
index: int = 0,
extra_delays: np.ndarray = None,
feed_gains: np.ndarray = None, ):
self.index = index

try:
Expand Down Expand Up @@ -346,12 +349,13 @@ def __init__(self, index: int = 0):
self._antenna_gain for _ in range(antenna_names.size)
])

super().__init__(
position=position,
antenna_names=antenna_names,
antenna_positions=antenna_positions,
antenna_gains=antenna_gains
)
super().__init__(position=position,
antenna_names=antenna_names,
antenna_positions=antenna_positions,
antenna_gains=antenna_gains,
extra_delays=extra_delays,
feed_gains=feed_gains
)


def __repr__(self):
Expand Down