Esempio n. 1
0
def trace_ray_grid(opt_model,
                   grid_rng,
                   fld,
                   wvl,
                   foc,
                   append_if_none=True,
                   **kwargs):
    """Trace a grid of rays at fld and wvl and return ray_pkgs in 2d list."""
    start = np.array(grid_rng[0])
    stop = grid_rng[1]
    num = grid_rng[2]
    step = np.array((stop - start) / (num - 1))
    grid = []
    for i in range(num):
        grid_row = []

        for j in range(num):
            pupil = np.array(start)
            if (pupil[0]**2 + pupil[1]**2) < 1.0:
                ray_pkg = trace.trace_base(opt_model, pupil, fld, wvl,
                                           **kwargs)
                grid_row.append([pupil[0], pupil[1], ray_pkg])
            else:  # ray outside pupil
                if append_if_none:
                    grid_row.append([pupil[0], pupil[1], None])

            start[1] += step[1]

        grid.append(grid_row)
        start[0] += step[0]
        start[1] = grid_rng[0][1]

    return grid
Esempio n. 2
0
def trace_ray_fan(opt_model, fan_rng, fld, wvl, foc, **kwargs):
    """ xy determines whether x (=0) or y (=1) fan """
    start = np.array(fan_rng[0])
    stop = fan_rng[1]
    num = fan_rng[2]
    step = (stop - start) / (num - 1)
    fan = []
    for r in range(num):
        pupil = np.array(start)
        ray_pkg = trace.trace_base(opt_model, pupil, fld, wvl, **kwargs)
        fan.append([pupil[0], pupil[1], ray_pkg])
        start += step
    return fan
Esempio n. 3
0
def trace_ray_list(opt_model, pupil_coords, fld, wvl, foc,
                   append_if_none=False, **kwargs):
    """Trace a list of rays at fld and wvl and return ray_pkgs in a list."""

    ray_list = []
    for pupil in pupil_coords:
        if (pupil[0]**2 + pupil[1]**2) < 1.0:
            ray_pkg = trace.trace_base(opt_model, pupil, fld, wvl, **kwargs)
            ray_list.append([pupil[0], pupil[1], ray_pkg])
        else:  # ray outside pupil
            if append_if_none:
                ray_list.append([pupil[0], pupil[1], None])

    return ray_list
Esempio n. 4
0
    def create_ray_table(self, opt_model):
        osp = opt_model.optical_spec
        pupil = [0., 1.]
        fi = 0
        wl = osp.spectral_region.reference_wvl
        fld, wvl, foc = osp.lookup_fld_wvl_focus(fi, wl)
        ray, ray_op, wvl = trace.trace_base(opt_model, pupil, fld, wvl)
        #        ray, ray_op, wvl, opd = trace.trace_with_opd(opt_model, pupil,
        #                                                     fld, wvl, foc)

        #        cr = trace.RayPkg(ray, ray_op, wvl)
        #        s, t = trace.trace_coddington_fan(opt_model, cr, foc)

        ray = [RaySeg(*rs) for rs in ray]
        model = cmds.create_ray_table_model(opt_model, ray)
        self.create_table_view(model, "Ray Table")
Esempio n. 5
0
    def update_data(self, **kwargs):
        """Set the fan attribute to a list of (pupil coords), dx, dy, opd."""
        build = kwargs.pop('build', 'rebuild')
        if build == 'rebuild':
            ray_pkg = trace.trace_base(self.opt_model, self.pupil, self.fld,
                                       self.wvl, **kwargs)
            self.ray_seg = ray_pkg[0][self.srf_indx]

            if self.srf_save == 'all':
                self.ray_pkg = ray_pkg

        ray_seg = self.ray_seg
        dist = self.foc / ray_seg[mc.d][2]
        defocused_pt = ray_seg[mc.p] - dist * ray_seg[mc.d]
        self.t_abr = defocused_pt[:-1] - self.image_pt_2d

        return self