def test_vis_calc(): # Construct a shell with a single point source at the zenith and confirm against analytic calculation. ant1_enu = np.array([0, 0, 0]) ant2_enu = np.array([0.0, 14.6, 0]) bl = visibility.baseline(ant1_enu, ant2_enu) freqs = np.array([1e8]) nfreqs = 1 fov=20 #Deg ## Longitude/Latitude in degrees. nside=128 ind = 10 center = list(hp.pix2ang(nside, ind, lonlat=True)) centers = [center] npix = nside**2 * 12 shell = np.zeros((npix, nfreqs)) pix_area = 4* np.pi / float(npix) shell[ind] = 1 # Jy/pix shell[ind] *= visibility.jy2Tstr(freqs[0], bm=pix_area) # K obs = visibility.observatory(latitude, longitude, array=[bl], freqs=freqs) obs.pointing_centers = centers obs.set_fov(fov) # resol = np.sqrt(4*np.pi/float(npix)) obs.set_beam('uniform') visibs = obs.make_visibilities(shell) print visibs nt.assert_true(np.real(visibs) == 1.0) #Unit point source at zenith
def test_offzenith_vis(): # Construct a shell with a single point source a known position off from zenith. # Similar to test_vis_calc, but set the pointing center 5deg off from the zenith and adjust analytic calculation freqs = [1.0e8] Nfreqs = 1 fov = 60 ant1_enu = np.array([0, 0, 0]) ant2_enu = np.array([0.0, 140.6, 0]) bl = visibility.baseline(ant1_enu, ant2_enu) Nside=128 ind = 9081 center = list(hp.pix2ang(Nside, ind, lonlat=True)) centers = [center] Npix = Nside**2 * 12 pix_area = 4*np.pi/float(Npix) shell = np.zeros((Npix, Nfreqs)) # Choose an index 5 degrees off from the pointing center phi, theta = hp.pix2ang(Nside, ind, lonlat=True) ind = hp.ang2pix(Nside, phi, theta-5, lonlat=True) shell[ind] = 1 # Jy/pix shell[ind] *= visibility.jy2Tstr(freqs[0], pix_area) # K obs = visibility.observatory(latitude, longitude, array=[bl], freqs=freqs) obs.pointing_centers = [[phi, theta]] obs.set_fov(fov) resol = np.sqrt(pix_area) obs.set_beam('uniform') vis_calc = obs.make_visibilities(shell) phi_new, theta_new = hp.pix2ang(Nside, ind, lonlat=True) src_az, src_za = np.radians(phi - phi_new), np.radians(theta-theta_new) src_l = np.sin(src_az) * np.sin(src_za) src_m = np.cos(src_az) * np.sin(src_za) src_n = np.cos(src_za) u, v, w = bl.get_uvw(freqs[0]) vis_analytic = (1) * np.exp(2j * np.pi * (u*src_l + v*src_m + w*src_n)) print(vis_analytic) print(vis_calc) nt.assert_true(np.isclose(vis_analytic, vis_calc, atol=1e-3))
inds = time_arr xind, yind = np.meshgrid(inds, inds) diff_inds = xind-yind means, bins, binnums = binned_statistic(diff_inds.flatten(), np.real(cov).flatten(), bins=Nbins) lag_bins = ((bins[1:] + bins[:-1])/2.) #pl.plot(bins[1:], means) return means, lag_bins # Observatory latitude = -30.7215277777 longitude = 21.4283055554 fov = 180 #Deg ant1_enu = np.array([0, 0, 0]) ant2_enu = np.array([0.0, 14.6, 0]) bl = visibility.baseline(ant1_enu, ant2_enu) # Time #Ntimes = 500 #t0 = 2451545.0 #Start at J2000 epoch #dt_min_short = 30.0/60. #dt_min_long = 10.0 #dt_days_short = dt_min_short * 1/60. * 1/24. #dt_days_long = dt_min_long * 1/60. * 1/24. #time_arr_short = np.arange(Ntimes) * dt_days_short + t0 #time_arr_long = np.arange(Ntimes) * dt_days_long + t0 # #time_arr = time_arr_short t0 = 2451545.0 #Start at J2000 epoch #Ntimes = 7854 # 24 hours in 11 sec chunks
antnums = sel['antenna_nums'] if isinstance(antnums, str): antnums = eval(sel['antenna_nums']) if isinstance(antnums, int): antnums = [antnums] bls = [(a1, a2) for (a1, a2) in bls if a1 in antnums or a2 in antnums] uv_obj.antenna_nums = antnums if 'redundancy' in sel: red_tol = sel['redundancy'] reds, vec_bin_centers, lengths = uvutils.get_antenna_redundancies(anums, enu, tol=red_tol, include_autos=False) bls = [r[0] for r in reds] bls = [uvutils.baseline_to_antnums(bl_ind, Nants) for bl_ind in bls] uv_obj.Nants_data = np.unique(bls).size for (a1, a2) in bls: i1, i2 = np.where(anums == a1), np.where(anums == a2) array.append(visibility.baseline(enu[i1], enu[i2])) bl_array.append(uvutils.antnums_to_baseline(a1, a2, Nants)) Nbls = len(bl_array) uv_obj.Nbls = Nbls uv_obj.Nblts = Nbls * Ntimes bl_array = np.array(bl_array) freqs = freq_dict['freq_array'][0] #Hz obs = visibility.observatory(np.degrees(lat), np.degrees(lon), array=array, freqs=freqs) obs.set_fov(fov) print("Observatory built.") print("Nbls: ", Nbls) print("Ntimes: ", Ntimes) sys.stdout.flush()
diff_inds = xind - yind means, bins, binnums = binned_statistic(diff_inds.flatten(), np.real(cov).flatten(), bins=Nbins) lag_bins = ((bins[1:] + bins[:-1]) / 2.) #pl.plot(bins[1:], means) return means, lag_bins # Observatory latitude = -30.7215277777 longitude = 21.4283055554 fov = 45 #Deg ant1_enu = np.array([0, 0, 0]) ant2_enu = np.array([0.0, 14.6, 0]) bl = visibility.baseline(ant1_enu, ant2_enu) lengths = [14.6, 50.0, 100.0] bls = [] for l in lengths: ant2_enu = np.array([0.0, l, 0.0]) bls.append(visibility.baseline(ant1_enu, ant2_enu)) # Time Ntimes = 500 t0 = 2451545.0 #Start at J2000 epoch dt_min_short = 30.0 / 60. dt_min_long = 10.0 dt_days_short = dt_min_short * 1 / 60. * 1 / 24. dt_days_long = dt_min_long * 1 / 60. * 1 / 24. time_arr_short = np.arange(Ntimes) * dt_days_short + t0