コード例 #1
0
ファイル: tests.py プロジェクト: 2baOrNot2ba/AntPat
def passrotPat():
    """Test passive rotation of a pattern. There are two sub-requests possible
    and two input configs: full 3D output of 2D-cuts with input, single-pol
    pattern or dual-pol.
    """
    def doTrack():
        #(thetas, phis) = pntsonsphere.cut_az(0.*math.pi/2) #Good for some tests.
        (thetas, phis) = pntsonsphere.cut_theta(10.0/180*math.pi)
        try:
            E_ths, E_phs = ant.getFFalong(1.0, (thetas, phis))
            tvecfun.plotAntPat2D(thetas, E_ths, E_phs, freq=0.5)
        except:
            freq=30e6
            jones = ant.getJonesAlong([freq], (thetas, phis))
            j00=jones[...,0,0].squeeze()
            j01=jones[...,0,1].squeeze()
            tvecfun.plotAntPat2D(phis, j00, j01, freq)
            j10=jones[...,1,0].squeeze()
            j11=jones[...,1,1].squeeze()
            tvecfun.plotAntPat2D(phis, j10, j11, freq)

    def do3D():
        cutphis = numpy.arange(0, 2*math.pi, .2)
        nrLngs = len(cutphis)
        dims = (100, nrLngs)
        THETA = numpy.zeros(dims)
        PHI  = numpy.zeros(dims)
        E_TH = numpy.zeros(dims, dtype=complex)
        E_PH = numpy.zeros(dims, dtype=complex)
        for (cutNr, cutphi) in enumerate(cutphis):
            (thetas, phis) = pntsonsphere.cut_theta(cutphi)
            E_ths, E_phs = ant.getFFalong(0.0, (thetas, phis))
            THETA[:,cutNr] = thetas
            PHI[:,cutNr] = phis
            E_TH[:,cutNr] = E_ths
            E_PH[:,cutNr] = E_phs
        tvecfun.plotvfonsph(THETA, PHI, E_TH, E_PH, projection='equirectangular')

    #Get a simple linear dipole along y.
    singpol = True
    if singpol:
        ant = gen_simp_RadFarField()
        #ant = antpat.theoreticalantennas.max_gain_pat(4)[0]
    else:
        dpath=dreambeam.__path__[0]+'/telescopes/LOFAR/data/'
        ha = HamakerPolarimeter(pickle.load(open(dpath+'HA_LOFAR_elresp_LBA.p', 'rb')))
        ant = DualPolElem(ha)

    rotang = 1.*math.pi/4.
    rotmat = pntsonsphere.rot3Dmat(0.0, 0.0*math.pi/2, 0.1*math.pi/2)
    #Rotate the antenna 90 deg.
    print(rotmat)
    ant.rotateframe(rotmat)
    #Choose between next 2 lines:
    #doTrack()
    do3D()
コード例 #2
0
ファイル: viewJonespat.py プロジェクト: 2baOrNot2ba/AntPat
def plotJones_fromFEKOfiles(p_chan_file, q_chan_file, freq):
    (tvf_p, tvf_q) = (TVecFields(), TVecFields())
    tvf_p.load_ffe(p_chan_file)
    tvf_q.load_ffe(q_chan_file)
    (ant_p, ant_q) = (RadFarField(tvf_p), RadFarField(tvf_q))
    (p_chan_name, q_chan_name) = (os.path.basename(p_chan_file), os.path.basename(q_chan_file))
    (ant_p.name, ant_q.name) = (p_chan_name, q_chan_name)
    dualpolAnt = DualPolElem(ant_p, ant_q)
    dualpolAnt.plotJonesPat3D(freq, vcoord='circ',
                              projection='azimuthal-equidistant',
                              cmplx_rep='ReIm')
コード例 #3
0
def plotJones_fromFEKOfiles(p_chan_file, q_chan_file, freq):
    (tvf_p, tvf_q) = (TVecFields(), TVecFields())
    tvf_p.load_ffe(p_chan_file)
    tvf_q.load_ffe(q_chan_file)
    (ant_p, ant_q) = (RadFarField(tvf_p), RadFarField(tvf_q))
    (p_chan_name, q_chan_name) = (os.path.basename(p_chan_file),
                                  os.path.basename(q_chan_file))
    (ant_p.name, ant_q.name) = (p_chan_name, q_chan_name)
    dualpolAnt = DualPolElem(ant_p, ant_q)
    dualpolAnt.plotJonesPat3D(freq,
                              vcoord='circ',
                              projection='azimuthal-equidistant',
                              cmplx_rep='ReIm')
コード例 #4
0
ファイル: tests.py プロジェクト: 2baOrNot2ba/AntPat
def dualpolelem_2FF():
    """Test plot of a dual-polarized antenna where one channel is given
    by Psi and the other is a rotated copy it."""
    T, P = pntsonsphere.sphericalGrid()
    dipX = numpy.array(vsh.Psi(1, 1, T, P))+numpy.array(vsh.Psi(1, -1, T, P))
    dipXT = numpy.squeeze(dipX[0,:,:])
    dipXP = numpy.squeeze(dipX[1,:,:])
    freq = 1.0
    vfdipX = tvecfun.TVecFields(T, P, dipXT, dipXP, freq)
    antp = RadFarField(vfdipX)
    antq = antp.rotate90()
    dualpolAnt = DualPolElem(antp, antq)
    rotmat = pntsonsphere.rotzmat(0*math.pi/4)
    dualpolAnt.rotateframe(rotmat)
    dualpolAnt.plotJonesPat3D(freq, projection='azimuthal-equidistant', cmplx_rep='ReIm', )
