def __init__(self, uv_wavelengths, visibilities, noise_map, antennas, time=None): self.uv_wavelengths = uv_wavelengths self.visibilities = visibilities self.noise_map = noise_map if (self.uv_wavelengths.shape == antennas.shape): self.antennas = antennas else: raise ValueError() self.time = time # NOTE: In the case where the real an imag part of the noise is the # same, which in real data is not. # C = np.diag( # np.power( # np.divide( # np.average(a=noise_map, axis=-1), # self.amplitudes, # ), # -2 # ) # ) self.C = np.diag( np.power( np.divide( np.sqrt( np.add( self.visibilities[:, 0]**2.0 * self.noise_map[:, 0]**2.0, self.visibilities[:, 1]**2.0 * self.noise_map[:, 1]**2.0 ) ), self.amplitudes**2.0, ), -2 ) ) self.f = calibration_utils.compute_f_matrix_from_antennas( antennas=self.antennas ) self.A = calibration_utils.compute_A_matrix_from_f_and_C_matrices( f=self.f, C=self.C ) self.B = calibration_utils.compute_B_matrix_from_f_and_C_matrices( f=self.f, C=self.C )
antennas = fits.getdata("./antennas.fits") if not (uv_wavelengths.shape[0] == antennas.shape[0]): raise ValueError("...") antennas_unique = np.unique(antennas) if os.path.isfile("./phase_errors.fits"): phase_errors = fits.getdata(filename="./phase_errors.fits") else: np.random.seed(seed=random_utils.seed_generator()) phase_errors = np.random.uniform(low=-np.pi / 2.0, high=np.pi / 2.0, size=(antennas_unique.size, )) fits.writeto("./phase_errors.fits", data=phase_errors) f = calibration_utils.compute_f_matrix_from_antennas(antennas=antennas) data_with_phase_errors = False self_calibration = False if __name__ == "__main__": def corrupt_visibilities_from_f_matrix_and_phase_errors( visibilities, f, phase_errors): phases_corrupted = np.add(visibilities.phases, np.matmul(f.T, phase_errors)) return aa.structures.visibilities.Visibilities( visibilities_1d=np.stack(arrays=(visibilities.amplitudes * np.cos(phases_corrupted),