Skip to content

Commit af0b9b8

Browse files
committed
Wrap uvw-tracker to generate flattened UVW ndarray
1 parent abb2bce commit af0b9b8

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

‎src/fastimgproto/telescope/base.py‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,24 @@ def uvw_at_local_hour_angle(self, local_hour_angle, dec):
163163
rotation = xyz_to_uvw_rotation_matrix(local_hour_angle, dec)
164164
return np.dot(rotation, self.baseline_local_xyz.T).T
165165

166-
def uvw_tracking_skycoord(self, pointing_centre, obs_times):
166+
def _uvw_tracking_skycoord_by_lha(self, pointing_centre, obs_times):
167+
"""
168+
Calculate the UVW-array towards pointing centre for each obs_time.
169+
170+
Each obs_time corresponds to a local hour-angle (LHA) for the given
171+
pointing centre. This function returns an OrderedDict mapping those
172+
LHA's (in same ordering as obs_times) to an ndarray of uvw-coords
173+
corresponding to that instantaneous observation.
174+
175+
Args:
176+
pointing_centre (astropy.coords.SkyCoord): Pointing centre co-ords
177+
for UVW calculation.
178+
obs_times (list): List of :class:`astropy.time.Time`, the instants
179+
of observation.
180+
Returns:
181+
dict: Mapping from LHA (astropy.coords.Longitude)-> UVW-ndarray,
182+
where UVW has (implicit) units of metres.
183+
"""
167184
lha_uvw_map = OrderedDict()
168185
for time in obs_times:
169186
lha = self.lha(pointing_centre.ra, time)
@@ -172,6 +189,27 @@ def uvw_tracking_skycoord(self, pointing_centre, obs_times):
172189
)
173190
return lha_uvw_map
174191

192+
def uvw_tracking_skycoord(self, pointing_centre, obs_times):
193+
"""
194+
Calculate the UVW-array towards pointing centre for all obs_times.
195+
196+
This function calculates an ndarray of uvw-coords corresponding to
197+
an instantaneous observation at each of ``obs_times``, then
198+
concatenates the results to produce an ndarray of length
199+
``n_baselines * len(obs_times)``
200+
201+
Args:
202+
pointing_centre (astropy.coords.SkyCoord): Pointing centre co-ords
203+
for UVW calculation.
204+
obs_times (list): List of :class:`astropy.time.Time`, the instants
205+
of observation.
206+
Returns:
207+
numpy.ndarray: UVW-ndarray, where UVW has (implicit) units of metres.
208+
"""
209+
lha_uvw_map = self._uvw_tracking_skycoord_by_lha(
210+
pointing_centre, obs_times)
211+
return np.concatenate(lha_uvw_map.values())
212+
175213

176214
def generate_baselines_and_labels(antenna_positions, antenna_labels):
177215
"""

‎tests/test_telescope/test_telescope.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,17 @@ def test_uvw_tracking_skyposn():
7373
tt_lha = telescope.lha(azimuth_target.ra, tt)
7474
assert np.fabs(tt_lha) < 0.2 * u.arcsec
7575

76-
obs_times = [tt - 10*u.second, tt, tt + 10*u.second]
77-
uvw_by_tracking = telescope.uvw_tracking_skycoord(
76+
obs_times = [tt - 10 * u.second, tt, tt + 10 * u.second]
77+
uvw_by_tracking = telescope._uvw_tracking_skycoord_by_lha(
7878
azimuth_target,
7979
obs_times=obs_times)
8080
assert len(uvw_by_tracking) == len(obs_times)
8181

8282
uvw_by_lha = telescope.uvw_at_local_hour_angle(tt_lha, azimuth_target.dec)
8383
assert uvw_by_tracking.keys()[1] == tt_lha
8484
assert (uvw_by_lha == uvw_by_tracking.values()[1]).all()
85+
86+
n_total_baselines = len(telescope.baseline_local_xyz) * len(obs_times)
87+
flattened_uvw_array = telescope.uvw_tracking_skycoord(
88+
azimuth_target, obs_times)
89+
assert len(flattened_uvw_array) == n_total_baselines

0 commit comments

Comments
 (0)