def trace_fan(self, fct, fi, xy, num_rays=21, **kwargs): """ xy determines whether x (=0) or y (=1) fan """ osp = self.opt_model.optical_spec fld = osp.field_of_view.fields[fi] wvl = self.central_wavelength() foc = osp.defocus.get_focus() rs_pkg, cr_pkg = trace.setup_pupil_coords(self.opt_model, fld, wvl, foc) fld.chief_ray = cr_pkg fld.ref_sphere = rs_pkg # Use the chief ray intersection point for the central wavelength # as the reference image point for wavefront error calculations ref_img_pt = cr_pkg[0].ray[-1][0] wvls = osp.spectral_region fans_x = [] fans_y = [] fan_start = np.array([0., 0.]) fan_stop = np.array([0., 0.]) fan_start[xy] = -1.0 fan_stop[xy] = 1.0 fan_def = [fan_start, fan_stop, num_rays] max_y_val = 0.0 rc = [] for wi, wvl in enumerate(wvls.wavelengths): rc.append(wvls.render_colors[wi]) rs_pkg, cr_pkg = trace.setup_pupil_coords(self.opt_model, fld, wvl, foc, image_pt=ref_img_pt) fld.chief_ray = cr_pkg fld.ref_sphere = rs_pkg fan = trace.trace_fan(self.opt_model, fan_def, fld, wvl, foc, img_filter=lambda p, ray_pkg: fct( p, xy, ray_pkg, fld, wvl, foc), **kwargs) f_x = [] f_y = [] for p, y_val in fan: f_x.append(p[xy]) f_y.append(y_val) if abs(y_val) > max_y_val: max_y_val = abs(y_val) fans_x.append(f_x) fans_y.append(f_y) fans_x = np.array(fans_x) fans_y = np.array(fans_y) return fans_x, fans_y, max_y_val, rc
def trace_wavefront(self, fld, wvl, foc, num_rays=32): def wave(p, ray_pkg, fld, wvl, foc): x = p[0] y = p[1] if ray_pkg is not None: fod = self.opt_model.optical_spec.parax_data.fod opd = analyses.wave_abr_full_calc(fod, fld, wvl, foc, ray_pkg, fld.chief_ray, fld.ref_sphere) opd = opd/self.opt_model.nm_to_sys_units(wvl) else: opd = 0.0 return np.array([x, y, opd]) rs_pkg, cr_pkg = trace.setup_pupil_coords(self.opt_model, fld, wvl, foc) fld.chief_ray = cr_pkg fld.ref_sphere = rs_pkg grid_start = np.array([-1., -1.]) grid_stop = np.array([1., 1.]) grid_def = (grid_start, grid_stop, num_rays) grid = trace.trace_grid(self.opt_model, grid_def, fld, wvl, foc, img_filter=lambda p, ray_pkg: wave(p, ray_pkg, fld, wvl, foc), form='grid') return grid
def trace_grid(self, fct, fi, wl=None, num_rays=21, form='grid', append_if_none=True): """ fct is applied to the raw grid and returned as a grid """ osp = self.opt_model.optical_spec wvls = osp.spectral_region wvl = self.central_wavelength() wv_list = wvls.wavelengths if wl is None else [wvl] fld = osp.field_of_view.fields[fi] foc = osp.defocus.get_focus() rs_pkg, cr_pkg = trace.setup_pupil_coords(self.opt_model, fld, wvl, foc) fld.chief_ray = cr_pkg fld.ref_sphere = rs_pkg grids = [] grid_start = np.array([-1., -1.]) grid_stop = np.array([1., 1.]) grid_def = [grid_start, grid_stop, num_rays] for wi, wvl in enumerate(wv_list): grid = trace.trace_grid(self.opt_model, grid_def, fld, wvl, foc, form=form, append_if_none=append_if_none, img_filter=lambda p, ray_pkg: fct(p, wi, ray_pkg, fld, wvl, foc)) grids.append(grid) rc = wvls.render_colors return grids, rc