示例#1
0
    def setUp(self):
        self.test_dir = os.path.dirname(os.path.realpath(__file__)) + '/'
        self.blmequ = sv.read_real_alm(self.test_dir + 'blm5.bin')
        self.blmax = 5
        self.freq = 150. / 300. * 299.792458  #my correct answers are computed with c=300,so im rescaing freq here to compensate
        self.zenithequ = sv.ctos(
            np.fromfile(self.test_dir + 'zenith.bin', dtype='float32'))[1:]
        self.zenithequ[0] = np.pi / 2 - self.zenithequ[0]
        self.zenithequ = np.array(self.zenithequ)[::-1]
        self.blvequ = np.fromfile(self.test_dir + 'blv.bin', dtype='float32')
        self.correct_BB = sv.read_alm(self.test_dir + 'BB47.bin')
        self.correct_cm = np.fromfile(self.test_dir + 'cm47.bin',
                                      dtype='complex64')
        self.correct_result = np.fromfile(
            self.test_dir + 'final47.bin', dtype='complex64'
        )  # * (len(self.correct_cm))**0.5 #correct result did not use correct normalization n**0.5 in fourier
        self.nside = 16
        healpix = np.zeros(12 * self.nside**2)
        healpix[420] = 1
        healpix[752] = 1
        self.alm = sv.convert_healpy_alm(hp.sphtfunc.map2alm(healpix),
                                         3 * self.nside - 1)

        self.vs = sv.Visibility_Simulator()
        self.vs.initial_zenith = self.zenithequ
        self.vs.Blm = sv.expand_real_alm(self.blmequ)
示例#2
0
    def test_speed(self):
        self.test_dir = os.path.dirname(os.path.realpath(__file__)) + '/'
        self.blmequ = sv.read_real_alm(self.test_dir + 'bx125.195.bin')
        self.blmax = 5
        self.freq = 125.195#my correct answers are computed with c=300,so im rescaing freq here to compensate
        self.zenithequ = sv.ctos(np.fromfile(self.test_dir + 'zenith.bin', dtype = 'float32'))[1:]
        self.zenithequ[0] = np.pi/2 - self.zenithequ[0]
        self.zenithequ = np.array(self.zenithequ)[::-1]
        self.correct_result = np.loadtxt(self.test_dir + 'Revised_Location_Visibilties_for_21_m_south_21_m_east_0_m_up_xx_pol_125.195_MHz.dat')
        self.correct_result = self.correct_result[:-1, 1] + 1j * self.correct_result[:-1, 2]
        self.nside = 128

        self.vs = sv.Visibility_Simulator()
        self.vs.initial_zenith = self.zenithequ
        self.vs.Blm = sv.expand_real_alm(self.blmequ)
        self.rot = np.fromfile(self.test_dir + 'x5rot.bin', dtype = 'float32').reshape((3,3))

        nside = self.nside
        print "Reading fits...",
        sys.stdout.flush()
        pca1 = hp.fitsfunc.read_map(self.test_dir + '/../data/gsm1.fits' + str(nside))
        pca2 = hp.fitsfunc.read_map(self.test_dir + '/../data/gsm2.fits' + str(nside))
        pca3 = hp.fitsfunc.read_map(self.test_dir + '/../data/gsm3.fits' + str(nside))
        gsm = 422.952*(0.307706*pca1+-0.281772*pca2+0.0123976*pca3)
        print "Done reading"
        sys.stdout.flush()
        equatorial_GSM = np.zeros(12*nside**2,'float')

        #rotate sky map
        print "Rotating map...",
        sys.stdout.flush()
        for i in range(12*nside**2):
            ang = hp.rotator.Rotator(coord='cg')(hpf.pix2ang(nside,i))
            pixindex, weight = hpf.get_neighbours(nside,ang[0],ang[1])
            for pix in range(len(pixindex)):
                equatorial_GSM[i] += weight[pix]*gsm[pixindex[pix]]
        print "Done rotating"
        sys.stdout.flush()

        print "Creating map alm...",
        sys.stdout.flush()
        self.alm = sv.convert_healpy_alm(hp.sphtfunc.map2alm(equatorial_GSM), 3 * nside - 1)
        print "Done alm"
        sys.stdout.flush()

        print "Computing visibilities...",
        sys.stdout.flush()
        timer = time.time()
        self.result = self.vs.calculate_visibility(sv.expand_real_alm(self.alm), d=self.rot.dot(np.array([21.0,21.0,0.0])), freq=self.freq, nt=len(self.correct_result), L = 3*self.nside-1, verbose = True)
        print "done", (time.time() - timer)/60, 'min'
        sys.stdout.flush()
        #print len(self.result), np.argmax(np.real(self.result)) - np.argmax(np.real(self.correct_result)), np.argmax(np.imag(self.result)) - np.argmax(np.imag(self.correct_result))
        plt.plot(np.real(self.result), 'r--', np.real(self.correct_result), 'b--')
        plt.show()
        plt.plot(np.imag(self.result), 'r--', np.imag(self.correct_result), 'b--')
        plt.show()