コード例 #5
0
def convHA2DPE(inp_HA_file, out_DP_file):
    """Convert a file with a pickled dict of a Hamaker-Arts instance to a
    file with a pickled DualPolElem object."""
    artsdata = pickle.load(open(inp_HA_file, 'rb'))
    HLBA = HamakerPolarimeter(artsdata)
    stnDPolel = DualPolElem(HLBA)
    pickle.dump(stnDPolel, open(out_DP_file, 'wb'), PICKLE_PROTO)
コード例 #6
0
ファイル: viewStokespat.py プロジェクト: David-McKenna/AntPat
def plotStokes_fromFEKOfiles(p_chan_file, q_chan_file, freq):
    (tvf_p, tvf_q) = (TVecFields(), TVecFields())
    tvf_p.load_ffe(p_chan_file)
    tvf_q.load_ffe(q_chan_file)
    (ant_p, ant_q) = (RadFarField(tvf_p), RadFarField(tvf_q))
    (p_chan_name, q_chan_name) = (os.path.basename(p_chan_file),
                                  os.path.basename(q_chan_file))
    (ant_p.name, ant_q.name) = (p_chan_name, q_chan_name)
    dualpolAnt = DualPolElem(ant_p, ant_q)
    THETA, PHI, Jones = dualpolAnt.getJonesPat(freq)
    (StokesI, StokesQ, StokesU, StokesV) = Jones2Stokes(Jones)

    x = THETA * numpy.cos(PHI)
    y = THETA * numpy.sin(PHI)
    #x= THETA
    #y=PHI
    xyNames = ('theta*cos(phi)', 'theta*sin(phi)')
    fig = plt.figure()
    ax1 = fig.add_subplot(221)
    plt.pcolormesh(x, y, 10 * numpy.log10(StokesI), label="I")
    #plt.pcolormesh(x, y, StokesI, label="I")
    plt.colorbar()
    ax1.set_title('I (dB)')

    ax2 = fig.add_subplot(222)
    plt.pcolormesh(x, y, StokesQ / StokesI, label="Q")
    plt.colorbar()
    ax2.set_title('Q/I')

    ax3 = fig.add_subplot(223)
    plt.pcolormesh(x, y, StokesU / StokesI, label="U")
    plt.colorbar()
    ax3.set_title('U/I')

    ax4 = fig.add_subplot(224)
    plt.pcolormesh(x, y, StokesV / StokesI, label="V")
    plt.colorbar()
    ax4.set_title('V/I')
    fig.suptitle('Stokes (azimuthal-equidistant proj) @ ' + str(freq / 1e9) +
                 ' GHz')
    plt.show()
コード例 #7
0
ファイル: tests.py プロジェクト: LordHui/AntPat
def dualpolelem_2FF():
    """Test plot of a dual-polarized antenna where one channel is given
    by Psi and the other is a rotated copy it."""
    T, P = pntsonsphere.sphericalGrid()
    dipX = numpy.array(vsh.Psi(1, 1, T, P)) + numpy.array(vsh.Psi(1, -1, T, P))
    dipXT = numpy.squeeze(dipX[0, :, :])
    dipXP = numpy.squeeze(dipX[1, :, :])
    freq = 1.0
    vfdipX = tvecfun.TVecFields(T, P, dipXT, dipXP, freq)
    antp = RadFarField(vfdipX)
    antq = antp.rotate90()
    dualpolAnt = DualPolElem(antp, antq)
    rotmat = pntsonsphere.rotzmat(0 * math.pi / 4)
    dualpolAnt.rotateframe(rotmat)
    dualpolAnt.plotJonesPat3D(
        freq,
        projection='azimuthal-equidistant',
        cmplx_rep='ReIm',
    )
コード例 #8
0
    plt.pcolormesh(phi, numpy.rad2deg(theta), 10*numpy.log10(IXR))
    plt.colorbar()
    plt.title('IXR_J')
    plt.show()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("freq", type=float,
                        help="Frequency in Hertz")
    parser.add_argument("filename",
                 help='Filename of dual-polarization FF, Hamaker-Arts format, or a single-polarization FF (p-channel)')
    parser.add_argument("filename_q", nargs='?',
                 help='Filename of second (q-channel) single-polarization FF.')
    args = parser.parse_args()
    
    if args.filename.endswith(antfiles.HamArtsuffix):
        artsdata = read_LOFAR_HAcc(args.filename)
        artsdata['channels'] = [args.freq]
        hp = hamaker.HamakerPolarimeter(artsdata)
    elif args.filename.endswith(antfiles.FEKOsuffix):
        hp = DualPolElem()
        hp.load_ffes(args.filename, args.filename_q)
    else:
        print("dual-pol pattern file type not known")
        exit(1)
    THETA, PHI = ZenHemisphGrid()
    jones=hp.getJonesAlong([args.freq], (THETA, PHI) )
    plotJonesCanonical(THETA, PHI, jones, os.path.basename(args.filename)
                       +' ('+str(args.freq/1e6)+' MHz)')
