Beispiel #1
0
def main():
    
    #        Get lens from database, get iris ration and set it
    lens = l.DataBaseLens()
    ratio = t.getFloat("Aperture Ratio",1.0)
    lens.setIris(ratio)
    
    #         Get angle and wavelength
    angle = math.radians(t.getFloat("Angle",0.0))
    wave = t.getFloat("Wavelength",0.55)
    design = 0.55         # Hard code design wavelength
    
    # set up wavefront analysis
    wa = a.WaveFrontAnalysis(lens,design)
    
    # do a 4th order Zernike fit with Collated lens 
    ze = wa.fitZernike(angle,wave,4,0)
    t.tprint("Reference point is : ",wa.refpt)
    
    t.tprint(repr(ze))

    #    Plot zernike as interfometer plot with tilt of 2 fringes
    inter = a.Interferometer(ze)
    inter.draw()
    plt.show()
def main():
    ps = p.ParticleSystem().readFile(t.openFile("File",defaulttype="part"))
    t.tprint(ps)
    
    delta = 0.025
    x = np.arange(-3.0, 3.0, delta)
    y = np.arange(-2.0, 2.0, delta)
    X, Y = np.meshgrid(x, y)
Beispiel #3
0
def main():
    
    u = v.Unit3d().random()

    vec = v.Vector3d().random(10.0)


    t.tprint("Random vector is : " + str(vec))
Beispiel #4
0
def main():
    
    ps = p.ParticleSystem().readFile(t.openFile("File",defaulttype="part"))
    t.tprint(ps)

    while True:
        pos = t.getVector3d("Position")
        ef = ps.getElectrostaticPotential(pos)
        t.tprint("Field at : ",pos," is : ",ef)
Beispiel #5
0
def main():

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

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

    index.draw()
    plt.show()
def main():
    sides = t.getInt("Number of sides on each dice", 6)
    startsample = t.getInt("Starting Sample", 1000)

    dice = Dice(sides)

    xData = []
    yData = []
    run = 0
    sample = startsample
    while sample > 10:
        #      Store generation and sample size in lists.
        xData.append(run)
        yData.append(sample)
        dice.throw(sample)

        #       Get number of dice with value 1
        n = dice.count()
        sample -= n  # Reduce sample size by that number
        run += 1

    #            Do data fitting
    x = np.array(xData)  # convert x/y data to np arrays.
    y = np.array(yData)
    sig = np.sqrt(y)
    #                Define a 3 parameter line
    #line = lambda x,a,b,c : a*np.exp(-b*x) + c
    #                Do a fit
    popt, pcov = curve_fit(line,
                           x,
                           y,
                           p0=[startsample, 1.0 / sides, 0.0],
                           sigma=sig)
    t.tprint(popt)

    #                Plot data
    plt.plot(x, y, "x")
    plt.title("Decay plot for {0:d} dice with {1:d} sides".format(
        startsample, sides))
    #                Plot the fitted line with 200 points
    xfine = np.linspace(0.0, float(run), 200)
    plt.plot(xfine,
             dline(xfine, popt[0], popt[1], popt[2]),
             "r",
             label="Decay parameter {0:8.4f}".format(popt[1]))
    plt.xlabel("Generation")
    plt.ylabel("Dice Number")
    plt.legend(loc="upper right", fontsize="small")
    plt.show()
def main():
    tl = m.ParaxialThickLens(20,0.015,1.74,15,-0.01,5)
    t.tprint(tl)

    t.tprint("Back focal length : ",tl.backFocalLength())

    ml = m.ParaxialMirror(100,-0.03,10)

    plt.figure(1)
    plt.subplot(2,1,1,axisbg="y")
    tl.draw(legend = True)

    plt.subplot(2,1,2)
    ml.draw()

    plt.show()
Beispiel #8
0
def main():
    ray = r.ParaxialRay(0,math.radians(5),10)
    ray.addMonitor(r.RayPath())
    
    #tio.tprint(repr(ray))
    lens = m.ParaxialThickLens(160,0.01,1.7,20.0,-0.015,radius=20)
    #tio.tprint(lens)
    tio.tprint("Focal length is : " + str(lens.backFocalLength()))
   
    ray *= lens
    #tio.tprint(ray)
    ray += 160
    #tio.tprint(ray)

    lens.draw(legend=True)
    ray.draw()
    plt.show()
