def __init__(self, center, from_optic, **extras):
		my=quadrupler
		optics={}
		ent=optics[my.ENTRANCE]=mir("quadrupler entrance")
		exit=optics[my.EXIT]=null_optic("quadrupler exit", (0,0,-1.0))
		l1=optics[my.L1]=lens("quadrupler telescope 1", f=+0.300)
		l2=optics[my.L2]=lens("quadrupler telescope 2", f=-0.150).place_between(ent, exit, 0.111).tilt_off_axis(4.0)
		#print l2.strength
		green=optics[my.DOUBLE]=null_optic("green crystal").place_between(l2, exit, 0.1)
		optics[my.QUADRUPLE]=null_optic("UV crystal").place_between(green, exit, 0.1)

		order=(my.L1, my.ENTRANCE, my.L2, my.DOUBLE, my.QUADRUPLE, my.EXIT)		
		composite_optic.init(self, "quadrupler", optics, order, (0,0,0), center, 0, extras=extras )
		l1.place_between(from_optic, ent, -0.04)
	def __init__(self, **extras):
		inch=0.0254
		entrance_y=5.0*inch
		y0=2.5*inch #height of main line off table)
		my=blue_through_ylf
		optics={}
		
		#first, list all mirrors, and point them at each other
		optics[my.UVM1]=mir("UVM1", (13*inch, entrance_y, 7.5*inch))
		optics[my.UVM2]=mir("UVM2", (7.5*inch, entrance_y, 7.5*inch))
		optics[my.PS1u]=mir("Blue Peri 1 upper", (8*inch, entrance_y, 37*inch))
		optics[my.PS1d]=mir("Blue Peri 1 lower", (8*inch, y0, 37*inch))
		optics[my.UVM3]=mir("UVM3", (36*inch, y0, 38*inch))
		optics[my.UVM4]=mir("UVM4", (36*inch, y0, 137.5*inch))
		optics[my.UVM5]=mir("UVM5", (43.5*inch, y0, 49.5*inch))
		optics[my.UVM6]=mir("UVM6", (46.5*inch, y0, 137.5*inch))
		optics[my.UVM7]=mir("UVM7", (38*inch, y0, 38*inch))
		optics[my.UVM8]=mir("UVM8", (41.5*inch, y0, 136*inch))
		optics[my.UVM9]=mir("UVM9", (53*inch, y0, 136*inch))
		optics[my.UVM10]=mir("UVM10", (53*inch, y0, 41*inch))
		optics[my.UVM11]=mir("UVM11", (48*inch, y0, 41*inch))
		optics[my.UVM12]=mir("YLF retro", (48*inch, y0,80.5*inch))
		optics[my.YLF_SPLIT]=mir("YLF exit splitter", (48*inch, y0, 47.8*inch))
		
		optics[my.UVL1]=lens("UVL1", f=+0.75).place_between(optics[my.UVM3], optics[my.UVM4], 4.0*inch)
		optics[my.UVL2]=lens("UVL2", f=+1.00).place_between(optics[my.UVL1], optics[my.UVM4], 83*inch-0.0*inch)
				
		optics[my.DEMAG1]=lens("UVL3", f=+0.75).place_between(optics[my.UVM9], optics[my.UVM10], 23.0*inch)
		optics[my.DEMAG2]=lens("UVL4", f=+1.00).place_between(optics[my.DEMAG1], optics[my.UVM10], 1.7+5.0*inch)

		optics[my.SERR]=null_optic("Serr. Aperture", width=1.0*inch, thickness=0.1*inch).place_between(optics[my.DEMAG1], optics[my.DEMAG2], 3*inch)
		optics[my.FILTER]=null_optic("Filter Aperture", width=1.0*inch, thickness=0.1*inch).place_between(optics[my.DEMAG1], optics[my.DEMAG2], 0.75)
		
		looks=[my.UVM1, my.UVM2, my.PS1u, my.PS1d, my.UVM3, my.UVM4, my.UVM5, my.UVM6, my.UVM7,
			my.UVM8, my.UVM9, my.UVM10, my.UVM11, my.UVM12, my.YLF_SPLIT]
		#align all mirrors
		for i in range(1, len(looks)-1):
			optics[looks[i]].set_direction(optics[looks[i-1]], optics[looks[i+1]])

		order=[my.UVM1, my.UVM2, my.PS1u, my.PS1d, my.UVM3, my.UVL1, my.UVL2, my.UVM4, my.UVM5, my.UVM6, my.UVM7,
			my.UVM8, my.UVM9, my.DEMAG1, my.SERR, my.FILTER, my.DEMAG2, my.UVM10, my.UVM11, my.UVM12, my.YLF_SPLIT]
		
		#specify center and reference as (0,0,0) to make our coordinates absolute
		composite_optic.init(self, "blue line", optics, order, (0,0,0), (0,0,0), 0, extras=extras )
示例#3
0
    def __init__(self, center, from_optic, **extras):
        my = quadrupler
        optics = {}
        ent = optics[my.ENTRANCE] = mir("quadrupler entrance")
        exit = optics[my.EXIT] = null_optic("quadrupler exit", (0, 0, -1.0))
        l1 = optics[my.L1] = lens("quadrupler telescope 1", f=+0.300)
        l2 = optics[my.L2] = lens("quadrupler telescope 2",
                                  f=-0.150).place_between(
                                      ent, exit, 0.111).tilt_off_axis(4.0)
        # print l2.strength
        green = optics[my.DOUBLE] = null_optic("green crystal").place_between(
            l2, exit, 0.1)
        optics[my.QUADRUPLE] = null_optic("UV crystal").place_between(
            green, exit, 0.1)

        order = (my.L1, my.ENTRANCE, my.L2, my.DOUBLE, my.QUADRUPLE, my.EXIT)
        composite_optic.init(self,
                             "quadrupler",
                             optics,
                             order, (0, 0, 0),
                             center,
                             0,
                             extras=extras)
        l1.place_between(from_optic, ent, -0.04)