コード例 #9
0
ファイル: tests.py プロジェクト: LordHui/AntPat
def passrotPat():
    """Test passive rotation of a pattern. There are two sub-requests possible
    and two input configs: full 3D output of 2D-cuts with input, single-pol
    pattern or dual-pol.
    """
    def doTrack():
        #(thetas, phis) = pntsonsphere.cut_az(0.*math.pi/2) #Good for some tests.
        (thetas, phis) = pntsonsphere.cut_theta(10.0 / 180 * math.pi)
        if type(ant) is not DualPolElem:
            E_ths, E_phs = ant.getFFalong(1.0, (thetas, phis))
            tvecfun.plotAntPat2D(thetas, E_ths, E_phs, freq=0.5)
        else:
            freq = 30e6
            jones = ant.getJonesAlong([freq], (thetas, phis))
            j00 = jones[..., 0, 0].squeeze()
            j01 = jones[..., 0, 1].squeeze()
            tvecfun.plotAntPat2D(phis, j00, j01, freq)
            j10 = jones[..., 1, 0].squeeze()
            j11 = jones[..., 1, 1].squeeze()
            tvecfun.plotAntPat2D(phis, j10, j11, freq)

    def do3D():
        cutphis = numpy.arange(0, 2 * math.pi, .2)
        nrLngs = len(cutphis)
        dims = (100, nrLngs)
        THETA = numpy.zeros(dims)
        PHI = numpy.zeros(dims)
        E_TH = numpy.zeros(dims, dtype=complex)
        E_PH = numpy.zeros(dims, dtype=complex)
        for (cutNr, cutphi) in enumerate(cutphis):
            (thetas, phis) = pntsonsphere.cut_theta(cutphi)
            if type(ant) is DualPolElem:
                freq = 30e6
                jones = ant.getJonesAlong([freq], (thetas, phis))
                j00 = jones[..., 0, 0].squeeze()
                j01 = jones[..., 0, 1].squeeze()
                j10 = jones[..., 1, 0].squeeze()
                j11 = jones[..., 1, 1].squeeze()
                # select y antenna
                E_ths = j10
                E_phs = j11
                vfname = 'Hamaker-Arts'
            else:
                freq = 0.0
                E_ths, E_phs = ant.getFFalong(freq, (thetas, phis))
                vfname = 'E-dipole y-directed'
            THETA[:, cutNr] = thetas
            PHI[:, cutNr] = phis
            E_TH[:, cutNr] = E_ths
            E_PH[:, cutNr] = E_phs
        tvecfun.plotvfonsph(THETA,
                            PHI,
                            E_TH,
                            E_PH,
                            freq=freq,
                            projection='equirectangular',
                            vfname=vfname)

    # Get a simple linear dipole along y.
    singpol = False
    if singpol:
        ant = gen_simp_RadFarField()
        # ant = antpat.theoreticalantennas.max_gain_pat(4)[0]
    else:
        dpath = dreambeam.__path__[0] + '/telescopes/LOFAR/data/'
        ha = HamakerPolarimeter(
            pickle.load(open(dpath + 'HA_LOFAR_elresp_LBA.p', 'rb')))
        ant = DualPolElem(ha)

    rotang = 1. * math.pi / 4.
    rotmat = pntsonsphere.rot3Dmat(0.0, 0.0 * math.pi / 2, 1.5 * math.pi / 2)
    # Rotate the antenna 90 deg.
    print(rotmat)
    ant.rotateframe(rotmat)
    # Choose between next 2 lines:
    # doTrack()
    do3D()
コード例 #10
0
ファイル: viewJonespat_dual.py プロジェクト: LordHui/AntPat
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("freq", type=float, help="Frequency in Hertz")
    parser.add_argument(
        "filename",
        help=
        'Filename of dual-polarization FF, Hamaker-Arts format, or a single-polarization FF (p-channel)'
    )
    parser.add_argument(
        "filename_q",
        nargs='?',
        help='Filename of second (q-channel) single-polarization FF.')
    args = parser.parse_args()

    if args.filename.endswith(antfiles.HamArtsuffix):
        artsdata = read_LOFAR_HAcc(args.filename)
        artsdata['channels'] = [args.freq]
        hp = hamaker.HamakerPolarimeter(artsdata)
    elif args.filename.endswith(antfiles.FEKOsuffix):
        hp = DualPolElem()
        hp.load_ffes(args.filename, args.filename_q)
    else:
        print("dual-pol pattern file type not known")
        exit(1)
    THETA, PHI = ZenHemisphGrid()
    jones = hp.getJonesAlong([args.freq], (THETA, PHI))
    plotJonesCanonical(
        THETA, PHI, jones,
        os.path.basename(args.filename) + ' (' + str(args.freq / 1e6) +
        ' MHz)')