Exemplo n.º 1
0
def traceWSShell(num,theta,r0,z0,phigh,plow,shigh,slow,\
                 energy,rough,chaseFocus=False,bestFocus=False):
    """Trace a WS mirror pair with 10 m focal length and
    mirror axial cutoffs defined by phigh,plow
    """
    #Define annulus of source rays
    a,p,d,e = con.woltparam(r0,z0)
    r1 = PT.wsPrimRad(plow,1.,r0,z0)#np.tan(a/2.)*(plow-10000.) + r0
    r2 = PT.wsPrimRad(phigh,1.,r0,z0)#np.tan(a/2.)*(phigh-10000.) + r0
    rays = PT.annulus(r1,r2,num)
    PT.transform(rays,0,0,0,np.pi,0,0)
    PT.transform(rays,0,0,z0,0,0,0)

    #Trace to primary
    PT.wsPrimary(rays,r0,z0,1.)
    #Handle vignetting
    ind = np.logical_and(rays[3]<phigh,rays[3]>plow)
    rays = PT.vignette(rays,ind=ind)
    #Vignette rays hitting backside of mirror
    dot = rays[4]*rays[7]+rays[5]*rays[8]+rays[6]*rays[9]
    ind = dot < 0.
    rays = PT.vignette(rays,ind=ind)
    #If all rays are vignetted, return
    if np.size(rays[1]) < 1:
        return 0.,0.,0.
    #Apply pointing error
    rays = [rays[0],rays[1],rays[2],rays[3],\
            rays[4]+np.sin(theta),rays[5],-np.sqrt(1-np.sin(theta)**2),\
            rays[7],rays[8],rays[9]]
##    PT.l = PT.l + np.sin(theta)
##    PT.n = -np.sqrt(1 - PT.l**2)
    #Reflect
    PT.reflect()
    #Compute mean incidence angle for reflectivity
    ang = np.abs(np.mean(np.arcsin(dot))) #radians
    refl1 = CXCreflIr(ang,energy,rough)
    #Total rays entering primary aperture
    N1 = np.size(rays[1])

    #Trace to secondary
    PT.wsSecondary(r0,z0,1.)
    #Vignette anything outside the physical range of the mirror
    ind = np.logical_and(rays[3]>slow,rays[3]<shigh)
    rays = PT.vignette(rays,ind=ind)
    #Vignette anything hitting the backside
    dot = rays[4]*rays[7]+rays[5]*rays[8]+rays[6]*rays[9]
    ind = dot < 0.
    rays = PT.vignette(rays,ind=ind)
    if np.size(rays[1]) < 1:
        return 0.,0.,0.
    PT.reflect()
    #Compute mean incidence angle for reflectivity
    ang = np.abs(np.mean(np.arcsin(dot))) #radians
    refl2 = CXCreflIr(ang,energy,rough)

    #Trace to focal plane
    rays = PT.flat(rays)

##    #Find Chase focus
##    delta = 0.
##    if chaseFocus or bestFocus:
##        cx,cy = PT.centroid()
##        r = np.sqrt(cx**2+cy**2)
##        delta = .0625*(1.+1)*(r**2*(phigh-plow)/10000.**2)\
##                *(1/np.tan(a))**2
##        PT.transform(0,0,delta,0,0,0)
##        PT.flat()
##
##    #Find best focus
##    delta2 = 0.
##    delta3 = 0.
##    if bestFocus:
##        try:
##            tran.focusI(rays,weights=
##        except:
##            pdb.set_trace()
##        PT.flat()

    return refl1*refl2,rays