示例#4
0
def show_table():
    inch = 0.0254
    lambda0 = 1.054e-6
    spitfire_exit = Numeric.array((2 * inch, 5 * inch, -0.65))
    compressor_entrance = Numeric.array((45.5 * inch, 2.5 * inch, 46.5 * inch))

    optics = {}
    BLUELINE = 'bl'
    SPLIT = 'split'
    START = 'start'
    COMP = 'compressor'
    QUAD = 'quadrupler'
    IR = 'ir'
    IR_COMP = 'ir compressor'
    BE_TURN = 'be_turn'
    IZ_SCREEN = 'iz'

    optics[START] = null_optic("start", spitfire_exit)
    optics[BLUELINE] = blueline = blue_through_ylf()
    optics[SPLIT] = split1 = reflector("splitter1",
                                       center=(2 * inch, 5 * inch, 3 * inch))
    optics[IR] = irline = ir_line()

    comp = optics[COMP] = blue_compressor(38.5,
                                          1.28,
                                          lambda0,
                                          center=compressor_entrance,
                                          angle=270)
    mainbeam = beam(spitfire_exit, qtens(lambda0, spitfire.q0), lambda0)
    # print mainbeam.q
    split1.set_direction(spitfire_exit, blueline)
    blueline.set_entrance_direction(split1)
    blueline.set_exit_direction(comp)
    comp.rotate_to_axis(blueline)
    q = optics[QUAD] = quadrupler(center=(40 * inch, 2.5 * inch, 34.5 * inch),
                                  from_optic=comp[blue_compressor.TM1])
    comp.set_exit_direction(q)
    q.set_entrance_direction(comp)
    blue_sys = composite_optic("blue_sys", optics,
                               [START, SPLIT, BLUELINE, COMP, QUAD], (0, 0, 0),
                               (0, 0, 0), 0)
    irline.set_entrance_direction(spitfire_exit)

    # align compressor table to output of main IR line
    ir_sys = composite_optic("ir_sys", optics, [START, IR], (0, 0, 0),
                             (0, 0, 0), 0).clone()
    pointer = trace_path(ir_sys, mainbeam.clone())[-1]
    pointer.free_drift(1.0)
    optics[IR_COMP] = ircomp = ir_compressor(center=pointer.x0,
                                             angle=math.atan(0.2) / deg)
    ircomp.set_entrance_direction(irline)

    # now, align IZ
    ir_sys = composite_optic("ir_sys", optics, [START, IR, IR_COMP], (0, 0, 0),
                             (0, 0, 0), 0).clone()
    pointer = trace_path(ir_sys, mainbeam.clone())[-1]
    pointer.free_drift(1.0)
    bemir = optics[BE_TURN] = reflector("be turn mirror",
                                        center=pointer.x0,
                                        angle=45.0)
    bemir.transport_to_here(pointer).transform(pointer)
    pointer.free_drift(0.1)
    dz = pointer.q.next_waist()
    pointer.free_drift(dz)
    optics[IZ_SCREEN] = null_optic("IZ", pointer.x0)
    ir_sys = composite_optic("ir_sys", optics,
                             [START, IR, IR_COMP, BE_TURN, IZ_SCREEN],
                             (0, 0, 0), (0, 0, 0), 0)

    whole_table = composite_optic(
        "whole table", optics,
        [START, SPLIT, BLUELINE, COMP, QUAD, IR, IR_COMP, BE_TURN, IZ_SCREEN],
        (0, 0, 0), (0, 0, 0), 0)

    ir_trace = trace_path(ir_sys, mainbeam.clone())
    ir_trace.color = graphite.red
    blue_trace = trace_path(blue_sys, mainbeam.clone())
    blue_trace.color = graphite.blue

    if table_layout:
        g = draw_everything({"sys": whole_table},
                            ir_trace, (-.25, 5), (0, 2.5),
                            three_d=0)
        draw_trace(g, blue_trace)

        #g=draw_everything({"sys":sys}, trace, (0.5,1.1), (0.8,1.1), three_d=0)
        #g=draw_everything({"sys":sys}, trace, (0.7,1.3), (0.9,1.2), three_d=0)
        if show_qd:
            graphite.genOutput(g,
                               'QD',
                               canvasname="Compressor layout",
                               size=(900, 500))
        if show_pdf:
            graphite.genOutput(g,
                               'PDF',
                               canvasname="Tablelayout",
                               size=(900, 500))
    # print trace[0]
    plotq(blue_trace)

    if 0:
        glabel = ircomp.mark_label(ircomp.INPUT)
        m = ir_trace[(glabel, 0)]
        print("\n\n**start**\n\n")
        print(m.incoming_direction, m.direction())
        print(m.incoming_q)
        print(m.incoming_q.qi_moments()[1:3])
        print(m.incoming_q.q_moments()[1:3])
        print(m.incoming_q.qit, "\n")
        print(m.localize_transform_tensor)
        print(m.footprint_q)
        print(m.footprint_q.qi_moments()[1:3])
        print(m.footprint_q.q_moments()[1:3])
        print(m.footprint_q.qit, "\n")
        print(m.globalize_transform_tensor)
        print(m.q)
        print(m.q.qi_moments()[1:3])
        print(m.q.q_moments()[1:3])
        print(m.q.qit, "\n")

    glabel = ircomp.mark_label(ircomp.INPUT)
    # endpoint=ir_trace[(glabel,0)]  #get first hit on optic <glabel>
    endpoint = ir_trace[-1]
    q = endpoint.q

    t, qx0, qy0 = q.qi_moments()
    theta = math.atan2(t[0, 1].real, t[0, 0].real) / deg
    qxx, qyy = endpoint.transform_q_to_table(q)
    dzx, dzy = (1e6 / qxx).real, (1e6 / qyy).real
    print((
        "qxx = %.1f, dzx = %.0f, qyy=%.1f, dzy=%.0f, (in um), theta=%.1f deg" %
        (q.rw(qxx)[1] * 1e6, dzx, q.rw(qyy)[1] * 1e6, dzy, theta)))
