예제 #1
0
 def test_azel_to_enu(self):
     """Closure tests for (az, el) to ENU conversion and vice versa."""
     e, n, u = katpoint.azel_to_enu(self.az, self.el)
     new_az, new_el = katpoint.enu_to_azel(e, n, u)
     assert_angles_almost_equal(new_az, self.az, decimal=15)
     assert_angles_almost_equal(new_el, self.el, decimal=15)
예제 #2
0
# How about an all-sky fringe pattern for the first baseline?
#############################################################

baseline_m = ant_a.baseline_toward(ant_b)
lat = ant_a.observer.lat
rf_freq = 1.8e9

# In terms of (az, el)
x_range, y_range = np.linspace(-1., 1., 201), np.linspace(-1., 1., 201)
x_grid, y_grid = np.meshgrid(x_range, y_range)
xx, yy = x_grid.flatten(), y_grid.flatten()
outside_circle = xx * xx + yy * yy > 1.0
xx[outside_circle] = yy[outside_circle] = np.nan
az, el = katpoint.plane_to_sphere['SIN'](0.0, np.pi / 2.0, xx, yy)

source_vec = katpoint.azel_to_enu(az, el)
geom_delay = -np.dot(baseline_m, source_vec) / katpoint.lightspeed
turns = geom_delay * rf_freq
phase = turns - np.floor(turns)

plt.figure(1)
plt.clf()
plt.imshow(phase.reshape(x_grid.shape),
           origin='lower',
           extent=[x_range[0], x_range[-1], y_range[0], y_range[-1]])

# In terms of (ha, dec)
# One second resolution on hour angle - picks up fast fringes that way
ha_range = np.linspace(-12., 12., 86401.)
dec_range = np.linspace(-90., katpoint.rad2deg(lat) + 90., 101)
ha_grid, dec_grid = np.meshgrid(ha_range, dec_range)
 num_ts = data.shape[0]
 if state != 'track':
     print "scan %3d (%4d samples) skipped '%s'" % (scan_ind, num_ts, state)
     continue
 if num_ts < 2:
     print "scan %3d (%4d samples) skipped - too short" % (scan_ind, num_ts)
     continue
 if target.name in excluded_targets:
     print "scan %3d (%4d samples) skipped - excluded '%s'" % (scan_ind, num_ts, target.name)
     continue
 # Extract visibilities for scan as an array of shape (T, F, B)
 vis = data.vis[:]
 ts = data.timestamps[:]
 # Obtain unit vectors pointing from array antenna to target for each timestamp in scan
 az, el = target.azel(ts, array_ant)
 targetdir = np.array(katpoint.azel_to_enu(az, el))
 # Invert sign of target vector, as positive dot product with baseline implies negative delay / advance
 # Augment target vector with a 1 to be 4-dimensional, as this allows fitting of constant (receiver) delay
 # This array has shape (4, T), with the augmented target vectors as columns
 scan_augmented_targetdir = np.vstack((-targetdir, np.ones(len(el))))
 # Create section of design matrix with shape (B P, T), by inserting target dir vectors in right places
 augm_block = np.dot(bl_parameter_map, scan_augmented_targetdir)
 # Rearrange shape to (P, B T) to be compatible with ravelled delay data, which has shape (B T,)
 augm_block = augm_block.reshape(num_bls, num_params, num_ts).swapaxes(0, 1).reshape(num_params, -1)
 augmented_targetdir.append(augm_block)
 # Group delay is proportional to phase slope across the band - estimate this as the phase difference between
 # consecutive frequency channels calculated via np.diff. Pick antenna 1 as reference antenna -> correlation
 # product XY* means we actually measure phase(antenna1) - phase(antenna2), therefore flip the sign.
 # Also divide by channel frequency difference, which correctly handles gaps in frequency coverage.
 phase_diff_per_Hz = np.diff(-np.angle(vis), axis=1) / freq_diff[:, np.newaxis]
 # Convert to a delay in seconds
예제 #4
0
 num_ts = data.shape[0]
 if state != 'track':
     print "scan %3d (%4d samples) skipped '%s'" % (scan_ind, num_ts, state)
     continue
 if num_ts < 2:
     print "scan %3d (%4d samples) skipped - too short" % (scan_ind, num_ts)
     continue
 if target.name in excluded_targets:
     print "scan %3d (%4d samples) skipped - excluded '%s'" % (scan_ind, num_ts, target.name)
     continue
 # Extract visibilities for scan as an array of shape (T, F, B)
 vis = data.vis[:]
 ts = data.timestamps[:]
 # Obtain unit vectors pointing from array antenna to target for each timestamp in scan
 az, el = target.azel(ts, array_ant)
 targetdir = np.array(katpoint.azel_to_enu(az, el))
 # Invert sign of target vector, as positive dot product with baseline implies negative delay / advance
 # Augment target vector with a 1 to be 4-dimensional, as this allows fitting of constant (receiver) delay
 # This array has shape (4, T), with the augmented target vectors as columns
 scan_augmented_targetdir = np.vstack((-targetdir, np.ones(len(el))))
 # Create section of design matrix with shape (B P, T), by inserting target dir vectors in right places
 augm_block = np.dot(bl_parameter_map, scan_augmented_targetdir)
 # Rearrange shape to (P, B T) to be compatible with ravelled delay data, which has shape (B T,)
 augm_block = augm_block.reshape(num_bls, num_params, num_ts).swapaxes(0, 1).reshape(num_params, -1)
 augmented_targetdir.append(augm_block)
 # Group delay is proportional to phase slope across the band - estimate this as the phase difference between
 # consecutive frequency channels calculated via np.diff. Pick antenna 1 as reference antenna -> correlation
 # product XY* means we actually measure phase(antenna1) - phase(antenna2), therefore flip the sign.
 # Also divide by channel frequency difference, which correctly handles gaps in frequency coverage.
 phase_diff_per_Hz = np.diff(-np.angle(vis), axis=1) / freq_diff[:, np.newaxis]
 # Convert to a delay in seconds