Пример #1
0
def create_surface_and_gap(surf_data,
                           radius_mode=False,
                           prev_medium=None,
                           wvl=550.0,
                           **kwargs):
    """ create a surface and gap where surf_data is a list that contains:
        [curvature, thickness, refractive_index, v-number] """
    s = surface.Surface()

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

    if len(surf_data) > 2:
        if isanumber(surf_data[2]):  # assume all args are numeric
            if len(surf_data) < 3:
                if surf_data[2] == 1.0:
                    mat = m.Air()
                else:
                    mat = m.Medium(surf_data[2])
            else:
                mat = m.Glass(surf_data[2], surf_data[3], '')

        else:  # string args
            if surf_data[2].upper() == 'REFL':
                s.interact_mode = 'reflect'
                mat = prev_medium
            else:
                num_args = len(surf_data[2:])
                if num_args == 2:
                    name, cat = surf_data[2], surf_data[3]
                else:
                    name, cat = surf_data[2].split(',')

                try:
                    mat = gfact.create_glass(name, cat)
                except ge.GlassNotFoundError as gerr:
                    logging.info('%s glass data type %s not found',
                                 gerr.catalog, gerr.name)
                    logging.info('Replacing material with air.')
                    mat = m.Air()

    else:  # only curvature and thickness entered, set material to air
        mat = m.Air()

    thi = surf_data[1]
    g = gap.Gap(thi, mat)
    rndx = mat.rindex(wvl)
    tfrm = np.identity(3), np.array([0., 0., thi])

    return s, g, rndx, tfrm
Пример #2
0
    def _initialize_arrays(self):
        """ initialize object and image interfaces and intervening gap """
        # add object interface
        self.ifcs.append(surface.Surface('Obj'))

        tfrm = np.identity(3), np.array([0., 0., 0.])
        self.gbl_tfrms.append(tfrm)
        self.lcl_tfrms.append(tfrm)

        # add object gap
        self.gaps.append(gap.Gap())
        self.z_dir.append(1)
        self.rndx.append([1.0])

        # add image interface
        self.ifcs.append(surface.Surface('Img'))
        self.gbl_tfrms.append(tfrm)
        self.lcl_tfrms.append(tfrm)
        self.z_dir.append(1)
        self.rndx.append([1.0])
Пример #3
0
 def insert_surface_and_gap(self):
     s = surface.Surface()
     g = gap.Gap()
     self.insert(s, g)
     return s, g
Пример #4
0
def create_surface_and_gap(surf_data,
                           radius_mode=False,
                           prev_medium=None,
                           wvl=550.0,
                           **kwargs):
    """ create a surface and gap where `surf_data` is a list that contains:

    [curvature, thickness, refractive_index, v-number, semi-diameter]
    
    The `curvature` entry is interpreted as radius if `radius_mode` is **True**

    The `thickness` is the signed thickness

    The `refractive_index, v-number` entry can have several forms:
        
        - **refractive_index, v-number**
        - **refractive_index** only -> constant index model
        - **'REFL'** -> set interact_mode to 'reflect'
        - **glass_name, catalog_name** as 1 or 2 strings
        - blank -> defaults to air

    The `semi-diameter` entry is optional
    """
    s = surface.Surface()

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

    if len(surf_data) > 2:
        if isanumber(surf_data[2]):  # assume all args are numeric
            if len(surf_data) < 3:
                if surf_data[2] == 1.0:
                    mat = m.Air()
                else:
                    mat = m.Medium(surf_data[2])
            else:
                if surf_data[2] == 1.0:
                    mat = m.Air()
                else:
                    mat = m.Glass(surf_data[2], surf_data[3], '')

        else:  # string args
            if surf_data[2].upper() == 'REFL':
                s.interact_mode = 'reflect'
                mat = prev_medium
            else:
                num_str_args = 0
                for tkn in surf_data[2:]:
                    if isinstance(tkn, str) and len(tkn) > 0:
                        num_str_args += 1
                if num_str_args == 2:
                    name, cat = surf_data[2], surf_data[3]
                elif num_str_args == 1:
                    name, cat = surf_data[2].split(',')
                elif num_str_args == 0:
                    mat = m.Air()

                if num_str_args > 0:
                    try:
                        mat = gfact.create_glass(name, cat)
                    except ge.GlassNotFoundError as gerr:
                        logging.info('%s glass data type %s not found',
                                     gerr.catalog, gerr.name)
                        logging.info('Replacing material with air.')
                        mat = m.Air()

        if len(surf_data) >= 5:
            s.set_max_aperture(surf_data[4])

    else:  # only curvature and thickness entered, set material to air
        mat = m.Air()

    thi = surf_data[1]
    g = gap.Gap(thi, mat)
    rndx = mat.rindex(wvl)
    tfrm = np.identity(3), np.array([0., 0., thi])

    return s, g, rndx, tfrm