示例#3
0
    def setUp(self):
        self.test_dir = os.path.dirname(os.path.realpath(__file__)) + '/'
        self.blmequ = sv.read_real_alm(self.test_dir + 'bx125.195.bin')
        self.blmax = 23
        self.pol = 'xx'
        beam_healpixs = {}
        self.freq = 158.008  #my correct answers are computed with c=300,so im rescaing freq here to compensate
        self.zenithequ = sv.ctos(
            np.fromfile(self.test_dir + 'zenith.bin', dtype='float32'))[1:]
        self.zenithequ[0] = np.pi / 2 - self.zenithequ[0]
        self.zenithequ = np.array(self.zenithequ)[::-1]
        self.rot = np.fromfile(self.test_dir + 'x5rot.bin',
                               dtype='float32').reshape(
                                   (3, 3))  #fine tune rotation for ant array
        self.correct_result = np.loadtxt(
            self.test_dir +
            'Revised_Location_Visibilties_for_15_m_south_21_m_east_0_m_up_xx_pol_158.008_MHz.dat'
        )
        self.correct_result = self.correct_result[:-1,
                                                  1] + 1j * self.correct_result[:
                                                                                -1,
                                                                                2]

        self.vs = sv.Visibility_Simulator()
        self.vs.initial_zenith = np.array([0, 45.2977 * np.pi / 180
                                           ])  #self.zenithequ

        for f in range(110, 200, 10):
            beam_healpixs[f] = np.fromfile(
                self.test_dir +
                '../data/MWA_beam_in_healpix_horizontal_coor/nside=%i_freq=%i_%s.bin'
                % ((self.blmax + 1) / 3, f, self.pol),
                dtype='float32')
        freqa = int(np.floor(self.freq / 10.) * 10)
        freqb = freqa + 10
        beam_healpix = beam_healpixs[freqa] + (self.freq - freqa) * (
            beam_healpixs[freqb] - beam_healpixs[freqa]) / (
                freqb - freqa)  #linear interpolation
        self.vs.import_beam(beam_healpix)
示例#4
0
tlist = np.arange(16, 24, .1)

infofile = '/home/omniscope/omnical/doc/redundantinfo_X5_q3y.bin'  #'/home/omniscope/omnical/doc/redundantinfo_PSA128_26ba_6bu_08-15-2014.bin'#
pol = 'yy'
info = omni.read_redundantinfo(infofile)

nside = 8
nside_target = 4
inclusion_thresh = 1  #betweennnn 0 and 1. ubl/lambda must be this times nside_target less
all_ubl = False
bnside = 8

freq = 160.

vs = sv.Visibility_Simulator()
if 'X5' in infofile and 'PSA' in infofile:
    raise Exception('Cant tell if the iinfo is for PAPER or MITEoR')
elif 'X5' in infofile:
    lat_degree = 45.2977
    infoubl = info['ubl'].dot([[1.5, 0, 0], [0, 1.5, 0], [0, 0, 0]])
    beam_healpix = np.fromfile(
        '/home/omniscope/simulate_visibilities/data/MWA_beam_in_healpix_horizontal_coor/nside=%i_freq=%i_%s.bin'
        % (bnside, freq, pol),
        dtype='float32')
elif 'PSA' in infofile:
    lat_degree = -(30. + 43. / 60. + 17.5 / 3600.)
    infoubl = info['ubl'].dot([[4, 0, 0], [0, 15, 0], [0, 0, 0]])
    calfile = 'psa6240_v003'
    ######get array  information and accurate ubl vectors
    aa = ap.cal.get_aa(calfile, np.array([freq / 1000.]))