示例#5
0
def doit_bc(theta1, clen, lambda0, drawit=0):

    print("\n\n***start blue line trace***\n")
    grating_offset = -0.075
    exit_height = 0
    exit_z = -0.3
    eta1 = 0.0

    optics = {}

    END = 'end'
    optics[END] = null_optic("end", (0.15, exit_height, 0), 0)
    START = 'start'
    optics[START] = null_optic("start", (0, 0, -0.85))

    tracebeam = basebeam.clone()
    system_center = Numeric.array((-0.1, 0, -0.85))

    basebeam = beam(system_center, qtens(lambda0, q=spitfire.q0), lambda0)
    tracebeam.free_drift(-0.2)

    COMP = 'comp'
    comp = optics[COMP] = blue_compressor(theta1,
                                          clen,
                                          lambda0,
                                          center=system_center,
                                          angle=rotation)
    TM2 = 'turn2'
    optics[TM2] = reflector("output turn 2",
                            angle=0,
                            center=(0.15, exit_height, -0.6),
                            width=.025)

    optics[COMP].set_exit_direction(optics[TM2])
    optics[TM2].set_direction(optics[COMP], optics[END])

    sys_order = (START, COMP, TM2, DEMAG1, DEMAG2, END)

    GRATE = comp.mark_label(blue_compressor.GRATE)
    IR1 = comp.mark_label(blue_compressor.IR1)
    IR2 = comp.mark_label(blue_compressor.IR2)

    optic_sys = composite_optic("system",
                                optics,
                                sys_order,
                                center=optics[START].center)

    trace0 = trace_path(optic_sys, tracebeam.shift_lambda(0))
    trace0.color = graphite.green
    trace1 = trace_path(optic_sys, tracebeam.shift_lambda(-0.5e-9))
    trace1.color = graphite.blue
    trace2 = trace_path(optic_sys, tracebeam.shift_lambda(+0.5e-9))
    trace2.color = graphite.red

    try:  # if one of the traces failed, this may not work
        print("Theta1=%.3f eta=%.3f len=%.3f lambda=%.4f" %
              (theta1, eta1, clen, lambda0 * 1e6))
        d0 = trace0[-1]['total_drift']
        d1 = trace1[-1]['total_drift']
        d2 = trace2[-1]['total_drift']
        print((
            "d(lambda0-0.5nm)=%.3f m, d(lambda0+0.5nm)=%.3f m, dt/dl=%.0f ps/nm, "
            % (d1, d2, (d2 - d1) * 1e12 / clight)),
              end=' ')
        print("d2t/dl2 = %.2f ps/nm^2" % ((d2 + d1 - 2.0 * d0) *
                                          (1e12 / clight) * 4))
        spot1info = trace0[(GRATE, 0)]
        spot2info = trace0[(GRATE, 1)]
        ir1info = trace0[(IR1, 0)]
        ir2info = trace0[(IR2, 0)]
        spot_offset = spot2info['position'] - spot1info['position']
        retro_offset = ir2info['position'] - ir1info['position']
        print("Grating offset = %.3f, retro_offset=%.3f" %
              (vec_mag(spot_offset), vec_mag(retro_offset)))
        print("measured vertex length = %.3f" %
              vec_mag(comp[GRATE].center - comp[IR1].center))
        print("dispersion offset on grating = %.3f m / nm" %
              vec_mag(trace2[(GRATE, 1)]['position'] -
                      trace1[(GRATE, 1)]['position']))
        print("final q = ", trace0[-1]['q'])
    except:
        traceback.print_exc()
        pass

    if drawit:
        g = draw_everything({"sys": optic_sys},
                            trace0, (-.9, .1), (-.5, .5),
                            three_d=0)
        #g=draw_everything(optics, trace0, (-2, 2), (-2, 2))
        draw_trace(g, trace1)
        draw_trace(g, trace2)
        graphite.genOutput(g,
                           'QD',
                           canvasname="Compressor layout",
                           size=(600, 500))
