Example #1
0
def gratArray(outerrad, hubdist, angle, inc, l=95.):
    """Trace rays leaving SPO petal to the fanned grating array.
    Start with outermost radius and rotate grating array about
    the hub. Define outermost grating position by max ray radius
    at desired axial height.
    Rays have been traced to bottom of outermost grating.
    """
    #Put origin at bottom of outermost grating
    PT.transform(outerrad, 0, 0, 0, 0, 0)
    #Go to proper incidence angle of grating
    PT.transform(0, 0, 0, 0, 0, -pi / 2)
    PT.transform(0, 0, 0, -pi / 2 - angle + inc, 0, 0)
    #Go to hub
    PT.transform(0, hubdist, 0, 0, 0, 0)
    #Trace out gratings until no rays hit a grating
    #Flat
    #Indices
    #Reflect
    #Apply Grating
    #Next
    PT.flat()
    ind = np.logical_and(PT.y < -hubdist, PT.y > -l - hubdist)
    ang = l * sin(inc) / hubdist
    i = 0
    while np.sum(ind) > 0:
        i = i + 1
        PT.reflect(ind=ind)
        PT.radgrat(0., 160. / hubdist, 0, 1., ind=ind)
        PT.transform(0, 0, 0, ang, 0, 0)
        PT.flat()
        ind = np.logical_and(PT.y < -hubdist, PT.y > -l - hubdist)
        sys.stdout.write('%i \r' % i)
        sys.stdout.flush()
    pdb.set_trace()
Example #2
0
def primMaskTrace(fold, primary, woltVignette=True, foldrot=0.):
    #Get Wolter parameters
    alpha, p, d, e = conicsolve.woltparam(220., 8400.)
    primfoc = conicsolve.primfocus(220., 8400.)

    #Trace to fold mirror
    #translate to center of fold mirror
    PT.transform(0., 85.12, primfoc - 651.57 + 85.12, 0, 0, 0)
    #rotate so surface normal points in correct direction
    PT.transform(0, 0, 0, -3 * pi / 4, 0, 0)
    PT.transform(0, 0, 0, 0, 0, pi)
    #trace to fold flat
    PT.flat()
    #Introduce fold misalignment
    PT.transform(*fold)
    PT.zernsurfrot(foldsag, foldfig, 406. / 2, -174.659 * pi / 180 + foldrot)
    PT.itransform(*fold)
    PT.reflect()
    PT.transform(0, 0, 0, 0, 0, -pi)
    PT.transform(0, 0, 0, pi / 4, 0, 0)

    #Translate to optical axis mid-plane, then down to image of
    #primary focus, place primary mirror and trace
    PT.transform(0, 85.12, 651.57 - 85.12, 0, 0, 0)
    PT.flat()
    ##    pdb.set_trace()
    rt = conicsolve.primrad(8475., 220., 8400.)
    PT.transform(0, -rt, 75., 0, 0, 0)
    PT.transform(*primary)
    PT.transform(0, rt, -8475., 0, 0, 0)
    ##    PT.wolterprimary(220.,8400.)
    PT.primaryLL(220., 8400., 8525., 8425., 30. * np.pi / 180., pcoeff, pax,
                 paz)
    if woltVignette is True:
        ind = logical_and(PT.z < 8525., PT.z > 8425.)
        PT.vignette(ind=ind)
    PT.reflect()
    PT.transform(0, -rt, 8475., 0, 0, 0)
    PT.itransform(*primary)
    PT.transform(0, rt, -8475., 0, 0, 0)

    #Move back up to mask plane and trace flat
    PT.transform(0, 0, 8400. + 134.18, 0, 0, 0)
    PT.flat()
    ##    pdb.set_trace()

    #Rays should now be at Hartmann mask plane

    return
