Ejemplo n.º 1
0
    def test_diffuse_foreground_orientation(self):
        fqs = np.linspace(.1, .2, 100, endpoint=False)
        omega_p = noise.bm_poly_to_omega_p(fqs)
        lsts = np.linspace(0, 2 * np.pi, 1000)
        Tsky_mdl = noise.HERA_Tsky_mdl['xx']

        bl_vec = (0, 30.0)
        vis = foregrounds.diffuse_foreground(lsts,
                                             fqs,
                                             bl_vec,
                                             Tsky_mdl=Tsky_mdl,
                                             fringe_filter_type='tophat',
                                             omega_p=omega_p)
        self.assertEqual(vis.shape, (lsts.size, fqs.size))

        # assert foregrounds show up at positive fringe-rates for FFT
        bl_vec = (100.0, 0.0)
        vis = foregrounds.diffuse_foreground(lsts,
                                             fqs,
                                             bl_vec,
                                             Tsky_mdl=Tsky_mdl,
                                             fringe_filter_type='gauss',
                                             fr_width=1e-5,
                                             omega_p=omega_p)
        dfft = np.fft.fftshift(np.fft.fft(
            vis * dspec.gen_window('blackmanharris', len(vis))[:, None],
            axis=0),
                               axes=0)
        frates = np.fft.fftshift(
            np.fft.fftfreq(len(lsts),
                           np.diff(lsts)[0] * 12 * 3600 / np.pi))
        max_frate = frates[np.argmax(np.abs(dfft[:, 0]))]
        nt.assert_true(max_frate > 0)

        bl_vec = (-100.0, 0.0)
        vis = foregrounds.diffuse_foreground(lsts,
                                             fqs,
                                             bl_vec,
                                             Tsky_mdl=Tsky_mdl,
                                             fringe_filter_type='gauss',
                                             fr_width=1e-5,
                                             omega_p=omega_p)
        dfft = np.fft.fftshift(np.fft.fft(
            vis * dspec.gen_window('blackmanharris', len(vis))[:, None],
            axis=0),
                               axes=0)
        max_frate = frates[np.argmax(np.abs(dfft[:, 0]))]
        nt.assert_true(max_frate < 0)
Ejemplo n.º 2
0
 def test_diffuse_foreground(self):
     fqs = np.linspace(.1, .2, 100, endpoint=False)
     lsts = np.linspace(0, 2 * np.pi, 1000)
     times = lsts / (2 * np.pi) * aipy.const.sidereal_day
     Tsky_mdl = noise.HERA_Tsky_mdl['xx']
     #Tsky = Tsky_mdl(lsts,fqs)
     bl_len_ns = 30.
     vis = foregrounds.diffuse_foreground(lsts,
                                          fqs, [bl_len_ns, 0, 0],
                                          Tsky_mdl=Tsky_mdl,
                                          delay_filter_type='tophat',
                                          fringe_filter_type='tophat')
     self.assertEqual(vis.shape, (lsts.size, fqs.size))
     # XXX check more substantial things
     #import uvtools, pylab as plt
     #uvtools.plot.waterfall(vis, mode='log'); plt.colorbar(); plt.show()
     nt.assert_raises(TypeError, foregrounds.diffuse_foreground, lsts, fqs,
                      [bl_len_ns])
Ejemplo n.º 3
0
    def setUp(self):
        # setup simulation parameters
        np.random.seed(0)
        fqs = np.linspace(0.1, 0.2, 100, endpoint=False)
        lsts = np.linspace(0, 2 * np.pi, 200)
        times = lsts / (2 * np.pi) * aipy.const.sidereal_day
        Tsky_mdl = noise.HERA_Tsky_mdl["xx"]
        Tsky = Tsky_mdl(lsts, fqs)
        bl_vec = np.array([50.0, 0, 0])
        # + 20 is to boost k=0 mode
        vis = foregrounds.diffuse_foreground(lsts, fqs, bl_vec, Tsky_mdl=Tsky_mdl, delay_filter_type='gauss') + 20

        self.freqs = fqs
        self.lsts = lsts
        self.Tsky = Tsky
        self.bl_vec = bl_vec
        self.vis = vis
        self.vfft = np.fft.fft(vis, axis=1)
        self.dlys = np.fft.fftfreq(len(fqs), d=np.median(np.diff(fqs)))
Ejemplo n.º 4
0
 def generate_diffuse_foreground(self):
     #GENERATE FOREGROUNDS
     return foregrounds.diffuse_foreground(
         self.lsts, self.fqs, self.bl_len_ns_list,
         Tsky_mdl=self.Tsky_mdl) / 40
