def open_model(file_name): """ open a file and populate an optical model with the data Args: file_name (str): a filename of a supported file type - .roa - a rayoptics JSON encoded file - .seq - a CODE V (TM) sequence file Returns: if successful, an OpticalModel instance, otherwise, None """ file_extension = os.path.splitext(file_name)[1] opm = None if file_extension == '.seq': opm = OpticalModel() cvp.read_lens(opm, file_name) create_specsheet_from_model(opm) elif file_extension == '.roa': with open(file_name, 'r') as f: obj_dict = json_tricks.load(f) if 'optical_model' in obj_dict: opm = obj_dict['optical_model'] opm.sync_to_restore() return opm
def update_model(self): self.seq_model.update_model() self.optical_spec.update_model() self.parax_model.update_model() self.ele_model.update_model() if self.specsheet is None: self.specsheet = create_specsheet_from_model(self)
def create_new_ideal_imager(**inputs): conj_type = (inputs['conjugate_type'] if 'conjugate_type' in inputs else 'finite') specsheets = create_specsheets() if 'opt_model' in inputs: opt_model = inputs['opt_model'] specsheet = create_specsheet_from_model(opt_model, specsheets=specsheets) conj_type = specsheet.conjugate_type specsheets[conj_type] = specsheet if 'gui_parent' in inputs: gui_parent = inputs['gui_parent'] opt_model = gui_parent.app_manager.model iid = IdealImagerDialog(conj_type, specsheets, cmd_fct=gui_parent.handle_ideal_imager_command, parent=gui_parent) gui_parent.add_subwindow(iid, ModelInfo(gui_parent.app_manager.model, update_specsheet, (iid, opt_model))) iid.update_values() iid.show() else: iid = IdealImagerDialog(conj_type, specsheets) iid.update_values() iid.exec_()