示例#6
0
    def __init__(self, **extras):
        inch = 0.0254
        entrance_y = 5.0 * inch
        exit_y = 13.5 * inch
        my = ir_line
        optics = {}

        # first, list all mirrors, and point them at each other
        optics[my.M1] = mir("M1", (2 * inch, entrance_y, 10 * inch))
        optics[my.M2] = mir("M2", (4 * inch, entrance_y, 10 * inch))
        optics[my.TrM1] = mir("TrM1", (4 * inch, entrance_y, 96 * inch))
        optics[my.TrM2] = mir("TrM2", (6 * inch, entrance_y, 96 * inch))
        optics[my.TrM3] = mir("TrM3", (6 * inch, entrance_y, 82.5 * inch))
        optics[my.TrM4] = mir("TrM4", (2 * inch, entrance_y, 82.5 * inch))
        optics[my.M3] = mir("M3", (4 * inch, entrance_y, 135 * inch))
        optics[my.M4] = mir("M4", (12 * inch, entrance_y, 135 * inch))
        optics[my.M5] = mir("M5", (13 * inch, entrance_y, 105 * inch))
        optics[my.M6] = mir("M6", (14 * inch, entrance_y, 105 * inch))
        optics[my.M7] = mir("M7", (16.5 * inch, entrance_y, 3 * inch))
        optics[my.M8] = mir("M8", (24 * inch, entrance_y, 3 * inch))
        optics[my.M9] = mir("M9", (23 * inch, entrance_y, 135 * inch))
        optics[my.M10] = mir("M10", (33 * inch, entrance_y, 134.5 * inch))
        optics[my.M11] = mir("M11", (33 * inch, entrance_y, -6 * inch))
        optics[my.BP4] = PL_brewster_filter("BP4",
                                            (33 * inch, entrance_y, 27 * inch),
                                            reversed=1)
        optics[my.M12] = mir("M12", (20 * inch, entrance_y, 33 * inch))
        optics[my.M13] = mir("M13", (20 * inch, entrance_y, 12 * inch))
        optics[my.M14] = mir("M14", (8.5 * inch, entrance_y, 11.5 * inch))
        optics[my.M15] = mir("M15", (8.5 * inch, exit_y, 11.5 * inch))

        optics[my.EXIT] = sys_exit = null_optic(
            "exit", (10.0 * inch, exit_y, 142.0 * inch))

        optics[my.L1] = lens("L1",
                             f=+0.400).place_between(optics[my.M2],
                                                     optics[my.TrM1],
                                                     12.0 * inch)
        optics[my.L2] = lens("L2",
                             f=+0.800).place_between(optics[my.L1],
                                                     optics[my.TrM1], 1.30)
        optics[my.L3] = lens("L3",
                             f=+0.750).place_between(optics[my.M6],
                                                     optics[my.M7], 10 * inch)
        optics[my.L4] = lens("L4",
                             f=+1.500).place_between(optics[my.L3],
                                                     optics[my.M7], 2.25)
        optics[my.L5] = lens("L5",
                             f=+0.750).place_between(optics[my.M10],
                                                     optics[my.M11], 5 * inch)
        optics[my.L6] = lens("L6",
                             f=+1.500).place_between(optics[my.L5],
                                                     optics[my.M11],
                                                     95.5 * inch)
        optics[my.L7] = lens("L7",
                             f=+0.750).place_between(optics[my.M15], sys_exit,
                                                     4.5 * inch)
        optics[my.L8] = lens("L8",
                             f=+2.500,
                             width=6 * inch,
                             thickness=0.25 * inch).place_between(
                                 optics[my.M15], sys_exit,
                                 -1 * inch).tilt_off_axis((0, 45, 0))

        optics[my.G9a] = laser_head("9mm-1", width=2.0 * inch, thickness=6.0 * inch, rodsize=0.009).\
            place_between(optics[my.M4], optics[my.M5], 9 * inch)
        optics[my.G9b] = laser_head("9mm-2", width=2.0 * inch, thickness=6.0 * inch, rodsize=0.009).\
            place_between(optics[my.M4], optics[my.M5], 23 * inch)

        optics[my.G25a] = laser_head("25mm-1", width=6.0 * inch, thickness=12.0 * inch, rodsize=0.025).\
            place_between(optics[my.M8], optics[my.M9], 74 * inch)
        optics[my.G25b] = laser_head("25mm-2", width=6.0 * inch, thickness=12.0 * inch, rodsize=0.025).\
            place_between(optics[my.M8], optics[my.M9], 94 * inch)

        optics[my.G50] = laser_head("50mm", width=9.0 * inch, thickness=15.0 * inch, rodsize=0.050).\
            place_between(optics[my.M10], optics[my.M11], -19 * inch)

        optics[my.SERR1] = serrated_aperture("serrated aperture", diameter=0.003).\
            place_between(optics[my.M2], optics[my.TrM1], 10 * inch)
        optics[my.SF1] = plain_aperture("spatial filter 1", diameter=0.001).\
            place_between(optics[my.M2], optics[my.TrM1], 35 * inch)

        optics[my.QR1] = halfwave_plate("QR1",
                                        width=1 * inch,
                                        thickness=0.5 * inch).place_between(
                                            optics[my.G9a], optics[my.G9b],
                                            8 * inch).rotate_axis(22.5)
        optics[my.FR12] = faraday_rotator("FR12", width=0.5 * inch, thickness=6 * inch, rotation=45).\
            place_between(optics[my.M6], optics[my.M7], 5 * inch)
        optics[my.VSF1] = vacuum_spatial_filter("VSF1", thickness=24 * inch, width=2 * inch).\
            place_between(optics[my.L3], optics[my.L4], 0.750)

        optics[my.QR2] = halfwave_plate("QR2",
                                        width=1 * inch,
                                        thickness=0.5 * inch).place_between(
                                            optics[my.G25a], optics[my.G25b],
                                            8 * inch).rotate_axis(22.5)

        optics[my.BP2] = PL_brewster_filter("BP2", transmit=1).place_between(
            optics[my.G25b], optics[my.M9], 13 * inch).rotate_axis(90)
        optics[my.QR3] = halfwave_plate("QR3",
                                        width=1 * inch,
                                        thickness=0.5 * inch).place_between(
                                            optics[my.G25b], optics[my.M9],
                                            19 * inch).rotate_axis(22.5)
        optics[my.FR25] = faraday_rotator("FR25", width=1.0 * inch, thickness=6.0 * inch, rotation=45).\
            place_between(optics[my.G25b], optics[my.M9], 23 * inch)
        optics[my.BP3] = PL_brewster_filter("BP3", transmit=1).\
            place_between(optics[my.G25b], optics[my.M9], 30 * inch).rotate_axis(0)

        looks = [
            my.M1, my.M2, my.TrM1, my.TrM2, my.TrM3, my.TrM4, my.M3, my.M4,
            my.M5, my.M6, my.M7, my.M8, my.M9, my.M10, my.M11, my.BP4, my.M12,
            my.M13, my.M14, my.M15, my.EXIT
        ]
        # align all mirrors
        for i in range(1, len(looks) - 1):
            optics[looks[i]].set_direction(optics[looks[i - 1]],
                                           optics[looks[i + 1]])

        order = [
            my.M1, my.M2, my.SERR1, my.L1, my.SF1, my.L2, my.TrM1, my.TrM2,
            my.TrM3, my.TrM4, my.M3, my.M4, my.G9a, my.QR1, my.G9b, my.M5,
            my.M6, my.FR12, my.L3, my.VSF1, my.L4, my.M7, my.M8, my.G25a,
            my.QR2, my.G25b, my.BP2, my.QR3, my.FR25, my.BP3, my.M9, my.M10,
            my.L5, my.L6, my.G50, my.M11, my.BP4, my.M12, my.M13, my.M14,
            my.M15, my.L7, my.L8
        ]

        # specify center and reference as (0,0,0) to make our coordinates absolute
        composite_optic.init(self,
                             "IR line",
                             optics,
                             order, (0, 0, 0), (0, 0, 0),
                             0,
                             extras=extras)
