Ejemplo n.º 1
0
def update_surface_and_gap(opt_model, dlist, idx=None):
    global _glass_handler
    seq_model = opt_model.seq_model
    s, g = seq_model.insert_surface_and_gap()

    if opt_model.radius_mode:
        if dlist[0] != 0.0:
            s.profile.cv = 1.0 / dlist[0]
        else:
            s.profile.cv = 0.0
    else:
        s.profile.cv = dlist[0]

    if g:
        g.thi = dlist[1]

        if len(dlist) < 3:
            g.medium = Air()
        else:
            if dlist[2].upper() == 'REFL':
                s.interact_mode = 'reflect'
                g.medium = seq_model.gaps[seq_model.cur_surface - 1].medium
            else:
                g.medium = _glass_handler.process_glass_data(dlist[2])

    else:
        # at image surface, apply defocus to previous thickness
        seq_model.gaps[idx - 1].thi += dlist[1]
Ejemplo n.º 2
0
def process_glass_data(glass_data):
    """ process GLA string for fictitious, catalog or private catalog glass """
    if isanumber(glass_data):  # process as fictitious glass code
        n, v = fictitious_glass_decode(float(glass_data))
        medium = Glass(n, v, '')

    else:  # look for glass name and optional catalog
        name_cat = glass_data.split('_')
        if len(name_cat) == 2:
            name, cat = name_cat
        elif len(name_cat) == 1:
            name, cat = glass_data, None
        if cat is not None:
            if cat.upper() == 'SCHOTT' and name[:1].upper() == 'N':
                name = name[:1] + '-' + name[1:]
            elif cat.upper() == 'OHARA' and name[:1].upper() == 'S':
                name = name[:1] + '-' + name[1:]
                if not name[-2:].isdigit() and name[-1].isdigit():
                    name = name[:-1] + ' ' + name[-1]
            try:
                medium = gfact.create_glass(name, cat)
            except glasserror.GlassNotFoundError as gerr:
                logging.info('%s glass data type %s not found', gerr.catalog,
                             gerr.name)
                logging.info('Replacing material with air.')
                medium = Air()
        else:  # name with no data. default to crown glass
            global _private_catalog_glasses
            if name in _private_catalog_glasses:
                medium = _private_catalog_glasses[name]
            else:
                medium = Glass(1.5, 60.0, name)
    return medium