Exemplo n.º 2
0
def traceChaseParam(num,
                    psi,
                    theta,
                    alpha,
                    L1,
                    z0,
                    bestFocus=False,
                    chaseFocus=False):
    """Trace a WS mirror pair using the parameters in Eq. 13
    of Chase & VanSpeybroeck
    Return the RMS radius of the focus
    Can specify whether to find the best focus or not
    """
    #Define annulus of source rays
    r0 = np.tan(4 * alpha) * z0
    alphap = 2 * alpha / (1 + 1 / psi)
    r1 = PT.wsPrimRad(z0 + L1, 1., r0, z0)  #np.tan(alphap/2.)*L1 + r0
    PT.annulus(r0, r1, num)
    PT.transform(0, 0, 0, np.pi, 0, 0)
    PT.transform(0, 0, -10000., 0, 0, 0)

    pdb.set_trace()

    #Trace to primary
    PT.wsPrimary(r0, z0, psi)
    #Handle vignetting
    PT.vignette()
    ind = np.logical_and(PT.z < z0 + L1, PT.z > z0)
    PT.vignette(ind=ind)
    ##    pdb.set_trace()
    #Apply pointing error
    PT.l = PT.l + np.sin(theta)
    PT.n = -np.sqrt(1 - PT.l**2)
    #Anything hitting backside goes away
    dot = PT.l * PT.ux + PT.m * PT.uy + PT.n * PT.uz
    ind = dot < 0.
    PT.vignette(ind=ind)
    if np.size(PT.x) < 1:
        return 0., 0., 0.
    #Reflect
    PT.reflect()

    N1 = np.size(PT.x)

    #Trace to secondary
    PT.wsSecondary(r0, z0, psi)
    #Vignette anything that did not converge
    PT.vignette()
    #Vignette anything hitting the backside
    dot = PT.l * PT.ux + PT.m * PT.uy + PT.n * PT.uz
    ind = dot < 0.
    PT.vignette(ind=ind)
    ##    #Vignette anything outside the physical range of the mirror
    ##    ind = np.logical_and(PT.z>z0-L1,PT.z<z0)
    ##    PT.vignette(ind=ind)
    if np.size(PT.x) < 1:
        return 0., 0., 0.
    PT.reflect()

    #Trace to focal plane
    PT.flat()
    cx, cy = PT.centroid()
    r = np.sqrt(cx**2 + cy**2)

    #Find best focus
    delta = 0.
    if chaseFocus or bestFocus:
        delta = .0625 * (psi + 1) * (r**2 * L1 / z0**2) * (1 /
                                                           np.tan(alpha))**2
        PT.transform(0, 0, delta, 0, 0, 0)
        PT.flat()

    delta2 = 0.
    delta3 = 0.
    if bestFocus:
        try:
            delta2 = PT.findimageplane(20., 100)
            PT.transform(0, 0, delta2, 0, 0, 0)
            delta3 = PT.findimageplane(1., 100)
            PT.transform(0, 0, delta3, 0, 0, 0)
        except:
            pdb.set_trace()
        PT.flat()

    return PT.rmsCentroid() / z0, delta + delta2 + delta3, r
Exemplo n.º 3
0
def sphericalNodes(rin,z0,fov,Nshells,N):
    """This function will iteratively scan node positions
    about a sphere around the focus. Node will start in obvious
    vignetting position. Extreme rays will be traced including
    FoV. Node will be nudged outward until vignetting no longer
    occurs. Node will then be moved by the designated mechanical
    gap. Then the next node is traced in the same fashion.
    Assumptions: 50 mm symmetric gap
    """
    #Bookkeeping parameters
    f = np.sqrt(rin**2+z0**2)
    fov = fov/60.*np.pi/180. #fov to radians
    zlist = []
    rlist = []
    for i in range(Nshells):
        #Starting radius for next shell node
        rstart = PT.wsPrimRad(z0+225.,1.,rin,z0)
        #Reduce rstart until vignetting is reached
        flag = 0
        while flag==0:
            zstart = np.sqrt(f**2-rstart**2)
            #Set up rays
            r1 = PT.wsPrimRad(zstart+25.,1.,rstart,zstart)
            r2 = PT.wsPrimRad(zstart+225.,1.,rstart,zstart)
            PT.pointsource(0.,N)
            PT.z = np.repeat(10500.,N)
            PT.x = np.linspace(r1,r2,N)
            PT.n = np.repeat(-1.,N)
            #Perform trace and add FoV deflections to rays
            PT.wsPrimary(rstart,zstart,1.)
            PT.l = np.repeat(np.sin(fov),N)
            PT.n = -np.sqrt(1 - PT.l**2)
            #Verify that rays do not hit prior primary
            PT.wsPrimary(rin,z0,1.)
            if np.sum(PT.z<z0+225.) != 0:
                #Ray has hit
                print 'Ray hits prior primary!'
                flag = 1
            #Verify that rays do not hit prior secondary
            PT.wsPrimary(rstart,zstart,1.)
            PT.reflect()
            PT.wsSecondary(rstart,zstart,1.)
            PT.reflect()
            PT.wsSecondary(rin,z0,1.)
            if np.sum(PT.z > z0-225.) != 0:
                print 'Ray hits prior secondary!'
                flag = 1
            #Look at other deflection
            PT.pointsource(0.,N)
            PT.z = np.repeat(10500.,N)
            PT.x = np.linspace(r1,r2,N)
            PT.n = np.repeat(-1.,N)
            #Perform trace and add FoV deflections to rays
            PT.wsPrimary(rstart,zstart,1.)
            PT.l = np.repeat(-np.sin(fov),N)
            PT.n = -np.sqrt(1 - PT.l**2)
            #Verify that rays do not hit prior primary
            PT.wsPrimary(rin,z0,1.)
            if np.sum(PT.z<z0+225.) != 0:
                #Ray has hit
                print 'Ray hits prior primary!'
                flag = 1
            #Verify that rays do not hit prior secondary
            PT.wsPrimary(rstart,zstart,1.)
            PT.reflect()
            PT.wsSecondary(rstart,zstart,1.)
            PT.reflect()
            PT.wsSecondary(rin,z0,1.)
            if np.sum(PT.z > z0-225.) != 0:
                print 'Ray hits prior secondary!'
                flag = 1
            if flag==0:
                rstart = rstart - .01 #Take off 10 microns
