コード例 #1
0
def main():

    lens = DataBaseMatrix("Tessar-100")  # get a lens from the database
    lens.setFocalLength(80.0)  # Set the focal length to 80mm
    lens.setInputPlane(120)

    #               Get system parameters
    mag = getFloat("Magnification", -2)
    ysize = getFloat("Height of Object plane", 20.0)

    #               Mage a pair of io / outplut place
    op, ip = lens.planePair(ysize, mag)
    tprint("Object plane at ; " + str(op.inputPlane()))
    tprint("Image plane at ; " + str(ip.inputPlane()))

    #               make a stsrem that conatins planes and lens in ordedr

    #                Maake a source bema from lower edge of object plane
    pencil = RayPencil().addSourceParaxialBeam(lens, -ysize,
                                               op).addMonitor(RayPath())
    #                Portagate throgh system
    pencil *= lens
    pencil *= ip

    #                Draw out the sytsem
    op.draw()
    lens.draw(True)  # Add a legend box
    ip.draw()
    pencil.draw()
    plt.axis("equal")
    plt.show()
コード例 #2
0
ファイル: Ptube.py プロジェクト: will-hossack/Poptics
def main():

    spectrum = PlanckSpectrum(3500)
    fw = tio.getFloat("Filter cutoff", 0.5)
    vl = tio.getFloat("Bias Voltage start", 0.3)
    vh = tio.getFloat("Bias Voltage end", 1.5)
    filter = LongPassFilter(fw)
    spectrum.addFilter(filter)
    photo = PhotoTube(1.6)
    photo.setSpectrum(spectrum)
    photo.setVoltage((vh + vl) / 2)
    plt.subplot(2, 2, 1)
    spectrum.draw()
    plt.subplot(2, 2, 2)
    photo.stack.draw()
    plt.subplot(2, 2, 3)
    photo.draw()

    volt = np.linspace(vl, vh)
    outdata = photo.getArrayOutputs(volt)

    plt.subplot(2, 2, 4)
    plt.plot(volt, outdata)
    #photo.draw()
    plt.show()
コード例 #3
0
ファイル: FilterTest.py プロジェクト: will-hossack/Poptics
def main():


    wl = tio.getFloat("Long Cut off",0.4)
    ws = tio.getFloat("Short Cut off",0.5)
    dw = tio.getFloat("dw",0.01)



    short = wave.ShortPassFilter(ws,dw)
    long = wave.LongPassFilter(wl,dw)
    stack = wave.FilterStack(short,long)


    tio.tprint(long.getValue(wl + dw/2),"   ", long.getValue(wl - dw/2))
    tio.tprint(short.getValue(ws + dw/2),"   ", short.getValue(ws - dw/2))


    notch = wave.NotchFilter(0.5)

    spectrum = wave.Spectrum()
    spectrum.addFilter(notch)
    spectrum.draw()



    plt.show()
コード例 #4
0
def main():

    prism = Prism()  # Default prism

    ia = math.radians(t.getFloat("Input angle"))
    oa = math.radians(t.getFloat("Output Angle"))

    w = prism.getWavelength(ia, oa)
    print("Wavelength from function " + str(w))
コード例 #5
0
ファイル: SelTest.py プロジェクト: will-hossack/Poptics
def main():

    l0 = getFloat("Lambda_0", 0.08)
    beta = getFloat("Beta", 1.25)
    index = w.Sellmeier(beta, l0)

    nd = index.getNd()
    vd = index.getVd()
    tprint("Nd index : ", nd, " Abbe No: ", vd)

    index.draw()
    plt.show()
コード例 #6
0
ファイル: KnifeTest.py プロジェクト: will-hossack/Poptics
def main():

    #         Get the lens from database
    lens = DataBaseLens()
    angle = math.radians(getFloat("Ray Angle in degrees"))
    opt = getInt("Focal Option", 1)
    kangle = math.radians(getFloat("Knife angle in degrees", 0.0))
    kt = KnifeTest(lens, angle, opt)
    knife = getFloat("Knife", 0.0)
    kt.setKnife(knife, kangle)
    kt.getImage().draw()
    plt.show()
