コード例 #1
0
def phase_vs_freq(interface, fstart, fstop, fstep="1GHz"):
    """
    Plot polarization rotation phase vs frequency for a given interface.
    """
    sin_to_fit = lambda x, a, phase: a*np.sin(phase + 4*x)
    pol_in = StokesVector(1,1,0,0)
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    f_range = np.arange(fstart, fstop, fstep)
    divisor, frq_range = frange(fstart, fstop)

    radstep = unitize_a("1deg")
    angle_range = np.arange(0, pi/2, radstep)

    data = np.array(mpexec(rot_sweep_data, "freq", f_range,
        interface=interface, step="1deg", a_range=pi/2, pol_in=pol_in,
        globals=globals()))
    pol = []
    phase = []
    print "starting fit"
    for i, f in enumerate(f_range):
        # Get Q vs angle, indexed by frequency
        pol.append(data[i,1])
        phase_fit = curve_fit(sin_to_fit, angle_range, pol[i])
        phase.append(phase_fit[0][1])
    min_phase = min(phase)
    phase -= min_phase
    dphase = map(deg, phase)
    plt.plot(f_range/divisor, dphase)
    plt.xlabel("Frequency ({})".format(frq_range))
    plt.ylabel("Phase angle (deg)")
    plt.show()
コード例 #2
0
def mod_vs_freq(interface, fstart, fstop, fstep, astep="1deg"):
    """
    Calculates and plots the modulation efficiency vs frequency.
    """
    start_time = time.time()
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    f_vals = []
    efficiency = []
    divisor, frq_range = frange(fstart, fstop)
    contrived_data = contrived_ahwp_mod(
        np.arange(fstart,fstop,fstep),np.sqrt(9.26),np.sqrt(11.56),"3.6mm")
    for f in xrange(int((fstop-fstart)/fstep)):
        f_vals.append((f*fstep+fstart)/divisor)
        #I,Q,U,V=rot_sweep_data(interface, fstart+f*fstep, step=astep, a_range=pi/2)
        #efficiency.append(rms(np.sqrt(Q**2+U**2)))
    end_time = time.time()
    print "elapsed: {}s".format((end_time-start_time))
    #plt.plot(f_vals, efficiency, label="Modulation Efficiency")
    plt.plot(f_vals, contrived_data, label="Contrived AHWP")
    plt.xlabel("Frequency ("+frq_range+")")
    plt.ylabel("Modulation Efficiency")
    plt.ylim(ymin=0,ymax=1.1)
    plt.legend()
    plt.show()   
コード例 #3
0
def mod_vs_freq(interface, fstart, fstop, fstep, astep="1deg"):
    """
    Calculates and plots the modulation efficiency vs frequency.
    """
    start_time = time.time()
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    f_vals = []
    efficiency = []
    divisor, frq_range = frange(fstart, fstop)
    contrived_data = contrived_ahwp_mod(np.arange(fstart, fstop, fstep),
                                        np.sqrt(9.26), np.sqrt(11.56), "3.6mm")
    for f in xrange(int((fstop - fstart) / fstep)):
        f_vals.append((f * fstep + fstart) / divisor)
        #I,Q,U,V=rot_sweep_data(interface, fstart+f*fstep, step=astep, a_range=pi/2)
        #efficiency.append(rms(np.sqrt(Q**2+U**2)))
    end_time = time.time()
    print "elapsed: {}s".format((end_time - start_time))
    #plt.plot(f_vals, efficiency, label="Modulation Efficiency")
    plt.plot(f_vals, contrived_data, label="Contrived AHWP")
    plt.xlabel("Frequency (" + frq_range + ")")
    plt.ylabel("Modulation Efficiency")
    plt.ylim(ymin=0, ymax=1.1)
    plt.legend()
    plt.show()
