Beispiel #1
0
 def get_instrument_defaults(self):
     self.detector_defaults.clear()
     fname = f'{self.instrument.lower()}_ref_config.yml'
     try:
         text = resource_loader.load_resource(hexrd_resources, fname)
     except Exception:
         fname = f'{self.instrument.lower()}_reference_config.yml'
         text = resource_loader.load_resource(hexrd_resources, fname)
     defaults = yaml.load(text, Loader=yaml.FullLoader)
     for det, vals in defaults['detectors'].items():
         self.detector_defaults[det] = vals['transform']
Beispiel #2
0
 def get_instrument_defaults(self):
     self.detector_defaults.clear()
     not_default = (self.ui.current_config.isChecked()
                    or not self.ui.default_config.isChecked())
     if self.config_file and not_default:
         if os.path.splitext(self.config_file)[1] in YAML_EXTS:
             with open(self.config_file, 'r') as f:
                 self.defaults = yaml.load(f, Loader=yaml.FullLoader)
         else:
             try:
                 with h5py.File(self.config_file, 'r') as f:
                     instr = create_hedm_instrument()
                     instr.unwrap_h5_to_dict(f, self.defaults)
             except Exception as e:
                 msg = (
                     f'ERROR - Could not read file: \n {e} \n'
                     f'File must be HDF5 or YAML.')
                 QMessageBox.warning(None, 'HEXRD', msg)
                 return False
     else:
         fname = f'{self.instrument.lower()}_reference_config.yml'
         text = resource_loader.load_resource(hexrd_resources, fname)
         self.defaults = yaml.load(text, Loader=yaml.FullLoader)
     self.detector_defaults['default_config'] = self.defaults
     self.set_detector_options()
     return True
Beispiel #3
0
    def load_default_materials(self):
        data = resource_loader.load_resource(hexrd.ui.resources.materials,
                                             'materials.hexrd',
                                             binary=True)
        self.load_materials_from_binary(data)

        # Set the tth_max of all the materials to match that of the polar
        # resolution config.
        self.reset_tth_max_all_materials()
Beispiel #4
0
    def load_file(self, file_name, parent=None):
        """Load a UI file and return the widget

        Returns a widget created from the UI file.

        :param file_name: The name of the ui file to load (must be located
                          in hexrd.resources.ui).
        """
        text = resource_loader.load_resource(hexrd.ui.resources.ui, file_name)
        return self.load_string(text, parent)
Beispiel #5
0
    def load_default_config(self):
        text = resource_loader.load_resource(hexrd.ui.resources.calibration,
                                             'default_instrument_config.yml')
        self.default_config['instrument'] = yaml.load(text,
                                                      Loader=yaml.FullLoader)

        yml = resource_loader.load_resource(hexrd.ui.resources.materials,
                                            'materials_panel_defaults.yml')
        self.default_config['materials'] = yaml.load(yml,
                                                     Loader=yaml.FullLoader)

        text = resource_loader.load_resource(hexrd.ui.resources.calibration,
                                             'default_image_config.yml')
        self.default_config['image'] = yaml.load(text, Loader=yaml.FullLoader)

        text = resource_loader.load_resource(hexrd.ui.resources.calibration,
                                             'default_calibration_config.yml')
        self.default_config['calibration'] = yaml.load(text,
                                                       Loader=yaml.FullLoader)
    def setup_widget_paths(self):
        text = resource_loader.load_resource(hexrd.ui.resources.indexing,
                                             'gui_config_maps.yml')
        self.gui_config_maps = yaml.load(text, Loader=yaml.FullLoader)

        paths = {}

        def recursive_get_paths(cur_config, cur_path):
            for key, value in cur_config.items():
                new_path = cur_path + [key]
                if isinstance(value, str):
                    paths[value] = new_path
                    continue

                recursive_get_paths(value, new_path)

        initial_path = []
        recursive_get_paths(self.gui_config_maps, initial_path)
        self.widget_paths = paths
Beispiel #7
0
def main():
    # Kill the program when ctrl-c is used
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)

    QCoreApplication.setOrganizationName('hexrd')
    QCoreApplication.setApplicationName('hexrd')

    app = QApplication(sys.argv)

    data = resource_loader.load_resource(hexrd.ui.resources.icons,
                                         'hexrd.ico',
                                         binary=True)
    pixmap = QPixmap()
    pixmap.loadFromData(data, 'ico')
    icon = QIcon(pixmap)
    app.setWindowIcon(icon)

    window = MainWindow()
    window.set_icon(icon)
    window.show()

    sys.exit(app.exec_())
Beispiel #8
0
 def load_calibration_flags_order(self):
     text = resource_loader.load_resource(hexrd.ui.resources.calibration,
                                          'calibration_flags_order.yml')
     self.calibration_flags_order = yaml.load(text, Loader=yaml.FullLoader)
Beispiel #9
0
 def load_gui_yaml_dict(self):
     text = resource_loader.load_resource(hexrd.ui.resources.calibration,
                                          'yaml_to_gui.yml')
     self.gui_yaml_dict = yaml.load(text, Loader=yaml.FullLoader)
Beispiel #10
0
 def load_default_materials(self):
     data = resource_loader.load_resource(hexrd.ui.resources.materials,
                                          'materials.hexrd',
                                          binary=True)
     self.load_materials_from_binary(data)
 def seed_search_defaults(self):
     file_name = 'seed_search_method_defaults.yml'
     text = load_resource(indexing_resources, file_name)
     return yaml.full_load(text)