Ejemplo n.º 5
0
    def gen_HERA_vis(self,
                     tsamples,
                     fsamples,
                     bl_len_ns=400.,
                     add_rfi=False,
                     inject_frb=False):
        #### Convert time samples to appropriate LST hours where 60 time samples = 10 min
        #### !!!! LST is in rads not hrs
        sph = 60. / .1667
        lst_add = tsamples / sph
        fqs = np.linspace(.1, .2, fsamples, endpoint=False)
        lsts = np.linspace(np.pi / 2., np.pi / 2. + lst_add, tsamples)
        times = lsts / (2. * np.pi) * a.const.sidereal_day

        #### FOREGROUNDS ####
        # Diffuse
        Tsky_mdl = noise.HERA_Tsky_mdl['xx']
        vis_fg_diffuse = foregrounds.diffuse_foreground(
            Tsky_mdl, lsts, fqs, bl_len_ns)
        # Point Sources
        vis_fg_pntsrc = foregrounds.pntsrc_foreground(lsts,
                                                      fqs,
                                                      bl_len_ns,
                                                      nsrcs=1000)
        # FRBs
        vis_fg_frb = np.asarray(gen_simulated_frb(NFREQ=1024,
                                                  NTIME=61,
                                                  width=1.,
                                                  sim=True,
                                                  delta_t=10.,
                                                  freq=(200, 100),
                                                  FREQ_REF=150.,
                                                  fluence=(60., 600.),
                                                  scintillate=True,
                                                  dm=(300., 1800.))[0].T,
                                dtype=np.complex128)
        vis_fg_frb *= np.exp(
            1j * (lsts[30] + .1 * np.pi * np.random.randn(61, 1024)))
        # Combined
        if inject_frb:
            vis_fg = vis_fg_diffuse + vis_fg_pntsrc + vis_fg_frb
        else:
            vis_fg = vis_fg_diffuse + vis_fg_pntsrc
        #### Noise ####
        tsky = noise.resample_Tsky(fqs,
                                   lsts,
                                   Tsky_mdl=noise.HERA_Tsky_mdl['xx'])
        t_rx = 150.
        nos_jy = noise.sky_noise_jy(tsky + t_rx, fqs, lsts)
        # Add Noise
        vis_fg_nos = vis_fg + nos_jy

        #### RFI ####
        if add_rfi:
            g = sigchain.gen_gains(fqs, [1, 2, 3])
            with open(add_rfi, 'r') as infile:
                RFIdict = yaml.load(infile)
            rfi = RFI_Sim(RFIdict)
            rfi.applyRFI()
            self.rfi_true = rfi.getFlags()
            vis_fg_nos_rfi = np.copy(vis_fg_nos) + rfi.getRFI()
            vis_total_rfi = sigchain.apply_gains(vis_fg_nos_rfi, g, (1, 2))
            # add cross-talk
            xtalk = sigchain.gen_xtalk(np.linspace(.1, .2, 1024),
                                       amplitude=.001)
            vis_total_rfi = sigchain.apply_xtalk(vis_total_rfi, xtalk)
            self.data_rfi = vis_total_rfi
        else:
            g = sigchain.gen_gains(fqs, [1, 2, 3])
            vis_total_norfi = sigchain.apply_gains(vis_fg_nos, g, (1, 2))
            self.data = vis_total_norfi
Ejemplo n.º 6
0
fp.create_dataset('lsts', data=lsts)

for a in ants:
    fp.create_dataset('g%d' % a, data=gains[a])

for bls in reds:
    for (i, j) in bls:
        data[(i, j)] = fp.create_dataset('%d-%d' % (i, j),
                                         (len(lsts), len(fqs)),
                                         chunks=True,
                                         dtype='complex64')

for bls in reds:
    bl_len = get_distance(bls[0], antpos)
    bl_len_ns = bl_len / aipy.const.c * 1e11
    vis_fg_pntsrc = foregrounds.pntsrc_foreground(lsts,
                                                  fqs,
                                                  bl_len_ns,
                                                  nsrcs=200)
    vis_fg_diffuse = foregrounds.diffuse_foreground(Tsky_mdl, lsts, fqs,
                                                    bl_len_ns)
    true_vis[bls[0]] = vis_fg_pntsrc + vis_fg_diffuse

    for (i, j) in bls:
        print(i, j)
        nos_jy = noise.sky_noise_jy(tsky + 150., fqs, lsts)
        vis_tot = nos_jy + true_vis[bls[0]]
        data[(i, j)][:, :] = sigchain.apply_gains(vis_tot, gains, (i, j))

fp.close()
 def generate_diffuse_foreground(self):
     return foregrounds.diffuse_foreground(
         lsts, fqs, self.bl_len_ns, Tsky_mdl=Tsky_mdl) / 40