Пример #1
0
def calc_image_uvw(vis_fname="test.fits", image_centre=[ 1.4596748494230258, 0.38422453855292943], savez=True):
        print "will compute uvw"
        f=FREQ2
        h = pf.open(vis_fname)[1].header
        tau = h['TSAMP']
        toa = h['MJD']
	dispersion_measure = h['DM']
        print 'Have DM: ',dispersion_measure
        antennas = h['ANTENNAS'].split('-')
        tp=np.loadtxt('/home/user/IMAGING_FULL/antpos_ITRF.txt')
        nants = len(antennas)
        blen=np.zeros((nants*(nants-1)/2,3),dtype=np.float32)

        u=np.zeros((NF2,nants*(nants-1)/2))
        v=np.zeros((NF2,nants*(nants-1)/2))
        w=np.zeros((NF2,nants*(nants-1)/2))
        wcorr=np.zeros((NF2,nants*(nants-1)/2))	# This is the w correction for rotation of the phase centre

        iiter=0
        for i in range(nants-1):
                for j in range(i+1,nants):
                        a1=int(antennas[i])-1; a2=int(antennas[j])-1;
                        blen[iiter,:]=np.array(tp[a1,1:]-tp[a2,1:])
                        iiter+=1

        delays = dm_delay(f,dm=dispersion_measure)
        t_mjd = toa + delays/SinD		# SinD is seconds in a day defined in const.py
						# t_mjd has the arrival time of pulses in each channel
        print "TOA = "+str(toa)
        print "Max disp delay = "+str(np.max(delays))

        qa = casautil.tools.quanta()
        me = casautil.tools.measures()
        #me.doframe(me.observatory('DSA-10'))            # Observatory (will look for entry in casacore measures:directory (see ~/.casarc)
        me.doframe(me.observatory('OVRO_MMA'))            # Observatory (will look for entry in casacore measures:directory (see ~/.casarc)
        me.doframe(me.epoch('utc',qa.quantity(REF_EPOCH,'d')))
        b=me.direction('HADEC', qa.quantity(0.0,'rad'),qa.quantity(POINTING,'rad'))
        azel=me.measure(b,'AZEL')
        me.doframe(me.epoch('utc',qa.quantity(toa,'d')))
        radec=me.measure(azel,'J2000')
        lst=radec['m0']['value']
        dec=radec['m1']['value']
        
        lam=C/f
        for i in range(nants*(nants-1)/2):
                tp4,tp5,tp6=fast_calc_uvw(blen[i,:],t_mjd,pointing=POINTING,src=[lst,dec])
                tp1,tp2,tp3=fast_calc_uvw(blen[i,:],t_mjd,pointing=POINTING,src=[image_centre[0],image_centre[1]])
                u[:,i]=tp1/lam
                v[:,i]=tp2/lam
                w[:,i]=tp3/lam
                wcorr[:,i]=(tp3-tp6)/lam

	#if savez:
	#uv_fname = "%s_uvw.npz"%vis_fname[:-4]
	#np.savez("test_withCasa.npz",u=u,v=v,w=w,wcorr=wcorr,f=f,t_mjd=t_mjd)

        
	return u,v,w,wcorr
Пример #2
0
def calc_image_uvw(vis_fname="output.npz",
                   image_centre=[0., 0.],
                   savez=True,
                   act_image_centre=None):
    print "will compute uvw"
    f = FREQ1
    h = np.load(vis_fname)
    tau = h['TSAMP']
    toa = h['MJD']
    antennas = str(h['ANTENNAS']).split('-')
    tp = np.loadtxt('/home/user/IMAGING_FULL/antpos_ITRF.txt')
    nants = len(antennas)
    blen = np.zeros((nants * (nants - 1) / 2, 3), dtype=np.float32)

    u = np.zeros((len(toa), NF1, nants * (nants - 1) / 2))
    v = np.zeros((len(toa), NF1, nants * (nants - 1) / 2))
    w = np.zeros((len(toa), NF1, nants * (nants - 1) / 2))
    wcorr = np.zeros(
        (len(toa), NF1, nants * (nants - 1) /
         2))  # This is the w correction for rotation of the phase centre

    iiter = 0
    for i in range(nants - 1):
        for j in range(i + 1, nants):
            a1 = int(antennas[i]) - 1
            a2 = int(antennas[j]) - 1
            blen[iiter, :] = np.array(tp[a1, 1:] - tp[a2, 1:])
            iiter += 1

    t_mjd = toa  # has shape of time-samples

    # do uvw calculation
    lam = C / f
    for i in range(nants * (nants - 1) / 2):

        if act_image_centre is not None:
            tp4, tp5, tp6 = fast_calc_uvw(
                blen[i, :],
                t_mjd,
                pointing=POINTING,
                src=[act_image_centre[0], act_image_centre[1]])
        else:
            tp4, tp5, tp6 = fast_calc_uvw(blen[i, :], t_mjd, pointing=POINTING)

        tp1, tp2, tp3 = fast_calc_uvw(blen[i, :],
                                      t_mjd,
                                      pointing=POINTING,
                                      src=[image_centre[0], image_centre[1]])

        for j in range(len(toa)):
            u[j, :, i] = tp1[j] / lam
            v[j, :, i] = tp2[j] / lam
            w[j, :, i] = tp3[j] / lam
            wcorr[j, :, i] = (tp3[j] - tp6[j]) / lam

    return u, v, w, wcorr
Пример #3
0
def calc_image_uvw(vis_fname="test.fits",
                   image_centre=[1.4596748494230258, 0.38422453855292943],
                   savez=True):
    print "will compute uvw"
    f = FREQ2
    h = pf.open(vis_fname)[1].header
    tau = h['TSAMP']
    toa = h['MJD']
    dispersion_measure = h['DM']
    print 'Have DM: ', dispersion_measure
    antennas = h['ANTENNAS'].split('-')
    tp = np.loadtxt('/home/user/IMAGING_FULL/antpos_ITRF.txt')
    nants = len(antennas)
    blen = np.zeros((nants * (nants - 1) / 2, 3), dtype=np.float32)

    u = np.zeros((NF2, nants * (nants - 1) / 2))
    v = np.zeros((NF2, nants * (nants - 1) / 2))
    w = np.zeros((NF2, nants * (nants - 1) / 2))
    wcorr = np.zeros(
        (NF2, nants * (nants - 1) /
         2))  # This is the w correction for rotation of the phase centre

    iiter = 0
    for i in range(nants - 1):
        for j in range(i + 1, nants):
            a1 = int(antennas[i]) - 1
            a2 = int(antennas[j]) - 1
            blen[iiter, :] = np.array(tp[a1, 1:] - tp[a2, 1:])
            iiter += 1

    delays = dm_delay(f, dm=dispersion_measure)
    t_mjd = toa + delays / SinD  # SinD is seconds in a day defined in const.py
    # t_mjd has the arrival time of pulses in each channel
    print "TOA = " + str(toa)
    print "Max disp delay = " + str(np.max(delays))

    lam = C / f
    for i in range(nants * (nants - 1) / 2):
        tp4, tp5, tp6 = fast_calc_uvw(blen[i, :], t_mjd, pointing=POINTING)
        tp1, tp2, tp3 = fast_calc_uvw(blen[i, :],
                                      t_mjd,
                                      pointing=POINTING,
                                      src=[image_centre[0], image_centre[1]])
        u[:, i] = tp1 / lam
        v[:, i] = tp2 / lam
        w[:, i] = tp3 / lam
        wcorr[:, i] = (tp3 - tp6) / lam

    return u, v, w, wcorr