示例#7
0
    def __init__(self, **extras):
        inch = 0.0254
        entrance_y = 5.0 * inch
        y0 = 2.5 * inch  # height of main line off table)
        my = blue_through_ylf
        optics = {}

        # first, list all mirrors, and point them at each other
        optics[my.UVM1] = mir("UVM1", (13 * inch, entrance_y, 7.5 * inch))
        optics[my.UVM2] = mir("UVM2", (7.5 * inch, entrance_y, 7.5 * inch))
        optics[my.PS1u] = mir("Blue Peri 1 upper",
                              (8 * inch, entrance_y, 37 * inch))
        optics[my.PS1d] = mir("Blue Peri 1 lower", (8 * inch, y0, 37 * inch))
        optics[my.UVM3] = mir("UVM3", (36 * inch, y0, 38 * inch))
        optics[my.UVM4] = mir("UVM4", (36 * inch, y0, 137.5 * inch))
        optics[my.UVM5] = mir("UVM5", (43.5 * inch, y0, 49.5 * inch))
        optics[my.UVM6] = mir("UVM6", (46.5 * inch, y0, 137.5 * inch))
        optics[my.UVM7] = mir("UVM7", (38 * inch, y0, 38 * inch))
        optics[my.UVM8] = mir("UVM8", (41.5 * inch, y0, 136 * inch))
        optics[my.UVM9] = mir("UVM9", (53 * inch, y0, 136 * inch))
        optics[my.UVM10] = mir("UVM10", (53 * inch, y0, 41 * inch))
        optics[my.UVM11] = mir("UVM11", (48 * inch, y0, 41 * inch))
        optics[my.UVM12] = mir("YLF retro", (48 * inch, y0, 80.5 * inch))
        optics[my.YLF_SPLIT] = mir("YLF exit splitter",
                                   (48 * inch, y0, 47.8 * inch))

        optics[my.UVL1] = lens("UVL1",
                               f=+0.75).place_between(optics[my.UVM3],
                                                      optics[my.UVM4],
                                                      4.0 * inch)
        optics[my.UVL2] = lens("UVL2",
                               f=+1.00).place_between(optics[my.UVL1],
                                                      optics[my.UVM4],
                                                      83 * inch - 0.0 * inch)

        optics[my.DEMAG1] = lens("UVL3", f=+0.75).place_between(
            optics[my.UVM9], optics[my.UVM10], 23.0 * inch)
        optics[my.DEMAG2] = lens("UVL4", f=+1.00).place_between(
            optics[my.DEMAG1], optics[my.UVM10], 1.7 + 5.0 * inch)

        optics[my.SERR] = null_optic("Serr. Aperture",
                                     width=1.0 * inch,
                                     thickness=0.1 * inch).place_between(
                                         optics[my.DEMAG1], optics[my.DEMAG2],
                                         3 * inch)
        optics[my.FILTER] = null_optic("Filter Aperture",
                                       width=1.0 * inch,
                                       thickness=0.1 * inch).place_between(
                                           optics[my.DEMAG1],
                                           optics[my.DEMAG2], 0.75)

        looks = [
            my.UVM1, my.UVM2, my.PS1u, my.PS1d, my.UVM3, my.UVM4, my.UVM5,
            my.UVM6, my.UVM7, my.UVM8, my.UVM9, my.UVM10, my.UVM11, my.UVM12,
            my.YLF_SPLIT
        ]
        # align all mirrors
        for i in range(1, len(looks) - 1):
            optics[looks[i]].set_direction(optics[looks[i - 1]],
                                           optics[looks[i + 1]])

        order = [
            my.UVM1, my.UVM2, my.PS1u, my.PS1d, my.UVM3, my.UVL1, my.UVL2,
            my.UVM4, my.UVM5, my.UVM6, my.UVM7, my.UVM8, my.UVM9, my.DEMAG1,
            my.SERR, my.FILTER, my.DEMAG2, my.UVM10, my.UVM11, my.UVM12,
            my.YLF_SPLIT
        ]

        # specify center and reference as (0,0,0) to make our coordinates absolute
        composite_optic.init(self,
                             "blue line",
                             optics,
                             order, (0, 0, 0), (0, 0, 0),
                             0,
                             extras=extras)
