def main(): if len(sys.argv) < 2: print("Image the first set of visibilites from a visibilities file") print() print("usage: {} <file>".format(sys.argv[0])) sys.exit(1) else: path = sys.argv[1] _, body = next(read_full(path)) cm = correlation_matrix(body, constants.NUM_ANTS) corr_data = np.abs(cm) corr_data[np.diag_indices(constants.NUM_ANTS)] = np.min(corr_data) gains = np.ones((1, constants.NUM_ANTS), dtype=np.complex64) cal_mat = gains.conj().transpose() * gains cm = cal_mat * cm U, V = load_antpos(constants.ANTPOS) mDuv = constants.C_MS / FRQ / 2.0 normal = [] for i in range(5): start = time.time() grid(U, V, cm, mDuv, constants.IMAGE_RES) end = time.time() normal.append(end - start) print("normal: {}".format(np.average(normal))) fast = [] for i in range(5): start = time.time() grid_fast(U, V, cm, mDuv, constants.IMAGE_RES) end = time.time() fast.append(end - start) print("fast: {}".format(np.average(fast)))
def make_image(cm, frequency): """ Create an image from the correlation matrix """ # No calibration vector applied gains = np.ones((1, constants.NUM_ANTS), dtype=np.complex64) cal_mat = gains.conj().transpose() * gains # Apply supplied calibration vector cm = cal_mat * cm U, V = load_antpos(constants.ANTPOS) mDuv = constants.C_MS / frequency / 2.0 gridvis = grid(U, V, cm, mDuv, constants.IMAGE_RES) gridvis = np.fft.fftshift(gridvis) gridvis = np.flipud(np.fliplr(gridvis)) gridvis = np.conjugate(gridvis) return np.real(np.fft.fftshift(np.fft.fft2(gridvis)))
def test_load_antpos(self): load_antpos(constants.ANTPOS)