Exemple #1
0
    def assign_object_to_node(self, node, factory):
        """ create a new element from `factory` and replace `node` with it """

        # extract optical properties of node
        n = self.sys[node][indx]
        power = self.sys[node][pwr]
        thi = n * self.sys[node][tau]
        sd = abs(self.ax[node][ht]) + abs(self.pr[node][ht])

        # create an element with the node's properties
        seq, ele = factory(power=power, sd=sd)

        n_before = self.sys[node - 1][indx]
        thi_before = n_before * self.sys[node - 1][tau]
        self.seq_model.gaps[node - 1].thi = thi_before

        # insert the path sequence and elements into the
        #  sequential and element models
        args = seq, ele
        kwargs = dict(idx=node - 1, t=thi)
        insert_ifc_gp_ele(self.opt_model, *args, **kwargs)

        path_stop = node + len(seq)
        inserted_seq = list(self.seq_model.path(start=node - 1,
                                                stop=path_stop))
        sys_seq = self.seq_path_to_paraxial_lens(inserted_seq[1:])
        pp_info = self.compute_principle_points(node, inserted_seq)
        self.replace_node_with_seq(node, sys_seq, pp_info)

        return args, kwargs
Exemple #2
0
def create_new_optical_model_from_specsheet(specsheet):
    """ create an OpticalModel with a basic thinlens model, given specsheet """
    opt_model = OpticalModel(specsheet=specsheet)

    seq_model = opt_model.seq_model

    # enter a basic thinlens model for the given specsheet
    imager = specsheet.imager
    if specsheet.conjugate_type == 'finite':
        opt_model.seq_model.gaps[0].thi = -imager.s
    else:
        opt_model.seq_model.gaps[0].thi = 1.0e10

    insert_ifc_gp_ele(opt_model,
                      *create_thinlens(power=1 / imager.f, indx=1.5),
                      idx=0,
                      t=imager.sp)

    #    insert_ifc_gp_ele(opt_model, *create_mirror(r=-2*efl, cc=-1),
    #                      idx=0, t=-efl)

    opt_model.ele_model.add_dummy_interface_at_image(seq_model,
                                                     seq_model.gbl_tfrms)

    opt_model.update_model()

    return opt_model
Exemple #3
0
def add_reflector(opt_model, idx, lcl_pt, create, **kwargs):
    seq_model = opt_model.seq_model
    g = seq_model.gaps[idx]
    x, y = lcl_pt
    t_new = x - g.thi
    g.thi = x

    insert_ifc_gp_ele(opt_model, *create(**kwargs), idx=idx, t=t_new)
Exemple #4
0
def add_elements(opt_model, idx, lcl_pt, create, **kwargs):
    seq_model = opt_model.seq_model
    g = seq_model.gaps[idx]
    x, y = lcl_pt
    t_new = g.thi - x
    g.thi = x

    insert_ifc_gp_ele(opt_model, *create(**kwargs), idx=idx, t=t_new)
Exemple #5
0
def add_lens(opt_model, idx, lcl_pt, **kwargs):
    seq_model = opt_model.seq_model
    g = seq_model.gaps[idx]
    x, y = lcl_pt
    t0_orig = g.thi
    t_ct = 0.05 * t0_orig
    t0_new = x
    t1_new = t0_orig - t_ct - t0_new
    g.thi = t0_new

    seq, ele = create_lens(th=t_ct)
    insert_ifc_gp_ele(opt_model, seq, ele, idx=idx, t=t1_new)
Exemple #6
0
def create_new_optical_system(efl=10.0, fov=1.0):
    opt_model = OpticalModel()
    seq_model = opt_model.seq_model

    # put in minimum calculation defaults
    opt_model.seq_model.gaps[0].thi = 1.0e10
    opt_model.optical_spec.field_of_view.type = 'OBJ_ANG'
    opt_model.optical_spec.field_of_view.set_from_list([0., fov])

    insert_ifc_gp_ele(opt_model,
                      *create_thinlens(power=1 / efl, indx=1.5),
                      idx=0,
                      t=efl)

    #    insert_ifc_gp_ele(opt_model, *create_mirror(r=-2*efl, cc=-1),
    #                      idx=0, t=-efl)

    opt_model.ele_model.add_dummy_interface_at_image(seq_model,
                                                     seq_model.gbl_tfrms)

    opt_model.update_model()

    return opt_model