コード例 #4
0
 def M(self, freq, layer_next=None):
     """
     Returns the matrix operator which acts on the Poynting vector,
     (Ex,Ey,Hx,Hy). We do this by first projecting into E space, acting
     the phase propogator, and then projection back into S.
     We combine the last two steps, and a change of basis, into the 
     second matrix, because it lends itself to a compact form.
     """
     Cx = sqrt(self.permitivity)/(c*mu_0)
     Cy = sqrt(self.permitivity2)/(c*mu_0)
     E_to_S = np.matrix([ #Eq3.84
         [ 1 , 0 , 1 , 0 ],
         [ 0 , 1 , 0 , 1 ],
         [ 0 ,-Cy, 0 ,Cy ],
         [Cx , 0 ,-Cx, 0 ]
         ])
     wavelength = c/unitize_f(freq)
     z = self.thickness
     if layer_next is not None:
         theta = layer_next.angle - self.angle
     else:
         theta = -self.angle
     phase_x = exp(2j*pi/wavelength*sqrt(self.permitivity)*z)
     phase_y = exp(2j*pi/wavelength*sqrt(self.permitivity2)*z)
     inv_x = exp(-2j*pi/wavelength*sqrt(self.permitivity)*z)
     inv_y = exp(-2j*pi/wavelength*sqrt(self.permitivity2)*z)
     phase = 0.5*np.matrix([ #Eq3.85
         [phase_x*cos(theta),phase_x*sin(theta),-phase_x*sin(theta)/Cx,phase_x*cos(theta)/Cx],
         [-phase_y*sin(theta),phase_y*cos(theta),-phase_y*cos(theta)/Cy,-phase_y*sin(theta)/Cy],
         [inv_x*cos(theta),inv_x*sin(theta),inv_x*sin(theta)/Cx,-inv_x*cos(theta)/Cx],
         [-inv_y*sin(theta),inv_y*cos(theta),inv_y*cos(theta)/Cy,inv_y*sin(theta)/Cy]
         ])
     return E_to_S*phase #Eq3.86
コード例 #5
0
def rot_sweep_data(interface, freq, step, a_range, pol_in):
    """
    Returns the I, Q, U and V over a rotation of 2pi.
    """
    I=np.array([])
    Q=np.array([])
    U=np.array([])
    V=np.array([])

    a_range=unitize_a(a_range)
    f = unitize_f(freq)
    interface.build(f)
    
    radstep = unitize_a(step)
    angle_range = np.arange(0, a_range, radstep)
    
    for angle in angle_range:
        # Rotating the input polarization rather than rebuilding the interface
        # at each rotation gives a factor of 2 improvement in performance.
        rot_pol = pol_in.rot(angle)
        pol_out = (interface*rot_pol).rot(-angle)
        I = np.append(I, pol_out.I)
        Q = np.append(Q, pol_out.Q)
        U = np.append(U, pol_out.U)
        V = np.append(V, pol_out.V)  
    
    return (I, Q, U, V)
コード例 #6
0
def rot_sweep_data(interface, freq, step, a_range, pol_in):
    """
    Returns the I, Q, U and V over a rotation of 2pi.
    """
    I = np.array([])
    Q = np.array([])
    U = np.array([])
    V = np.array([])

    a_range = unitize_a(a_range)
    f = unitize_f(freq)
    interface.build(f)

    radstep = unitize_a(step)
    angle_range = np.arange(0, a_range, radstep)

    for angle in angle_range:
        # Rotating the input polarization rather than rebuilding the interface
        # at each rotation gives a factor of 2 improvement in performance.
        rot_pol = pol_in.rot(angle)
        pol_out = (interface * rot_pol).rot(-angle)
        I = np.append(I, pol_out.I)
        Q = np.append(Q, pol_out.Q)
        U = np.append(U, pol_out.U)
        V = np.append(V, pol_out.V)

    return (I, Q, U, V)
コード例 #7
0
def contrived_cross_sweep(fstart, fstop, fstep, n1, n2, d):
    d = unitize_d(d)
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    divisor, frq_range = frange(fstart,fstop)
    arange = np.arange(0, pi/2, unitize_a("15deg"))
    f_range = np.arange(fstart, fstop, fstep)
    for angle in arange:
        angles = contrived_ahwp_cross(f_range, n1, n2, d, angle)
        label = "AHWP Angle: {0:.2f}".format(angle)
        plt.plot(f_range, angles, label=label)
    plt.xlabel("Frequency ("+frq_range+")")
    plt.ylabel("Polarization Angle")
    plt.ylim(ymin=0, ymax=pi)
    plt.legend()
    plt.show()