コード例 #7
0
def main():

    # Get lens and other info

    lens = DataBaseLens()
    angle = math.radians(getFloat("Angle in degrees"))
    wave = getFloat("Wavelength of plot",getDefaultWavelength())

    wa = WaveFrontAnalysis(lens)
    wa.drawAberrationPlot(angle,wavelength=wave,legend = "lower left")


    plt.show()
コード例 #8
0
def main():

    #      Get the red, green, blue relative peak values
    red = getFloat("Red Intensity ", 1.0)
    green = getFloat("Greeen Intensity", 1.0)
    blue = getFloat("Blue Intensity", 1.0)

    #       Get spectrum with specified values and default brightness and peak width.
    s = TriColourSpectrum(red, green, blue)
    print(repr(s))

    #        Default plot
    s.draw()
    plt.title(repr(s))
    plt.show()
コード例 #9
0
def main():
    #       Read the wavefront in from a .wf file and display it contents
    wave = WaveFront().fromFile()
    #wave.setMask(AnnularMask(wave.radius,0.7))    # Uncomment for annual mask

    tprint(repr(wave))

    #       Get the tilts
    xt = getFloat("Xtilt", 0.0)
    yt = getFloat("Ytilt", 0.0)

    #       Make the interferometed
    inter = Interferometer(wave)
    inter.setTilt(xt, yt)  # Set the tilts
    inter.draw()  # Display
    plt.show()
コード例 #10
0
def main():

        lens = Eye()
        iris = getFloat("Iris",1.0)
        lens.setIris(iris)

        u = getUnit3d("Direction",0.0)

        vpencil = RayPencil().addBeam(lens,u,key="vl").addMonitor(RayPath())
        spencil = RayPencil().addBeam(lens,u,key="array")


        vpencil *= lens
        spencil *= lens
        plane = lens.getRetina()

        ps = Psf().setWithRays(spencil,plane)
        tprint("PSF is",repr(ps))

        plt.subplot(2,1,1)
        lens.draw()
        vpencil.draw()
        plt.axis("equal")

        plt.subplot(2,1,2)
        spot = SpotDiagram(spencil)
        spot.draw(plane,True)

        plt.show()
コード例 #11
0
ファイル: MinDeviation.py プロジェクト: will-hossack/Poptics
def main():

    #         Get name of index and make a default sprectometer with 60 degreee prism
    glassname = getString("Glass type",default = "BK7")
    prism = PrismSpectrometer(index = glassname)
    tprint(repr(prism))         # Show details of spectrometer

    #        Get a wavelngth, calculate min deviation and display it
    while True:
        wavelength = getFloat("Wavelength in um",min = 0.35,max = 1.0)
        mindeviation = math.degrees(prism.minDeviation(wavelength))
        tprint("Minimum deviation for {0:5.3f} um is : {1:7.4f} degrees".format(wavelength,mindeviation))
コード例 #12
0
ファイル: SpotDiagram.py プロジェクト: will-hossack/Poptics
def main():

    #      Get lens from database
    lens = DataBaseLens()

    #           Get angle of beam and wavelnegth
    angle = getFloat("Angle in degrees", 0.0, 0.0, 15.0)
    u = Unit3d(Angle().setDegrees(angle))  # Angle as unit vectr
    w = getFloat("Wavelength", Default)

    #    Make two ray pencils, one for spot diagram and one for display (vertical only)
    pencil = RayPencil().addBeam(lens, u, "array", wavelength=w)
    vpencil = RayPencil().addBeam(lens, u, "vl",
                                  wavelength=w).addMonitor(RayPath())
    bf = lens.backFocalPlane()

    #            Propagate through lens to back focal plane
    pencil *= lens

    vpencil *= lens
    vpencil *= bf

    #            Get optimal area psf and create a SpotDiagram
    sd = SpotDiagram(pencil)

    #             Go round loop plotting the sopt diagram as various zplane positions

    while True:
        zp = getFloat("Zplane", bf.getPoint().z)
        plane = OpticalPlane(zp)
        plt.subplot(2, 1, 1)
        lens.draw()
        vpencil.draw()
        plt.axis("equal")
        plt.title("Lens " + lens.title)

        plt.subplot(2, 1, 2)
        sd.draw(plane, True)
        plt.title("Spot diagram")
        plt.show(block=True)