def show_table():
	inch=0.0254
	lambda0=1.054e-6
	spitfire_exit=Numeric.array((2*inch, 5*inch, -0.65))
	compressor_entrance=Numeric.array((45.5*inch, 2.5*inch, 46.5*inch))
	
	optics={}
	BLUELINE='bl'
	SPLIT='split'
	START='start'
	COMP='compressor'
	QUAD='quadrupler'
	IR='ir'
	IR_COMP='ir compressor'
	BE_TURN='be_turn'
	IZ_SCREEN='iz'
	
	optics[START]=null_optic("start", spitfire_exit)
	optics[BLUELINE]=blueline=blue_through_ylf()	
	optics[SPLIT]=split1=reflector("splitter1", center=(2*inch, 5*inch, 3*inch))
	optics[IR]=irline=ir_line()
	
	comp=optics[COMP]=blue_compressor(38.5, 1.28, lambda0, center=compressor_entrance, angle=270)
	mainbeam=beam( spitfire_exit, qtens(lambda0, spitfire.q0), lambda0)
	#print mainbeam.q
	split1.set_direction(spitfire_exit, blueline)
	blueline.set_entrance_direction(split1)
	blueline.set_exit_direction(comp)
	comp.rotate_to_axis(blueline)
	q=optics[QUAD]=quadrupler(center=(40*inch, 2.5*inch, 34.5*inch), from_optic=comp[blue_compressor.TM1])
	comp.set_exit_direction(q)
	q.set_entrance_direction(comp)
	blue_sys=composite_optic("blue_sys", optics, [START, SPLIT, BLUELINE, COMP, QUAD], (0,0,0), (0,0,0), 0)
	irline.set_entrance_direction(spitfire_exit)
	
	#align compressor table to output of main IR line
	ir_sys=composite_optic("ir_sys", optics, [START, IR], (0,0,0), (0,0,0), 0).clone()
	pointer=trace_path(ir_sys, mainbeam.clone())[-1]
	pointer.free_drift(1.0)
	optics[IR_COMP]=ircomp=ir_compressor(center=pointer.x0, angle=math.atan(0.2)/deg)
	ircomp.set_entrance_direction(irline)

	#now, align IZ
	ir_sys=composite_optic("ir_sys", optics, [START, IR, IR_COMP], (0,0,0), (0,0,0), 0).clone()
	pointer=trace_path(ir_sys, mainbeam.clone())[-1]
	pointer.free_drift(1.0)
	bemir=optics[BE_TURN]=reflector("be turn mirror", center=pointer.x0, angle=45.0)
	bemir.transport_to_here(pointer).transform(pointer)
	pointer.free_drift(0.1)
	dz=pointer.q.next_waist()
	pointer.free_drift(dz)
	optics[IZ_SCREEN]=null_optic("IZ", pointer.x0)
	ir_sys=composite_optic("ir_sys", optics, [START, IR, IR_COMP, BE_TURN, IZ_SCREEN], (0,0,0), (0,0,0), 0)
	
	whole_table=composite_optic("whole table", optics, [START, SPLIT, BLUELINE, COMP, QUAD, IR, IR_COMP, BE_TURN, IZ_SCREEN], (0,0,0), (0,0,0), 0)
	
	
	ir_trace=trace_path(ir_sys, mainbeam.clone())
	ir_trace.color=graphite.red
	blue_trace=trace_path(blue_sys, mainbeam.clone())
	blue_trace.color=graphite.blue
	
	if table_layout:
		g=draw_everything({"sys":whole_table}, ir_trace, (-.25,5), (0,2.5), three_d=0)
		draw_trace(g, blue_trace)
		
		#g=draw_everything({"sys":sys}, trace, (0.5,1.1), (0.8,1.1), three_d=0)
		#g=draw_everything({"sys":sys}, trace, (0.7,1.3), (0.9,1.2), three_d=0)
		if show_qd:
			graphite.genOutput(g,'QD',canvasname="Compressor layout", size=(900,500))
		if show_pdf:
			graphite.genOutput(g,'PDF',canvasname="Tablelayout", size=(900,500))
	#print trace[0]
	plotq(blue_trace)
	
	if 0:
		glabel=ircomp.mark_label(ircomp.INPUT)
		m=ir_trace[(glabel,0)]
		print "\n\n**start**\n\n"
		print m.incoming_direction, m.direction()
		print m.incoming_q
		print m.incoming_q.qi_moments()[1:3]
		print m.incoming_q.q_moments()[1:3]
		print m.incoming_q.qit, "\n"
		print m.localize_transform_tensor
		print m.footprint_q
		print m.footprint_q.qi_moments()[1:3]
		print m.footprint_q.q_moments()[1:3]
		print m.footprint_q.qit, "\n"
		print m.globalize_transform_tensor
		print m.q
		print m.q.qi_moments()[1:3]
		print m.q.q_moments()[1:3]
		print m.q.qit, "\n"

	glabel=ircomp.mark_label(ircomp.INPUT)
	#endpoint=ir_trace[(glabel,0)]  #get first hit on optic <glabel>
	endpoint=ir_trace[-1]
	q=endpoint.q
	
	t, qx0, qy0=q.qi_moments()
	theta=math.atan2(t[0,1].real, t[0,0].real)/deg
	qxx, qyy = endpoint.transform_q_to_table(q)
	dzx, dzy = (1e6/qxx).real, (1e6/qyy).real
	print ("qxx = %.1f, dzx = %.0f, qyy=%.1f, dzy=%.0f, (in um), theta=%.1f deg" % 
			(q.rw(qxx)[1]*1e6, dzx, q.rw(qyy)[1]*1e6, dzy, theta ) )