Example #3
0
def setupSource(wave,N,radius=450.,focal=8000.,scatter=50e-6,\
                gwidth=25.,glength=32.,pitch=0.,yaw=0.,roll=0.):
    """Set up converging beam with some scatter.
    Idea is to place a grating at radius and focal length
    with an incidence angle of 1.5 degrees
    """
    #Setup rays over grating surface
    PT.x = np.random.uniform(low=-gwidth / 2, high=gwidth / 2, size=N)
    PT.y = np.random.uniform(low=-glength / 2, high=glength / 2, size=N)
    PT.z = np.repeat(0., N)
    PT.l = np.zeros(N)
    PT.m = np.zeros(N)
    PT.n = np.zeros(N)
    PT.ux = np.zeros(N)
    PT.uy = np.zeros(N)
    PT.uz = np.repeat(1., N)
    #Transform to nominal focus to set ray cosines
    PT.transform(0, 0, 0, -88.5 * np.pi / 180, 0, 0)
    PT.transform(0, radius, -focal, 0, 0, 0)
    rad = np.sqrt(PT.x**2 + PT.y**2 + PT.z**2)
    PT.l = -PT.x / rad
    PT.m = -PT.y / rad
    PT.n = -PT.z / rad
    #Add scatter
    PT.l = PT.l + scatter / 10. * np.random.normal(size=N)
    PT.m = PT.m + scatter * np.random.normal(size=N)
    PT.n = -np.sqrt(1. - PT.l**2 - PT.m**2)
    #Go back to plane of of grating
    PT.transform(0, -radius, focal, 0, 0, 0)
    PT.transform(0, 0, 0, 88.5 * np.pi / 180, 0, np.pi)
    #Place grating and diffract
    hubdist = np.sqrt(radius**2 + focal**2) * np.cos(1.5 * np.pi / 180)
    PT.flat()
    PT.reflect()
    PT.transform(0, 0, 0, pitch, roll, yaw)
    PT.radgrat(hubdist, 160. / hubdist, 1, wave)
    PT.itransform(0, 0, 0, pitch, roll, yaw)
    #Go to focal plane
    PT.transform(0, 0, 0, np.pi / 2, 0, 0)
    PT.transform(0, 0, -hubdist, 0, 0, 0)
    PT.transform(0, 0, 27.27727728 - .04904905, 0, 0, 0)
    PT.flat()

    #plt.plot(PT.x,PT.y,'.')

    return PT.centroid()
Example #4
0
def arc(inc, yaw, hubdist, wave, order, dpermm):
    """Return x and y positions of diffraction arc
    as a function of wavelength for a given order"""
    #Set up source ray
    PT.circularbeam(0., 1)
    #Transform to grating frame
    PT.transform(0, 0, 0, pi / 2 + inc, 0, 0)
    PT.transform(0, 0, 0, 0, 0, yaw)
    PT.flat()
    #Apply grating
    PT.reflect()
    PT.radgrat(hubdist, dpermm, order, wave)
    #Go to focus
    PT.transform(0, 0, 0, 0, 0, -yaw)
    PT.transform(0, hubdist, 0, 0, 0, 0)
    PT.transform(0, 0, 0, pi / 2, 0, 0)
    PT.flat()
    #Get ray positions
    return PT.x[0], PT.y[0]
Example #5
0
def traceFromMask(N,
                  numholes,
                  cda,
                  fold,
                  retro,
                  primary,
                  foldrot=0.,
                  retrorot=0.):
    #Vignette at proper hole
    h = hartmannMask()
    ind = h == N
    PT.vignette(ind=ind)

    #Continue trace up to retro and back to CDA
    PT.transform(0, -123.41, 1156.48 - 651.57 - 134.18, 0, 0, 0)
    PT.flat()
    PT.transform(0, 0, 0, pi, 0, 0)
    PT.transform(*retro)
    PT.zernsurfrot(retrosag, retrofig, 378. / 2, -8.993 * pi / 180 + retrorot)
    PT.itransform(*retro)
    PT.reflect()
    PT.transform(0, 0, 0, -pi, 0, 0)
    PT.transform(0, 123.41, -1156.48 + 651.57 + 134.18, 0, 0, 0)
    PT.flat()
    h = hartmannMask()
    ind = h == N
    PT.vignette(ind=ind)
    PT.transform(0, 0, -134.18, 0, 0, 0)
    rt = conicsolve.primrad(8475., 220., 8400.)
    PT.transform(0, -rt, 75., 0, 0, 0)
    PT.transform(*primary)
    PT.transform(0, rt, -8475., 0, 0, 0)
    PT.wolterprimary(220., 8400.)
    ind = logical_and(PT.z < 8525., PT.z > 8425.)
    PT.vignette(ind=ind)
    PT.reflect()
    PT.transform(0, -rt, 8475., 0, 0, 0)
    PT.itransform(*primary)
    PT.transform(0, rt, -8475., 0, 0, 0)
    PT.transform(0,-85.12,8400.-651.57+85.12\
                 ,0,0,0)
    PT.transform(0, 0, 0, -pi / 4, 0, 0)
    PT.transform(0, 0, 0, 0, 0, pi)
    PT.flat()
    PT.transform(*fold)
    PT.zernsurfrot(foldsag, foldfig, 406. / 2, -174.659 * pi / 180 + foldrot)
    PT.itransform(*fold)
    PT.reflect()
    PT.transform(0, 0, 0, 0, 0, -pi)
    PT.transform(0, 0, 0, 3 * pi / 4, 0, 0)
    PT.transform(0,-85.12,-85.12-(conicsolve.primfocus(220.,8400.)-651.57)\
                 ,0,0,0)
    PT.transform(*cda)
    PT.flat()

    return
