import lens, trace, glass, draw


New_Lens = lens.Lens(lens_name='triplet',creator='XF')
New_Lens.lens_info()

New_Lens.add_wavelength(wl = 656.30)
New_Lens.add_wavelength(wl = 546.10)
New_Lens.add_wavelength(wl = 486.10)
New_Lens.list_wavelengths()

New_Lens.add_field(angle=0)
New_Lens.add_field(angle=7)
New_Lens.add_field(angle=10)
New_Lens.list_fields()

New_Lens.add_surface(number=1,radius=10000000,thickness=10,glass='air')
New_Lens.add_surface(number=2,radius=16.87831,thickness=3.250000 ,glass='NSK16_SCHOTT')
New_Lens.add_surface(number=3,radius=247.02634,thickness=4.984142,glass='air')
New_Lens.add_surface(number=4,radius=-35.95718,thickness=1.250000,glass='NF2_SCHOTT',STO=True)
New_Lens.add_surface(number=5,radius=15.88615 ,thickness=6.099225 ,glass='air')
New_Lens.add_surface(number=6,radius=49.08083,thickness=3.250000,glass='NSK16_SCHOTT')
New_Lens.add_surface(number=7,radius=-27.62109,thickness=38.898042,glass='air')
New_Lens.add_surface(number=8,radius=100000000,thickness=0,glass='air')

#trace.trace_sys(New_Lens)
#New_Lens.spotdiagram()
#New_Lens.EFL()
#New_Lens.BFL()
#New_Lens.OAL(2,9)
Beispiel #2
0
import matplotlib.pyplot as plt

import lens
import draw

sample_lens = lens.Lens()
sample_lens.Fno = 1.4
sample_lens.wavelength_list = [587.60, 486.10, 656.30]

sample_lens.add_surface(number=0, radius=10000000000, thickness=1, glass='1')
sample_lens.add_surface(number=1, radius=4.25, thickness=0.7, glass='S-BSM16')
sample_lens.add_surface(number=2, radius=-31.73, thickness=1.2, glass='1')
sample_lens.add_surface(number=3, radius=-4.05, thickness=0.3, glass='S-TIM2')
sample_lens.add_surface(number=4, radius=3.86, thickness=1.2, glass='1')
sample_lens.add_surface(number=5, radius=28.25, thickness=0.7, glass='S-BSM16')
sample_lens.add_surface(number=6, radius=-3.5, thickness=8.59, glass='1')
sample_lens.add_surface(number=7, radius=100000000, thickness=0, glass='1')

sample_lens.paraxial_amount()

x = 0
for i in range(len(sample_lens.surface_list)):
    draw.draw_surf(sample_lens.surface_list[i].radius, 1.8, x)
    x += sample_lens.surface_list[i].thickness
plt.show()
Beispiel #3
0
import lens, trace

New_Lens = lens.Lens(lens_name='singlet', creator='XF')
New_Lens.lens_info()

New_Lens.add_wavelength(wl=500)
New_Lens.list_wavelengths()

New_Lens.add_field(angle=0)
New_Lens.list_fields()

New_Lens.add_surface(number=1, radius=10000000, thickness=10, glass='air')
New_Lens.add_surface(number=2,
                     radius=50,
                     thickness=5,
                     glass='BK7_SCHOTT',
                     STO=True)
New_Lens.add_surface(number=3, radius=1175.71, thickness=96.672, glass='air')
New_Lens.add_surface(number=4, radius=10000000, thickness=0, glass='air')

trace.trace_sys(New_Lens)