コード例 #13
0
def main():

    #      Get lens from database
    lens = DataBaseLens()

    #           Get angle of beam and wavelnegth
    angle = getFloat("Angle in degrees", 0.0, 0.0, 15.0)
    u = Unit3d(Angle().setDegrees(angle))  # Angle as unit vectr
    wave = getFloat("Wavelength", getDefaultWavelength())

    #            Get optimal area psf and create a SpotDiagram
    sd = SpotAnalysis(lens, u, 0, wavelength=wave)

    #             Go round loop plotting the sopt diagram as various zplane positions

    while True:
        zp = getFloat("Delta", 0.0)

        sd.draw(zp, True)
        pos = sd.plane.getPoint().z
        print("Plane pos " + str(pos))
        plt.title("Spot diagram")
        plt.show(block=True)
コード例 #14
0
def main():

    #      First set up prism
    n = MaterialIndex()                   # get materail, angle and height
    prismAngle = getFloat("Prism angle in degrees",60.0)
    prismHeight =getFloat("Height of prism in mm",100.0)
    beam =getFloat("Beam Radius in mm",10.0)

    #       Set up spectrometer
    prism = PrismSpectrometer(0.0,prismAngle,prismHeight,n,beam)
    tprint(repr(prism))

    #        Get the setup wavelength (set prsm at min deviation)
    setupWavelength = getFloat("Set up wavelength",Mercury_e)
    prism.setUpWavelength(setupWavelength)

    #         Print out details
    deviation = prism.minDeviation()
    tprint("Min deviation : {0:6.4f} at : {1:6.4f}".format(math.degrees(deviation),setupWavelength))
    tprint("Max resolutions is : {0:7.3f}".format(prism.maxResolution(setupWavelength)))
    tprint("Resolution with specified beam : {0:7.3f}".format(prism.resolution()))

    #          Get the wavelengths and intensities of the spcetrum
    fileName = getFilename("Wavelength file","csv")
    wavelengths,intensities = readCSV(fileName)

    #        Give option for matplotplot or save to CSV

    if getBool("Display Graph",True):
        prism.plotSpectrum(wavelengths, intensities)
        plt.show()
    else:
        fieldAngle,spectrum = prism.getIntensitySpectum(wavelengths,intensities)
        fileName = getFilename("Output file","csv")
        n = writeCSV(fileName,[fieldAngle,spectrum])
        tprint("No of lines written: ",n)
コード例 #15
0
def main():

    theta = math.radians(getFloat("Polariser angle", 30.0))

    #       Make right circular beam
    beam = j.RightCircularPolarisedBeam()
    print(repr(beam))

    #       Make linear polarsier as specified angle
    polar = j.LinearPolariser(theta)

    #       Pass beam through polarsied and do a polarplot
    beam *= polar
    print(repr(beam))
    beam.polarPlot()

    plt.show()
コード例 #16
0
ファイル: SpotAnimate.py プロジェクト: will-hossack/Poptics
def main():

    #      Get lens from database
    lens = DataBaseLens()

    #           Get angle of beam and wavelnegth
    u = getUnit3d("Direction", 0.0)
    w = getFloat("Wavelength", Default)

    #    Make a ray through lens
    pencil = RayPencil().addBeam(lens, u, "array", wavelength=w)
    pencil *= lens  # Propagate through lens

    sd = SpotAnimation(pencil)

    #             Go round loop plotting the sopt diagram as various zplane positions
    bf = lens.backFocalPlane()  # Back focal plane
    sd.run(bf)  #1.0,0.1,400)
コード例 #17
0
def main():

    res = w.Sodium_D / (w.Sodium_D2 - w.Sodium_D1)
    tio.tprint("Resolution target for Na Doublet is : ", res)

    index = w.MaterialIndex()
    tio.tprint(repr(index))
    tio.tprint("Nd index : ", index.getNd(), " Abbe No: ", index.getVd())

    dn = index.getDerivative(w.Sodium_D)
    tio.tprint("dn / d :", dn)
    d = tio.getFloat("d in mm")
    d *= 1000
    pr = d * dn

    tio.tprint("Prism resolution  : ", pr)

    if abs(pr) > abs(res):
        tio.tprint("Doublet resolved")
    else:
        tio.tprint("Doublet not resolved")