Example #6
0
def traceSPO(R, L, F, N, M, span=pi / 12, d=.605, t=.775):
    """Trace SPO surfaces sequentially. Collect rays from
    each SPO shell and set them to the PT rays at the end.
    Start at the inner radius, use the wafer and pore thicknesses
    to vignette and compute the next radius, loop while
    radius is less than Rout.
    """
    #Ray bookkeeping arrays
    tx = np.zeros(M * N)
    ty = np.zeros(M * N)
    tz = np.zeros(M * N)
    tl = np.zeros(M * N)
    tm = np.zeros(M * N)
    tn = np.zeros(M * N)
    tux = np.zeros(M * N)
    tuy = np.zeros(M * N)
    tuz = np.zeros(M * N)

    #Loop through shell radii and collect rays
    for i in range(M):
        #Set up source annulus
        PT.subannulus(R[i], R[i] + d, span, N)
        #Transform rays to be above xy plane
        PT.n = -PT.n
        PT.transform(0, 0, -100., 0, 0, 0)
        #Trace to primary
        PT.spoPrimary(R[i], F)
        PT.reflect()
        #Vignette
        ind = np.logical_and(PT.z <= L[i], PT.z >= 0.)
        if np.sum(ind) < N:
            pdb.set_trace()
        PT.vignette(np.logical_and(PT.z <= L[i], PT.z >= 0.))
        #Trace to secondary
        PT.spoSecondary(R[i], F)
        PT.reflect()
        #Vignette
        ind = np.logical_and(PT.z <= 0., PT.z >= -L[i])
        if np.sum(ind) < N:
            pdb.set_trace()
        PT.vignette(ind)
        #Collect rays
        try:
            tx[i * N:(i + 1) * N] = PT.x
            ty[i * N:(i + 1) * N] = PT.y
            tz[i * N:(i + 1) * N] = PT.z
            tl[i * N:(i + 1) * N] = PT.l
            tm[i * N:(i + 1) * N] = PT.m
            tn[i * N:(i + 1) * N] = PT.n
            tux[i * N:(i + 1) * N] = PT.ux
            tuy[i * N:(i + 1) * N] = PT.uy
            tuz[i * N:(i + 1) * N] = PT.uz
        except:
            pdb.set_trace()

    #Set to PT rays
    try:
        PT.x = tx
        PT.y = ty
        PT.z = tz
        PT.l = tl
        PT.m = tm
        PT.n = tn
        PT.ux = tux
        PT.uy = tuy
        PT.uz = tuz
    except:
        pdb.set_trace()

    return
Example #7
0
def traceCyl(align):
    """Traces a cylindrical approximation to Wolter I geometry
    Assumes 1 m radius of curvature in accordance with OAB samples
    align is a 12 element array giving the transformations to be
    applied to each mirror
    Uses identical set of rays each run defined upon module import
    Adds a restraint such that any vignetting over 25% results in
    a huge merit function
    """

    #Set up source
    np.random.seed(5)
    a, p, d, e = con.woltparam(1000., 10000.)
    r0 = con.primrad(10025., 1000., 10000.)
    r1 = con.primrad(10125., 1000., 10000.)
    dphi = 100. / 1000.
    PT.subannulus(r0, r1, dphi, 10**4)
    PT.transform(0, 0, 0, np.pi, 0, 0)
    PT.transform(0, 0, -10500., 0, 0, 0)

    #Trace primary cylinder: go to tangent point at center
    #of mirror and then rotate to cone angle, then move
    #to new cylinder axis and tracecyl
    rt = con.primrad(10075., 1000., 10000.)
    PT.transform(rt, 0, 0, 0, a, 0)
    PT.transform(*align[:6])
    PT.transform(0, 0, 0, np.pi / 2, 0, 0)
    PT.transform(-1000., 0, 0, 0, 0, 0)
    PT.cyl(1000.)

    #Vignette rays missing physical surface
    ind = np.logical_and(abs(PT.z) < 50., abs(PT.y) < 50.)
    PT.vignette(ind=ind)

    #Reflect and reverse transformations
    PT.reflect()
    PT.transform(1000., 0, 0, 0, 0, 0)
    PT.itransform(0, 0, 0, np.pi / 2, 0, 0)
    PT.itransform(*align[:6])
    PT.itransform(rt, 0, 0, 0, a, 0)

    #Trace secondary cylinder: same principle as before
    rt = con.secrad(9925., 1000., 10000.)
    PT.transform(0, 0, -150., 0, 0, 0)
    PT.transform(rt, 0, 0, 0, 3 * a, 0)
    PT.transform(*align[6:])
    PT.transform(0, 0, 0, np.pi / 2, 0, 0)
    PT.transform(-1000., 0, 0, 0, 0, 0)
    PT.cyl(1000.)

    #Vignette rays missing physical surface
    ind = np.logical_and(abs(PT.z) < 50., abs(PT.y) < 50.)
    PT.vignette(ind=ind)

    #Reflect and reverse transformations
    PT.reflect()
    PT.transform(1000., 0, 0, 0, 0, 0)
    PT.itransform(0, 0, 0, np.pi / 2, 0, 0)
    PT.itransform(*align[6:])
    PT.itransform(rt, 0, 0, 0, 3 * a, 0)

    #Go down to nominal focus
    PT.transform(0, 0, -9925., 0, 0, 0)
    PT.flat()

    #Compute merit function
    nom = PT.rmsCentroid() / 10**4 * 180. / np.pi * 60**2
    nom = nom + max((9500. - np.size(PT.x)), 0.)

    return nom