New_Lens.spotdiagram()
Beispiel #4
0
    def run(self):

        # initialize LENS object
        l = lens.Lens(self.model_path, self.role, self.sim_search,
                      self.transition_mode, self.lexer_style,
                      self.templates_no_fields)

        if self.role == "client":

            # network client configuration
            connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            connection.connect((self.host, self.port))
            connection.settimeout(self.tout)
            print "[*] Connected to server..."

            # client starts communications
            snd_message = l.transitionSelf()
            print "first client msg: " + str(snd_message[1])
            connection.send(str(snd_message[1]))

            while 1:
                time.sleep(0.3)
                try:
                    rcv_message = connection.recv(self.bsize)
                    print "rcv msg: " + str(rcv_message)
                except socket.timeout:
                    rcv_message = ""
                if rcv_message != "":
                    l.consumeOtherSide(rcv_message)
                snd_message = l.transitionSelf()
                print "snd mesg: " + str(snd_message[1])
                connection.send(str(snd_message[1]))

        elif self.role == "server":

            # network server configuration
            backlog = 1
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.bind((self.host, self.port))
            s.listen(backlog)
            connection, address = s.accept()
            connection.settimeout(self.tout)
            print "[*] Connected to client..."

            while 1:
                time.sleep(0.3)
                try:
                    rcv_message = connection.recv(self.bsize)
                except socket.timeout:
                    print "\n>>> TIMEOUT IN RECEIVE\n"
                    rcv_message = ""
                    if snd_message[1] is None:
                        print ">>> NO TRANSITION POSSIBLE."
                        print ">>> WAITING FOR NEW CONNECTION...\n"
                        connection.close()
                        connection, address = s.accept()
                        connection.settimeout(self.tout)
                        continue
                if rcv_message != "":
                    print "\n>>> CONSUMING RECEIVED \
                            MESSAGE:\n{}".format(rcv_message)
                    l.consumeOtherSide(rcv_message)
                snd_message = l.transitionSelf()
                #            print "snd_message:\n{}".format(snd_message)
                if snd_message[1] is not None:
                    print "\n>>> SENDING MESSAGE:\n{}".format(snd_message[1])
                    connection.send(str(snd_message[1]))

        try:
            connection.close()
        except:
            print "Err: No active connection to close."
            pass
Beispiel #5
0
import lens, trace, glass

New_Lens = lens.Lens(lens_name='doublet', creator='XF')
New_Lens.lens_info()

New_Lens.add_wavelength(wl=656.30)
New_Lens.add_wavelength(wl=546.10)
New_Lens.add_wavelength(wl=486.10)
New_Lens.list_wavelengths()

New_Lens.add_field(angle=0)
New_Lens.add_field(angle=2)
New_Lens.add_field(angle=3)
New_Lens.list_fields()

New_Lens.add_surface(number=1, radius=10000000, thickness=0, glass='air')
New_Lens.add_surface(number=2,
                     radius=61.07222,
                     thickness=10.345634,
                     glass='BSM24_OHARA',
                     STO=True)
New_Lens.add_surface(number=3,
                     radius=-42.17543,
                     thickness=2.351280,
                     glass='SF1_SCHOTT')
New_Lens.add_surface(number=4,
                     radius=-316.13853,
                     thickness=92.451433,
                     glass='air')
New_Lens.add_surface(number=5, radius=10000000, thickness=0, glass='air')
Beispiel #6
0
def readseq(filename, output=False):
    file = open(filename)
    lines = []
    surface_data = []
    lens_dict = {
        'Name': '',
        'EPD': 0,
        'XAN': [],
        'YAN': [],
        'Surface': [],
        'WL': [],
        'FNO': 0,
        'NA': 0
    }
    while 1:
        line = file.readline()
        if not line:
            break
        a = line.split()
        #print a
        lines.append(a)
    count = 0
    for line in lines:
        count = count + 1
        # lens name
        if line[0] == 'TITLE':
            lens_dict['Name'] = ''.join(line[1:])
        # wavelength,EPD,XAN,YAN,FNO,NA
        if line[0] in ['WL', 'EPD', 'XAN', 'YAN', 'FNO', 'NA']:
            lens_dict[line[0]] = str2num(line[1:])
        # surface
        if line[0] in ['SO', 'S', 'SI']:
            if len(line) == 3:
                line.append('')
            surface_data.append(line)
        elif line[0] == 'STO':
            surface_data[-1].append('STO')
    lens_dict['Surface'] = surface_data
    file.close()
    # Generate Lens class
    New_Lens = lens.Lens(lens_name=lens_dict['Name'], creator='XF')

    for w in lens_dict['WL']:
        New_Lens.add_wavelength(wl=w)
    for f in lens_dict['YAN']:
        New_Lens.add_field_YAN(angle=f)
    n = 0
    for s in lens_dict['Surface']:
        n = n + 1
        if float(s[1]) == 0:
            r = 10000000
        else:
            r = float(s[1])
        t = float(s[2])
        if s[3] == '':
            g = 'air'
        else:
            g = s[3]
        if len(s) == 5:
            STOP = True
        else:
            STOP = False
        New_Lens.add_surface(number=n,
                             radius=r,
                             thickness=t,
                             glass=g,
                             STO=STOP,
                             output=output)
    return New_Lens