def doit_bc(theta1, clen, lambda0, drawit=0):
	
	print "\n\n***start blue line trace***\n"
	grating_offset=-0.075
	exit_height=0
	exit_z=-0.3
	eta1=0.0
	
	optics={}
	
	END='end'
	optics[END]=null_optic("end", (0.15,exit_height,0), 0)
	START='start'
	optics[START]=null_optic("start", (0,0,-0.85))

	
	tracebeam=basebeam.clone()
	system_center=Numeric.array((-0.1, 0, -0.85))
	
	basebeam=beam(system_center, qtens(lambda0, q=spitfire.q0), lambda0)
	tracebeam.free_drift(-0.2)
		
	COMP='comp'
	comp=optics[COMP]=blue_compressor(theta1, clen, lambda0, center=system_center, angle=rotation)
	TM2='turn2'
	optics[TM2]=reflector("output turn 2", angle=0, center=(0.15,exit_height,-0.6), width=.025)

	optics[COMP].set_exit_direction(optics[TM2])
	optics[TM2].set_direction(optics[COMP], optics[END])

	sys_order=(START, COMP, TM2, DEMAG1, DEMAG2, END)

	GRATE=comp.mark_label(blue_compressor.GRATE)
	IR1=comp.mark_label(blue_compressor.IR1)
	IR2=comp.mark_label(blue_compressor.IR2)
	
	optic_sys=composite_optic("system", optics, sys_order, center=optics[START].center)
	
	trace0=trace_path(optic_sys, tracebeam.shift_lambda(0))
	trace0.color=graphite.green
	trace1=trace_path(optic_sys, tracebeam.shift_lambda(-0.5e-9))
	trace1.color=graphite.blue
	trace2=trace_path(optic_sys, tracebeam.shift_lambda(+0.5e-9))
	trace2.color=graphite.red
			
	try: #if one of the traces failed, this may not work
		print "Theta1=%.3f eta=%.3f len=%.3f lambda=%.4f" % (theta1, eta1, clen, lambda0*1e6)
		d0=trace0[-1]['total_drift']
		d1=trace1[-1]['total_drift']
		d2=trace2[-1]['total_drift']
		print ("d(lambda0-0.5nm)=%.3f m, d(lambda0+0.5nm)=%.3f m, dt/dl=%.0f ps/nm, " % (d1, d2, (d2-d1)*1e12/clight)), 
		print "d2t/dl2 = %.2f ps/nm^2" % ((d2+d1-2.0*d0)*(1e12/clight)*4)
		spot1info=trace0[(GRATE,0)] 
		spot2info=trace0[(GRATE,1)] 
		ir1info=trace0[(IR1,0)]
		ir2info=trace0[(IR2,0)]
		spot_offset=spot2info['position']-spot1info['position']
		retro_offset=ir2info['position']-ir1info['position']
		print "Grating offset = %.3f, retro_offset=%.3f" % (vec_mag(spot_offset), vec_mag(retro_offset))
		print "measured vertex length = %.3f" % vec_mag(comp[GRATE].center-comp[IR1].center)
		print "dispersion offset on grating = %.3f m / nm" % vec_mag(trace2[(GRATE,1)]['position']-trace1[(GRATE,1)]['position'])
		print "final q = ", trace0[-1]['q']
	except:
		traceback.print_exc()
		pass
				
	if drawit:
		g=draw_everything({"sys":optic_sys}, trace0, (-.9, .1), (-.5, .5), three_d=0)
		#g=draw_everything(optics, trace0, (-2, 2), (-2, 2))
		draw_trace(g, trace1)
		draw_trace(g, trace2)
		graphite.genOutput(g,'QD',canvasname="Compressor layout", size=(600,500))
	def __init__(self, **extras):
		inch=0.0254
		entrance_y=5.0*inch
		exit_y=13.5*inch
		my=ir_line
		optics={}
		
		#first, list all mirrors, and point them at each other
		optics[my.M1]=mir("M1", (2*inch, entrance_y, 10*inch))
		optics[my.M2]=mir("M2", (4*inch, entrance_y, 10*inch))
		optics[my.TrM1]=mir("TrM1", (4*inch, entrance_y, 96*inch))
		optics[my.TrM2]=mir("TrM2", (6*inch, entrance_y, 96*inch))
		optics[my.TrM3]=mir("TrM3", (6*inch, entrance_y, 82.5*inch))
		optics[my.TrM4]=mir("TrM4", (2*inch, entrance_y, 82.5*inch))
		optics[my.M3]=mir("M3", (4*inch, entrance_y, 135*inch))
		optics[my.M4]=mir("M4", (12*inch, entrance_y, 135*inch))
		optics[my.M5]=mir("M5", (13*inch, entrance_y, 105*inch))
		optics[my.M6]=mir("M6", (14*inch, entrance_y, 105*inch))
		optics[my.M7]=mir("M7", (16.5*inch, entrance_y, 3*inch))
		optics[my.M8]=mir("M8", (24*inch, entrance_y, 3*inch))
		optics[my.M9]=mir("M9", (23*inch, entrance_y, 135*inch))
		optics[my.M10]=mir("M10", (33*inch, entrance_y, 134.5*inch))
		optics[my.M11]=mir("M11", (33*inch, entrance_y, -6*inch))
		optics[my.BP4]=PL_brewster_filter("BP4", (33*inch, entrance_y, 27*inch), reversed=1)
		optics[my.M12]=mir("M12", (20*inch, entrance_y, 33*inch))
		optics[my.M13]=mir("M13", (20*inch, entrance_y, 12*inch))
		optics[my.M14]=mir("M14", (8.5*inch, entrance_y, 11.5*inch))
		optics[my.M15]=mir("M15", (8.5*inch, exit_y, 11.5*inch))
		
		optics[my.EXIT]=sys_exit=null_optic("exit", (10.0*inch, exit_y, 142.0*inch))
				
		optics[my.L1]=lens("L1", f=+0.400).place_between(optics[my.M2], optics[my.TrM1], 12.0*inch)
		optics[my.L2]=lens("L2", f=+0.800).place_between(optics[my.L1], optics[my.TrM1], 1.30)
		optics[my.L3]=lens("L3", f=+0.750).place_between(optics[my.M6], optics[my.M7], 10*inch)
		optics[my.L4]=lens("L4", f=+1.500).place_between(optics[my.L3], optics[my.M7], 2.25)
		optics[my.L5]=lens("L5", f=+0.750).place_between(optics[my.M10], optics[my.M11], 5*inch)
		optics[my.L6]=lens("L6", f=+1.500).place_between(optics[my.L5], optics[my.M11], 95.5*inch)
		optics[my.L7]=lens("L7", f=+0.750).place_between(optics[my.M15], sys_exit, 4.5*inch)
		optics[my.L8]=lens("L8", f=+2.500, width=6*inch, thickness=0.25*inch).\
			place_between(optics[my.M15], sys_exit, -1*inch).tilt_off_axis((0,45,0))
		
		optics[my.G9a]=laser_head("9mm-1", width=2.0*inch, thickness=6.0*inch, rodsize=0.009).\
			place_between(optics[my.M4], optics[my.M5], 9*inch)
		optics[my.G9b]=laser_head("9mm-2", width=2.0*inch, thickness=6.0*inch, rodsize=0.009).\
			place_between(optics[my.M4], optics[my.M5], 23*inch)
		
		optics[my.G25a]=laser_head("25mm-1", width=6.0*inch, thickness=12.0*inch, rodsize=0.025).\
			place_between(optics[my.M8], optics[my.M9], 74*inch)
		optics[my.G25b]=laser_head("25mm-2", width=6.0*inch, thickness=12.0*inch, rodsize=0.025).\
			place_between(optics[my.M8], optics[my.M9], 94*inch)

		optics[my.G50]=laser_head("50mm", width=9.0*inch, thickness=15.0*inch, rodsize=0.050).\
			place_between(optics[my.M10], optics[my.M11], -19*inch)

		optics[my.SERR1]=serrated_aperture("serrated aperture", diameter=0.003).\
			place_between(optics[my.M2], optics[my.TrM1], 10*inch)		
		optics[my.SF1]=plain_aperture("spatial filter 1", diameter=0.001).\
			place_between(optics[my.M2], optics[my.TrM1], 35*inch)
		
		optics[my.QR1]=halfwave_plate("QR1", width=1*inch, thickness=0.5*inch).\
			place_between(optics[my.G9a], optics[my.G9b], 8*inch).rotate_axis(22.5)	
		optics[my.FR12]=faraday_rotator("FR12", width=0.5*inch, thickness=6*inch, rotation=45).\
			place_between(optics[my.M6], optics[my.M7], 5*inch)
		optics[my.VSF1]=vacuum_spatial_filter("VSF1", thickness=24*inch, width=2*inch).\
			place_between(optics[my.L3], optics[my.L4], 0.750)
			
		optics[my.QR2]=halfwave_plate("QR2", width=1*inch, thickness=0.5*inch).\
			place_between(optics[my.G25a], optics[my.G25b], 8*inch).rotate_axis(22.5)	

		optics[my.BP2]=PL_brewster_filter("BP2", transmit=1).\
			place_between(optics[my.G25b], optics[my.M9], 13*inch).rotate_axis(90)
		optics[my.QR3]=halfwave_plate("QR3", width=1*inch, thickness=0.5*inch).\
			place_between(optics[my.G25b], optics[my.M9], 19*inch).rotate_axis(22.5)	
		optics[my.FR25]=faraday_rotator("FR25", width=1.0*inch, thickness=6.0*inch, rotation=45).\
			place_between(optics[my.G25b], optics[my.M9], 23*inch)
		optics[my.BP3]=PL_brewster_filter("BP3", transmit=1).\
			place_between(optics[my.G25b], optics[my.M9], 30*inch).rotate_axis(0)
		
		looks=[my.M1, my.M2, my.TrM1, my.TrM2, my.TrM3, my.TrM4, my.M3, my.M4, my.M5,
			my.M6, my.M7, my.M8, my.M9, 
			my.M10, my.M11, my.BP4, my.M12, my.M13, my.M14, my.M15, my.EXIT]
		#align all mirrors
		for i in range(1, len(looks)-1):
			optics[looks[i]].set_direction(optics[looks[i-1]], optics[looks[i+1]])

		order=[my.M1, my.M2, my.SERR1, my.L1, my.SF1, my.L2, my.TrM1, my.TrM2, my.TrM3, my.TrM4, my.M3, my.M4, my.G9a, 
			my.QR1, my.G9b, my.M5,
			my.M6, my.FR12, my.L3, my.VSF1, my.L4, my.M7, my.M8, my.G25a, my.QR2, my.G25b, 
			my.BP2, my.QR3, my.FR25, my.BP3, 
			my.M9, my.M10, my.L5, my.L6, my.G50, my.M11, my.BP4, my.M12, 
			my.M13, my.M14, my.M15, my.L7, my.L8]
		
		#specify center and reference as (0,0,0) to make our coordinates absolute
		composite_optic.init(self, "IR line", optics, order, (0,0,0), (0,0,0), 0, extras=extras )