Example #8
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
Example #9
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
Example #10
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
Example #11
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
Example #12
0
def fullFromMask(N, cda, fold, retro, prim, sec, foldrot=0., retrorot=0.):
    ##    pdb.set_trace()
    #Vignette at proper hole
    h = hartmannMask()
    ind = h == N
    PT.vignette(ind=ind)

    #Continue trace up to retro and back to CDA
    PT.transform(0, -123.41, 1156.48 - 651.57 - 134.18, 0, 0, 0)
    PT.flat()
    PT.transform(0, 0, 0, pi, 0, 0)
    PT.transform(*retro)
    PT.zernsurfrot(retrosag, retrofig, 378. / 2, -8.993 * pi / 180 + retrorot)
    PT.itransform(*retro)
    PT.reflect()
    PT.transform(0, 0, 0, -pi, 0, 0)

    #Back to mask
    PT.transform(0, 123.41, -1156.48 + 651.57 + 134.18, 0, 0, 0)
    PT.flat()
    h = hartmannMask()
    ind = h == N
    PT.vignette(ind=ind)

    #Place Wolter surfaces
    PT.transform(0, 0, -134.18 - 8400., 0, 0, 0)
    PT.transform(0, -conicsolve.primrad(8425., 220., 8400.), 8425., 0, 0, 0)
    PT.transform(*prim)
    PT.itransform(0, -conicsolve.primrad(8425., 220., 8400.), 8425., 0, 0, 0)
    ##    PT.wolterprimary(220.,8400.)
    PT.primaryLL(220., 8400., 8525., 8425., 30. * np.pi / 180., pcoeff, pax,
                 paz)
    pdb.set_trace()
    ind = logical_and(PT.z < 8525., PT.z > 8425.)
    PT.vignette(ind=ind)
    PT.transform(0, -conicsolve.primrad(8425., 220., 8400.), 8425., 0, 0, 0)
    PT.itransform(*prim)
    PT.itransform(0, -conicsolve.primrad(8425., 220., 8400.), 8425., 0, 0, 0)
    PT.reflect()

    #Wolter secondary
    PT.transform(0, -conicsolve.secrad(8325., 220., 8400.), 8325., 0, 0, 0)
    PT.transform(*sec)
    PT.itransform(0, -conicsolve.secrad(8325., 220., 8400.), 8325., 0, 0, 0)
    PT.woltersecondary(220., 8400.)
    ind = logical_and(PT.z < 8375., PT.z > 8275.)
    PT.vignette(ind=ind)
    PT.reflect()
    PT.transform(0, -conicsolve.secrad(8325., 220., 8400.), 8325., 0, 0, 0)
    PT.itransform(*sec)
    PT.itransform(0, -conicsolve.secrad(8325., 220., 8400.), 8325., 0, 0, 0)

    ##    PT.woltersecondary(220.,8400.)
    ##    ind = logical_and(PT.z<8375.,PT.z>8275.)
    ##    PT.vignette(ind=ind)
    ##    PT.reflect()

    #Back to fold
    PT.transform(0,-85.12,8400.-651.57+85.12\
                 ,0,0,0)
    PT.transform(0, 0, 0, -pi / 4, 0, 0)
    PT.transform(0, 0, 0, 0, 0, pi)
    PT.flat()
    PT.transform(*fold)
    PT.zernsurfrot(foldsag, foldfig, 406. / 2, -174.659 * pi / 180 + foldrot)
    PT.itransform(*fold)
    PT.reflect()
    PT.transform(0, 0, 0, 0, 0, -pi)

    #Back to CDA
    PT.transform(0, 0, 0, 3 * pi / 4, 0, 0)
    PT.transform(0,-85.12,-85.12-8400.+651.57\
                 ,0,0,0)
    PT.transform(*cda)
    PT.flat()

    return