def main():


    
    
    l = m.ParaxialThinLens(10,0.01,1.6,-0.015,10)
    t.tprint(l)
    t.tprint("Front Focal Plane : " + str(l.frontFocalPlane()))
    t.tprint("Back focal length : " + str(l.backFocalLength()))
    t.tprint("Front focal length : " + str(l.frontFocalLength()))
Beispiel #10
0
def main():

    xdata = []
    ydata = []

    a = t.getVector3d("Central", [5, 1, 0])
    t.tprint(a)

    for i in range(0, 100):
        x = i / 10.0
        xdata.append(x)
        b = v.Vector3d(x, 0, 0)
        f = a.inverseSquare(b, -1.0)
        t.tprint(f),
        ydata.append(abs(f))

    pt.plot(xdata, ydata)
    pt.show()
Beispiel #11
0
def main():

    s = sur.OpticalPlane(4)
    tio.tprint(repr(s))

    r = ray.IntensityRay([3, 4, 0], math.radians(10))
    tio.tprint(repr(r))

    inter = s.getSurfaceInteraction(r)

    tio.tprint(repr(inter))
Beispiel #12
0
def main():


    s = t.getString("Give a string") 
    t.tprint("Given string was : ",s)

    y = t.getFloat("Give a float",max=100)
    t.tprint("Given value was : ",y)

    i = t.getInt("Give and int",default = 30)
    t.tprint("int value is ",i)

    z = t.getComplex("Give complex",cmath.sqrt(-6))
    t.tprint("Complex value is :",z)


    file = t.openFile("File","w","data","output")
    file.write("Hello\n")
    file.close()
Beispiel #13
0
def main():
    
    s = p.ParticleSystem("system")

    for i in range(10):
        pos = v.Vector3d(i,-i,2*i)
        vel = v.Vector3d(-i,i,2*i)
        part = p.Particle(pos,vel,mass = 2)
        s.append(part)


    t.tprint("Total Kinetic Engery is : " + str(s.getKineticEnergy()))
    t.tprint("Total Linear Momentum is : " + str(s.getLinearMomentum()))
    t.tprint("Centre of mass is : " + str(s.getCentreOfMass()))
Beispiel #14
0
def main():

    # read in csv file and plot
    file = t.openFile("Data", "r", "txt")
    xpos, intensity = csv.readCSV(file)
    peak = (xpos[0] + xpos[-1]) / 2

    t.tprint("Number of data points : ", xpos.size)
    t.tprint("X range is : ", xpos[0], " to ", xpos[-1])

    width = t.getFloat("Slit width", 0.1)
    separ = t.getFloat("Slit seperation", 0.4)
    peak = t.getFloat("Peak", peak)
    pintensity = t.getFloat("Peak Intensity", 1.0)

    # Make a guess od the slits
    slits = FitSlits(separ, width, distance, peak, wave, pintensity, 0.0)

    #     Do a curve fit wit p0 v=being the initial giess
    popt,pcov = curve_fit(slits.line,xpos,intensity,\
                          p0=[slits.separ,slits.width,slits.peak,slits.intensity,slits.offset])
    perr = np.sqrt(np.diag(pcov))
    # print(popt)
    # print(perr)

    #      Print out the results
    t.tprint("Separation: {0:7.5f} +/- {1:7.5}".format(popt[0], perr[0]))
    t.tprint("Slit width: {0:7.5f} +/- {1:7.5}".format(popt[1], perr[1]))
    t.tprint("Peak centre: {0:7.5f} +/- {1:7.5}".format(popt[2], perr[2]))
    t.tprint("Peak intensity: {0:7.5f} +/- {1:7.5}".format(popt[3], perr[3]))
    t.tprint("Offset: {0:7.5f} +/- {1:7.5}".format(popt[4], perr[4]))

    #    Plot outputs
    plt.plot(xpos, intensity, 'o')
    xfine = np.linspace(xpos[0], xpos[-1], 500)  # do a fine plot as comparison
    plt.plot(xfine, slits.getArrayValues(xfine))
    plt.ylim(0.0, slits.intensity)
    plt.title("Fit of Slit Data")
    plt.xlabel("X position")
    plt.ylabel("Intensity")

    plt.show()
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")
Beispiel #16
0
def main():
    file = t.openFile("Particle files",defaulttype = "data")

    system = p.ParticleSystem().readFile(file)

    t.tprint(system)