コード例 #8
0
def contrived_cross_sweep(fstart, fstop, fstep, n1, n2, d):
    d = unitize_d(d)
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    divisor, frq_range = frange(fstart, fstop)
    arange = np.arange(0, pi / 2, unitize_a("15deg"))
    f_range = np.arange(fstart, fstop, fstep)
    for angle in arange:
        angles = contrived_ahwp_cross(f_range, n1, n2, d, angle)
        label = "AHWP Angle: {0:.2f}".format(angle)
        plt.plot(f_range, angles, label=label)
    plt.xlabel("Frequency (" + frq_range + ")")
    plt.ylabel("Polarization Angle")
    plt.ylim(ymin=0, ymax=pi)
    plt.legend()
    plt.show()
コード例 #9
0
def get_data(interface, start, stop, step):
    """Get polarization transmittion data over a range of frequencies."""
    start = unitize_f(start)
    stop = unitize_f(stop)
    step = unitize_f(step)
    trans=[]
    xy_cross=[]
    yx_cross=[]
    unit = PolarizationVector(1)
    zero = PolarizationVector(0)
    vect_x = PolarizationTwoVector(unit,zero)
    vect_y = PolarizationTwoVector(zero,unit)
    for f in xrange(int((stop-start)/step)):
        interface.build(start+f*step)
        out_x = interface*vect_x
        trans.append(out_x.v_x.power)
        xy_cross.append(out_x.v_y.power)
    return (trans, xy_cross)
コード例 #10
0
def graph(interface, start="1ghz", stop="300ghz", step="0.1ghz"):
    """Show frequency spectrum of interface."""
    start = unitize_f(start)
    stop = unitize_f(stop)
    step = unitize_f(step)
    x_vals=[]
    # Choose a sane base for the plot
    divisor, frq_range = frange(start,stop)
    for x in xrange(int((stop-start)/step)):
        x_vals.append((x*step+start)/divisor)
    (trans, xy_cross)=get_data(interface, start, stop, step)
    plt.plot(x_vals, trans, label="Total transmission")
    plt.plot(x_vals, xy_cross, label="Cross polarization")
    plt.xlabel("Frequency ("+frq_range+")")
    plt.ylabel("Transmission Ratio")
    plt.ylim(ymax=1)
    plt.legend()
    plt.show()
コード例 #11
0
def get_data(interface, start, stop, step):
    """Get polarization transmittion data over a range of frequencies."""
    start = unitize_f(start)
    stop = unitize_f(stop)
    step = unitize_f(step)
    trans = []
    xy_cross = []
    yx_cross = []
    unit = PolarizationVector(1)
    zero = PolarizationVector(0)
    vect_x = PolarizationTwoVector(unit, zero)
    vect_y = PolarizationTwoVector(zero, unit)
    for f in xrange(int((stop - start) / step)):
        interface.build(start + f * step)
        out_x = interface * vect_x
        trans.append(out_x.v_x.power)
        xy_cross.append(out_x.v_y.power)
    return (trans, xy_cross)
コード例 #12
0
def graph(interface, start="1ghz", stop="300ghz", step="0.1ghz"):
    """Show frequency spectrum of interface."""
    start = unitize_f(start)
    stop = unitize_f(stop)
    step = unitize_f(step)
    x_vals = []
    # Choose a sane base for the plot
    divisor, frq_range = frange(start, stop)
    for x in xrange(int((stop - start) / step)):
        x_vals.append((x * step + start) / divisor)
    (trans, xy_cross) = get_data(interface, start, stop, step)
    plt.plot(x_vals, trans, label="Total transmission")
    plt.plot(x_vals, xy_cross, label="Cross polarization")
    plt.xlabel("Frequency (" + frq_range + ")")
    plt.ylabel("Transmission Ratio")
    plt.ylim(ymax=1)
    plt.legend()
    plt.show()
