Esempio n. 1
0
def test_dtypes(uvdata, dtype, cdtype):
    I_sky = create_uniform_sky()

    sim = VisCPU(uvdata=uvdata,
                 sky_freqs=np.unique(uvdata.freq_array),
                 sky_intensity=I_sky,
                 real_dtype=dtype,
                 complex_dtype=cdtype)

    v = sim.simulate()
    assert v.dtype == cdtype
Esempio n. 2
0
def test_comparision_airy(uvdata2):
    freqs = np.unique(uvdata2.freq_array)
    nbase = 4
    nside = 2**nbase

    I_sky = create_uniform_sky(nbase=nbase)

    vec = healpy.ang2vec(np.pi / 2, 0)
    # Zero out values within pi/2 of (theta=pi/2, phi=0)
    ipix_disc = healpy.query_disc(nside=nside, vec=vec, radius=np.pi / 2)
    for i in range(len(freqs)):
        I_sky[i][ipix_disc] = 0

    viscpu = VisCPU(uvdata=uvdata2,
                    sky_freqs=freqs,
                    sky_intensity=I_sky,
                    beams=[AnalyticBeam("airy", diameter=1.75)],
                    nside=nside).simulate()

    healvis = HealVis(uvdata=uvdata2,
                      sky_freqs=freqs,
                      sky_intensity=I_sky,
                      beams=[AnalyticBeam("airy", diameter=1.75)],
                      nside=nside).simulate()

    assert viscpu.shape == healvis.shape
    np.testing.assert_allclose(viscpu, healvis, rtol=0.05)
Esempio n. 3
0
def test_comparison_multiple(uvdata2):
    freqs = np.unique(uvdata2.freq_array)

    # put a point source in
    point_source_pos = np.array(
        [[0, uvdata2.telescope_location_lat_lon_alt[0] + np.pi / 4],
         [0, uvdata2.telescope_location_lat_lon_alt[0]]])
    point_source_flux = np.array([[1.0, 1.0]] * len(freqs))

    # align to healpix center for direct comparision
    point_source_pos, point_source_flux = align_src_to_healpix(
        point_source_pos, point_source_flux)

    viscpu = VisCPU(uvdata=uvdata2,
                    sky_freqs=freqs,
                    point_source_flux=point_source_flux,
                    point_source_pos=point_source_pos,
                    nside=2**4).simulate()

    healvis = HealVis(uvdata=uvdata2,
                      sky_freqs=freqs,
                      point_source_flux=point_source_flux,
                      point_source_pos=point_source_pos,
                      nside=2**4).simulate()

    assert viscpu.shape == healvis.shape
    np.testing.assert_allclose(viscpu, healvis, rtol=0.05)
Esempio n. 4
0
def test_JD(uvdata, uvdataJD):
    freqs = np.unique(uvdata.freq_array)

    # put a point source in
    point_source_pos = np.array([[0,
                                  uvdata.telescope_location_lat_lon_alt[0]]])
    point_source_flux = np.array([[1.0]] * len(freqs))

    viscpu1 = VisCPU(uvdata=uvdata,
                     sky_freqs=np.unique(uvdata.freq_array),
                     point_source_flux=point_source_flux,
                     point_source_pos=point_source_pos,
                     nside=2**4).simulate()

    viscpu2 = VisCPU(uvdata=uvdataJD,
                     sky_freqs=np.unique(uvdataJD.freq_array),
                     point_source_flux=point_source_flux,
                     point_source_pos=point_source_pos,
                     nside=2**4).simulate()

    assert viscpu1.shape == viscpu2.shape
    assert not np.allclose(viscpu1, viscpu2, atol=0.1)
Esempio n. 5
0
                              **cfg_beam) for i in range(Nant)
        ]
    else:
        beam_list = [PolyBeam(**cfg_beam) for i in range(Nant)]

    # Use VisCPU to create point source sim, or load a template file with
    # correct data structures instead
    if cfg_spec['use_ptsrc']:

        # Create VisCPU visibility simulator object (MPI-enabled)
        simulator = VisCPU(
            uvdata=uvd,
            beams=beam_list,
            beam_ids=ant_index,
            sky_freqs=freqs,
            point_source_pos=ra_dec,
            point_source_flux=flux,
            precision=2,
            use_pixel_beams=False,  # Do not use pixel beams
            bm_pix=10,
            mpi_comm=comm)

        # Run simulation
        tstart = time.time()
        simulator.simulate()
        print("Simulation took %2.1f sec" % (time.time() - tstart))

        if myid != 0:
            # Wait for root worker to finish IO before ending all other worker procs
            comm.Barrier()
            sys.exit(0)