Beispiel #17
0
def main():
    #
    ps = p.ParticleSystem().readFile(t.openFile("Particles",defaulttype="part"))
    
    t.tprint("Initial Linear Momentum is : ",ps.getLinearMomentum())
    t.tprint("Initial Angular Momnetum is : ",ps.getAngularMomentum())
    t.tprint("Initial Total Energy is : ",ps.getKineticEnergy())

    elastic = t.getBool("Elastic",True)

    if elastic :
        ps[0].elasticCollision(ps[1])
    else:
        ps[0].inelasticCollision(ps[1])

    t.tprint("Left particle: ",ps[0])
    t.tprint("Right particle: ",ps[1])

    t.tprint("Final Liner Momentum is : ",ps.getLinearMomentum())
    t.tprint("Final Angular Momnetum is : ",ps.getAngularMomentum())
    t.tprint("Final Total Energy is : ",ps.getKineticEnergy())
Beispiel #18
0
def main():

   f = tio.openFile("Give file","r","lens")

   for l in f.readlines():
      tio.tprint(l)

   
   z = tio.getComplex("Give complex",complex(1,1))
   tio.tprint("Complex is " + repr(z))

   v = tio.getVector3d("Vector")
   tio.tprint("vector is : " + repr(v))
   
   options = ["start","close","quit","restart"]
   n,nopt = tio.getOption("Option",options)

   tio.tprint("Option {0:d} chosen, name is {1:s}".format(n,nopt))

   x = tio.getFloat("float",3.0,0.0,5.0)
   tio.tprint(x)

   st = tio.getString("and a string")
   tio.tprint(st)
Beispiel #19
0
def main():
    vel = t.getVector3d("Velocity :")
    pos = t.getVector3d("Position :", [0, 0, 0])
    # org = t.getVector3d("Origin :",[0,0,0])

    left = p.Particle(pos, vel, mass=5, title="Left")

    right = p.Particle(pos, -3.0 * vel, mass=10, title="Right")
    t.tprint(left)
    t.tprint(right)

    mom = left.getLinearMomentum() + right.getLinearMomentum()
    k = left.getKineticEnergy() + right.getKineticEnergy()

    t.tprint("Inital linear momentum is : ", mom)
    t.tprint("Initial Energy is : ", k)

    left.elasticCollision(right)

    t.tprint(left)
    t.tprint(right)

    mom = left.getLinearMomentum() + right.getLinearMomentum()
    k = left.getKineticEnergy() + right.getKineticEnergy()

    t.tprint("Final linear momentum is : ", mom)
    t.tprint("Final Energy is : ", k)
Beispiel #20
0
def main():
    d = t.getString("Dir")
    d = t.getExpandedFilename(d)
    for filename in os.listdir(d):
        t.tprint(filename)
Beispiel #21
0
def main():
    a = tio.getVector3d("Give a vector",[1,2,3])
    tio.tprint(repr(a))

    r,u = a.unitPair()

    tio.tprint("Abs is  : ",r," Unit is : ",u)

    u = v.Unit3d(a)
    tio.tprint("Unit vector is " , repr(u))


    ang = v.Angle(u)
    tio.tprint("Angle of u is ", repr(ang))

    ang = v.Angle(a)
    tio.tprint("Angle of a is ", repr(ang))

    w = v.Unit3d(ang)
    tio.tprint("Unit 3d from angle is ",w)

    d = tio.getAngle("Give angle pair",[0.5,0.6])
    tio.tprint(repr(d))
Beispiel #22
0
def main():
    options = ["stop","go","reset","reformat"]
    i,opt = tio.getOption("Which option",options,1)
    tio.tprint("Option chosen was : ",i," being ",opt)