##                sys.stdout.write(str(rstart)+'\n')
##                sys.stdout.flush()
        #Vignetting has been reached, append rstart and zstart
        #to list of node positions
        rlist.append(rstart)
        zlist.append(zstart)
        rin = rstart
        z0 = zstart
    return rlist,zlist
Exemplo n.º 4
0
def traceWSShell(num,theta,r0,z0,phigh,plow,shigh,slow,\
                 chaseFocus=False,bestFocus=False):
    """Trace a WS mirror pair with 10 m focal length and
    mirror axial cutoffs defined by phigh,plow
    """
    #Define annulus of source rays
    a, p, d, e = con.woltparam(r0, z0)
    r1 = PT.wsPrimRad(plow, 1., r0, z0)  #np.tan(a/2.)*(plow-10000.) + r0
    r2 = PT.wsPrimRad(phigh, 1., r0, z0)  #np.tan(a/2.)*(phigh-10000.) + r0
    ##    r2 = np.mean([r1,r2])
    PT.annulus(r1, r2, num)
    PT.transform(0, 0, 0, np.pi, 0, 0)
    PT.transform(0, 0, z0, 0, 0, 0)
    ##    pdb.set_trace()

    #Trace to primary
    PT.wsPrimary(r0, z0, 1.)
    #Handle vignetting
    PT.vignette()
    ind = np.logical_and(PT.z < phigh, PT.z > plow)
    PT.vignette(ind=ind)
    #Vignette rays hitting backside of mirror
    dot = PT.l * PT.ux + PT.m * PT.uy + PT.n * PT.uz
    ind = dot < 0.
    PT.vignette(ind=ind)
    #If all rays are vignetted, return
    if np.size(PT.x) < 1:
        return 0., 0., 0.
    #Apply pointing error
    PT.l = PT.l + np.sin(theta)
    PT.n = -np.sqrt(1 - PT.l**2)
    #Reflect
    PT.reflect()
    #Compute mean incidence angle for reflectivity
    ##    ang = np.abs(np.mean(np.arcsin(dot))) #radians
    ##    refl1 = CXCreflIr(ang,energy,rough)
    #Total rays entering primary aperture
    N1 = np.size(PT.x)

    #Trace to secondary
    PT.wsSecondary(r0, z0, 1.)
    #Vignette anything that did not converge
    PT.vignette()
    #Vignette anything outside the physical range of the mirror
    ind = np.logical_and(PT.z > slow, PT.z < shigh)
    PT.vignette(ind=ind)
    #Vignette anything hitting the backside
    dot = PT.l * PT.ux + PT.m * PT.uy + PT.n * PT.uz
    ind = dot < 0.
    PT.vignette(ind=ind)
    if np.size(PT.x) < 1:
        return 0., 0., 0.
    PT.reflect()
    #Compute mean incidence angle for reflectivity
    ##    ang = np.abs(np.mean(np.arcsin(dot))) #radians
    ##    refl2 = CXCreflIr(ang,energy,rough)

    #Trace to focal plane
    PT.flat()

    #Find Chase focus
    delta = 0.
    if chaseFocus or bestFocus:
        cx, cy = PT.centroid()
        r = np.sqrt(cx**2 + cy**2)
        delta = .0625*(1.+1)*(r**2*(phigh-plow)/10000.**2)\
                *(1/np.tan(a))**2
        PT.transform(0, 0, delta, 0, 0, 0)
        PT.flat()

    #Find best focus
    delta2 = 0.
    delta3 = 0.
    if bestFocus:
        try:
            delta2 = PT.findimageplane(20., 100)
            PT.transform(0, 0, delta2, 0, 0, 0)
            delta3 = PT.findimageplane(1., 100)
            PT.transform(0, 0, delta3, 0, 0, 0)
        except:
            pdb.set_trace()
        PT.flat()

    #return refl1*refl2
    return PT.hpd(), PT.rmsCentroid(), delta