コード例 #13
0
def phase_vs_freq(interface, fstart, fstop, fstep="1GHz"):
    """
    Plot polarization rotation phase vs frequency for a given interface.
    """
    sin_to_fit = lambda x, a, phase: a * np.sin(phase + 4 * x)
    pol_in = StokesVector(1, 1, 0, 0)
    fstart = unitize_f(fstart)
    fstop = unitize_f(fstop)
    fstep = unitize_f(fstep)
    f_range = np.arange(fstart, fstop, fstep)
    divisor, frq_range = frange(fstart, fstop)

    radstep = unitize_a("1deg")
    angle_range = np.arange(0, pi / 2, radstep)

    data = np.array(
        mpexec(rot_sweep_data,
               "freq",
               f_range,
               interface=interface,
               step="1deg",
               a_range=pi / 2,
               pol_in=pol_in,
               globals=globals()))
    pol = []
    phase = []
    print "starting fit"
    for i, f in enumerate(f_range):
        # Get Q vs angle, indexed by frequency
        pol.append(data[i, 1])
        phase_fit = curve_fit(sin_to_fit, angle_range, pol[i])
        phase.append(phase_fit[0][1])
    min_phase = min(phase)
    phase -= min_phase
    dphase = map(deg, phase)
    plt.plot(f_range / divisor, dphase)
    plt.xlabel("Frequency ({})".format(frq_range))
    plt.ylabel("Phase angle (deg)")
    plt.show()
コード例 #14
0
from mp import mpexec

hwp_axis_1 = 11.56
hwp_axis_2 = 9.36
hwp = Layer(eps=hwp_axis_1, eps2=hwp_axis_2, thickness="3.6mm")
coating_2a = 2.32
coating_2b = 6.79
ar2a = Layer(coating_2a, "400um")
ar2b = Layer(coating_2b, "230um")
dual_band_ahwp = Interface(ar2a, ar2b, hwp, hwp("58deg"), hwp, ar2b, ar2a)

central_freq="150GHz"
c=300000000.0

base_thick=c/(4*unitize_f("150ghz"))
default_input = StokesVector(1, 1, 0, 0) # I=Q=1, U=V=0

rms = lambda arr: np.sqrt(np.mean(np.square(arr)))

def contrived_ahwp_mod(f_range,n1,n2,d):
    a_range = np.arange(0, pi/2, unitize_a("1deg"))
    d=unitize_d(d)
    center_angle = unitize_a("58deg")
    mods = []
    for f in f_range:
        mueller = mueller_wp((n2-n1)*2*pi*f*d/c)
        I = np.array([])
        Q = np.array([])
        for a in a_range:
            s = StokesVector(1,1,0,0)
コード例 #15
0
from mp import mpexec

hwp_axis_1 = 11.56
hwp_axis_2 = 9.36
hwp = Layer(eps=hwp_axis_1, eps2=hwp_axis_2, thickness="3.6mm")
coating_2a = 2.32
coating_2b = 6.79
ar2a = Layer(coating_2a, "400um")
ar2b = Layer(coating_2b, "230um")
dual_band_ahwp = Interface(ar2a, ar2b, hwp, hwp("58deg"), hwp, ar2b, ar2a)

central_freq = "150GHz"
c = 300000000.0

base_thick = c / (4 * unitize_f("150ghz"))
default_input = StokesVector(1, 1, 0, 0)  # I=Q=1, U=V=0

rms = lambda arr: np.sqrt(np.mean(np.square(arr)))


def contrived_ahwp_mod(f_range, n1, n2, d):
    a_range = np.arange(0, pi / 2, unitize_a("1deg"))
    d = unitize_d(d)
    center_angle = unitize_a("58deg")
    mods = []
    for f in f_range:
        mueller = mueller_wp((n2 - n1) * 2 * pi * f * d / c)
        I = np.array([])
        Q = np.array([])
        for a in a_range: