Ejemplo n.º 1
0
def create_thinlens(power=0., indx=1.5, sd=None, **kwargs):
    tl = thinlens.ThinLens(power=power, ref_index=indx, max_ap=sd, **kwargs)
    tle = ThinElement(tl)
    tree = tle.tree()
    return [[tl, None, None, 1, +1]], [tle], tree
Ejemplo n.º 2
0
def handle_types_and_params(optm, cur, cmd, inputs):
    global _track_contents
    if cmd == "TYPE":
        ifc = optm.seq_model.ifcs[cur]
        typ = inputs.split()[0]
        # useful to remember the Type of Zemax surface
        ifc.z_type = typ
        _track_contents[typ] += 1
        if typ == 'EVENASPH':
            cur_profile = ifc.profile
            new_profile = profiles.mutate_profile(cur_profile,
                                                  'EvenPolynomial')
            ifc.profile = new_profile
        elif typ == 'TOROIDAL':
            cur_profile = ifc.profile
            new_profile = profiles.mutate_profile(cur_profile, 'YToroid')
            ifc.profile = new_profile
        elif typ == 'COORDBRK':
            ifc.decenter = DecenterData(dec.LOCAL)
        elif typ == 'PARAXIAL':
            ifc = thinlens.ThinLens()
            ifc.z_type = typ
            optm.seq_model.ifcs[cur] = ifc
    elif cmd == "CONI":
        _track_contents["CONI"] += 1
        ifc = optm.seq_model.ifcs[cur]
        cur_profile = ifc.profile
        if not hasattr(cur_profile, 'cc'):
            ifc.profile = profiles.mutate_profile(cur_profile, 'Conic')
        ifc.profile.cc = float(inputs.split()[0])
    elif cmd == "PARM":
        ifc = optm.seq_model.ifcs[cur]
        i, param_val = inputs.split()
        i = int(i)
        param_val = float(param_val)
        if ifc.z_type == 'COORDBRK':
            if i == 1:
                ifc.decenter.dec[0] = param_val
            elif i == 2:
                ifc.decenter.dec[1] = param_val
            elif i == 3:
                ifc.decenter.euler[0] = param_val
            elif i == 4:
                ifc.decenter.euler[1] = param_val
            elif i == 5:
                ifc.decenter.euler[2] = param_val
            elif i == 6:
                if param_val != 0:
                    ifc.decenter.self.dtype = dec.REV
            ifc.decenter.update()
        elif ifc.z_type == 'EVENASPH':
            ifc.profile.coefs.append(param_val)
        elif ifc.z_type == 'PARAXIAL':
            if i == 1:
                ifc.optical_power = 1 / param_val
        elif ifc.z_type == 'TOROIDAL':
            if i == 1:
                ifc.profile.rR = param_val
            elif i > 1:
                ifc.profile.coefs.append(param_val)
    else:
        return False
    return True
Ejemplo n.º 3
0
def handle_types_and_params(optm, cur, cmd, inputs):
    global _track_contents
    if cmd == "TYPE":
        ifc = optm.seq_model.ifcs[cur]
        typ = inputs.split()[0]
        # useful to remember the Type of Zemax surface
        ifc.z_type = typ
        _track_contents[typ] += 1
        if typ == 'EVENASPH':
            cur_profile = ifc.profile
            new_profile = profiles.mutate_profile(cur_profile,
                                                  'EvenPolynomial')
            ifc.profile = new_profile
        elif typ == 'TOROIDAL':
            cur_profile = ifc.profile
            new_profile = profiles.mutate_profile(cur_profile,
                                                  'YToroid')
            ifc.profile = new_profile
        elif typ == 'XOSPHERE':
            cur_profile = ifc.profile
            new_profile = profiles.mutate_profile(cur_profile,
                                                  'RadialPolynomial')
            ifc.profile = new_profile
        elif typ == 'COORDBRK':
            ifc.decenter = DecenterData('decenter')
        elif typ == 'PARAXIAL':
            ifc = thinlens.ThinLens()
            ifc.z_type = typ
            optm.seq_model.ifcs[cur] = ifc
    elif cmd == "CONI":
        _track_contents["CONI"] += 1
        ifc = optm.seq_model.ifcs[cur]
        cur_profile = ifc.profile
        if not hasattr(cur_profile, 'cc'):
            ifc.profile = profiles.mutate_profile(cur_profile, 'Conic')
        ifc.profile.cc = float(inputs.split()[0])
    elif cmd == "PARM":
        ifc = optm.seq_model.ifcs[cur]
        i, param_val = inputs.split()
        i = int(i)
        param_val = float(param_val)
        if ifc.z_type == 'COORDBRK':
            if i == 1:
                ifc.decenter.dec[0] = param_val
            elif i == 2:
                ifc.decenter.dec[1] = param_val
            elif i == 3:
                ifc.decenter.euler[0] = param_val
            elif i == 4:
                ifc.decenter.euler[1] = param_val
            elif i == 5:
                ifc.decenter.euler[2] = param_val
            elif i == 6:
                if param_val != 0:
                    ifc.decenter.self.dtype = 'reverse'
            ifc.decenter.update()
        elif ifc.z_type == 'EVENASPH':
            ifc.profile.coefs.append(param_val)
        elif ifc.z_type == 'PARAXIAL':
            if i == 1:
                ifc.optical_power = 1/param_val
        elif ifc.z_type == 'TOROIDAL':
            if i == 1:
                ifc.profile.rR = param_val
            elif i > 1:
                ifc.profile.coefs.append(param_val)
    elif cmd == "XDAT":
        ifc = optm.seq_model.ifcs[cur]
        inputs = inputs.split()
        i = int(inputs[0])
        param_val = float(inputs[1])
        if ifc.z_type == 'XOSPHERE':
            if i == 1:
                num_terms = param_val
                ifc.profile.coefs = []
            elif i == 2:
                normalizing_radius = param_val
                if normalizing_radius != 1.0:
                    logging.info('Normalizing radius not supported on extended surfaces')
            elif i >= 3:
                ifc.profile.coefs.append(param_val)
    else:
        return False
    return True