def choose_entry(self): self.refine = NXRefine(self.entry) if 'peaks' in self.entry: if self.layout.count() == 2: self.insert_layout(1, self.parameters.grid(header=False)) self.insert_layout(2, self.action_buttons) self.update_parameters() else: self.display_message("Calculating Angles", "No peaks have been found in this entry")
def choose_entry(self): self.refine = NXRefine(self.root['entry']) if self.layout.count() == 2: self.insert_layout(1, self.parameters.grid(header=False)) if sgtbx: self.insert_layout( 2, self.make_layout(self.import_button, self.import_checkbox, align='center')) self.update_parameters()
def accept(self): try: if 'transform' in self.entry and not self.overwrite: self.display_message( "Preparing Transform", f"Transform group already exists in {self.entry.nxname}") return if (self.mask and 'masked_transform' in self.entry and not self.overwrite): self.display_message( "Preparing Transform", "Masked transform group already exists in " f"{self.entry.nxname}") return output_file = self.get_output_file() settings_file = self.get_settings_file() self.write_parameters(output_file, settings_file) self.refine.prepare_transform(output_file) if self.mask: masked_output_file = self.get_output_file(mask=True) self.refine.prepare_transform(masked_output_file, mask=True) self.refine.write_settings(settings_file) if self.copy: root = self.entry.nxroot for entry in [ e for e in root if e != 'entry' and e != self.entry.nxname ]: if 'transform' in root[entry] and not self.overwrite: self.display_message( "Preparing Transform", f"Transform group already exists in {entry}") return if (self.mask and 'masked_transform' in root[entry] and not self.overwrite): self.display_message( "Preparing Transform", f"Masked transform group already exists in {entry}" ) return self.refine = NXRefine(root[entry]) output_file = self.get_output_file(entry=root[entry]) settings_file = self.get_settings_file(entry=root[entry]) self.write_parameters(output_file, settings_file) self.refine.prepare_transform(output_file) if self.mask: masked_output_file = self.get_output_file( mask=True, entry=root[entry]) self.refine.prepare_transform(masked_output_file, mask=True) self.refine.write_settings(settings_file) super().accept() except NeXusError as error: report_error("Preparing Data Transform", error)
def initialize_grid(self): self.refine = NXRefine(self.entry) self.refine.initialize_grid() self.start_h_box.setText('%g' % self.refine.h_start) self.step_h_box.setText('%g' % self.refine.h_step) self.stop_h_box.setText('%g' % self.refine.h_stop) self.start_k_box.setText('%g' % self.refine.k_start) self.step_k_box.setText('%g' % self.refine.k_step) self.stop_k_box.setText('%g' % self.refine.k_stop) self.start_l_box.setText('%g' % self.refine.l_start) self.step_l_box.setText('%g' % self.refine.l_step) self.stop_l_box.setText('%g' % self.refine.l_stop)
def accept(self): try: if 'transform' in self.entry and not self.overwrite: self.display_message( 'Preparing Transform', 'Transform group already exists in %s' % self.entry.nxname) return if self.mask and 'masked_transform' in self.entry and not self.overwrite: self.display_message( 'Preparing Transform', 'Masked transform group already exists in %s' % self.entry.nxname) return output_file = self.get_output_file() settings_file = self.get_settings_file() self.write_parameters(output_file, settings_file) self.refine.prepare_transform(output_file) if self.mask: masked_output_file = self.get_output_file(mask=True) self.refine.prepare_transform(masked_output_file, mask=True) self.refine.write_settings(settings_file) if self.copy: root = self.entry.nxroot for entry in [ e for e in root if e != 'entry' and e != self.entry.nxname ]: if 'transform' in root[entry] and not self.overwrite: self.display_message( 'Preparing Transform', 'Transform group already exists in %s' % entry) return if self.mask and 'masked_transform' in root[ entry] and not self.overwrite: self.display_message( 'Preparing Transform', 'Masked transform group already exists in %s' % entry) return self.refine = NXRefine(root[entry]) output = output_file.replace(self.entry.nxname, entry) settings = settings_file.replace(self.entry.nxname, entry) self.write_parameters(output, settings) self.refine.prepare_transform(output) if self.mask: output = masked_output_file.replace( self.entry.nxname, entry) self.refine.prepare_transform(output, mask=True) self.refine.write_settings(settings) super(TransformDialog, self).accept() except NeXusError as error: report_error("Preparing Data Transform", error)
def __init__(self, parent=None): super(TransformDialog, self).__init__(parent) self.select_entry(self.initialize_grid) self.refine = NXRefine() grid = QtWidgets.QGridLayout() grid.setSpacing(10) header_font = QtGui.QFont() header_font.setBold(True) start_label = QtWidgets.QLabel('Start') start_label.setFont(header_font) grid.addWidget(start_label, 0, 1) step_label = QtWidgets.QLabel('Step') step_label.setFont(header_font) grid.addWidget(step_label, 0, 2) stop_label = QtWidgets.QLabel('Stop') stop_label.setFont(header_font) grid.addWidget(stop_label, 0, 3) grid.addWidget(QtWidgets.QLabel('H:'), 1, 0) grid.addWidget(QtWidgets.QLabel('K:'), 2, 0) grid.addWidget(QtWidgets.QLabel('L:'), 3, 0) self.start_h_box = QtWidgets.QLineEdit() self.step_h_box = QtWidgets.QLineEdit() self.stop_h_box = QtWidgets.QLineEdit() grid.addWidget(self.start_h_box, 1, 1) grid.addWidget(self.step_h_box, 1, 2) grid.addWidget(self.stop_h_box, 1, 3) self.start_k_box = QtWidgets.QLineEdit() self.step_k_box = QtWidgets.QLineEdit() self.stop_k_box = QtWidgets.QLineEdit() grid.addWidget(self.start_k_box, 2, 1) grid.addWidget(self.step_k_box, 2, 2) grid.addWidget(self.stop_k_box, 2, 3) self.start_l_box = QtWidgets.QLineEdit() self.step_l_box = QtWidgets.QLineEdit() self.stop_l_box = QtWidgets.QLineEdit() grid.addWidget(self.start_l_box, 3, 1) grid.addWidget(self.step_l_box, 3, 2) grid.addWidget(self.stop_l_box, 3, 3) self.set_layout( self.entry_layout, grid, self.checkboxes( ('copy', 'Copy to all entries', True), ('mask', 'Create masked transform group', True), ('overwrite', 'Overwrite existing transforms', False)), self.close_buttons(save=True)) self.setWindowTitle('Transforming Data') try: self.initialize_grid() except Exception: pass
def __init__(self, parent=None): super().__init__(parent) self.select_root(self.choose_entry) self.refine = NXRefine() self.parameters = GridParameters() self.parameters.add('space_group', self.refine.space_group, 'Space Group', slot=self.set_groups) self.parameters.add('laue_group', self.refine.laue_groups, 'Laue Group') self.parameters.add('symmetry', self.refine.symmetries, 'Symmetry', slot=self.set_lattice_parameters) self.parameters.add('centring', self.refine.centrings, 'Cell Centring') self.parameters.add('a', self.refine.a, 'Unit Cell - a (Ang)', slot=self.set_lattice_parameters) self.parameters.add('b', self.refine.b, 'Unit Cell - b (Ang)', slot=self.set_lattice_parameters) self.parameters.add('c', self.refine.c, 'Unit Cell - c (Ang)', slot=self.set_lattice_parameters) self.parameters.add('alpha', self.refine.alpha, 'Unit Cell - alpha (deg)', slot=self.set_lattice_parameters) self.parameters.add('beta', self.refine.beta, 'Unit Cell - beta (deg)', slot=self.set_lattice_parameters) self.parameters.add('gamma', self.refine.gamma, 'Unit Cell - gamma (deg)', slot=self.set_lattice_parameters) self.parameters['laue_group'].value = self.refine.laue_group self.parameters['symmetry'].value = self.refine.symmetry self.parameters['centring'].value = self.refine.centring self.import_button = NXPushButton('Import CIF', self.import_cif) self.import_checkbox = NXCheckBox('Update Lattice Parameters') self.set_layout(self.root_layout, self.close_buttons(save=True)) self.set_title('Defining Lattice')
def choose_entry(self): if self.layout.count() == 2: self.insert_layout(1, self.parameters.grid_layout) self.insert_layout(2, self.find_layout) self.reduce = NXReduce(self.entry) self.refine = NXRefine(self.entry) self.refine.polar_max = self.refine.two_theta_max() if self.reduce.first is not None: self.parameters['first'].value = self.reduce.first if self.reduce.last: self.parameters['last'].value = self.reduce.last else: try: self.parameters['last'].value = self.reduce.shape[0] except Exception: pass self.parameters['threshold'].value = self.reduce.threshold
def __init__(self, parent=None): super().__init__(parent) self.select_entry(self.choose_entry) self.refine = NXRefine() self.parameters = GridParameters() self.parameters.add('wavelength', self.refine.wavelength, 'Wavelength (Ang)') self.parameters.add('distance', self.refine.distance, 'Detector Distance (mm)') self.parameters.add('xc', self.refine.xc, 'Beam Center - x') self.parameters.add('yc', self.refine.yc, 'Beam Center - y') self.parameters.add('pixel', self.refine.pixel_size, 'Pixel Size (mm)') self.action_buttons = self.action_buttons( ('Plot', self.plot_lattice), ('Save', self.write_parameters)) self.set_layout(self.entry_layout, self.close_buttons()) self.set_title('Calculate Angles')
def choose_entry(self): try: refine = NXRefine(self.entry) if refine.xp is None: raise NeXusError("No peaks in entry") except NeXusError as error: report_error("Refining Lattice", error) return self.refine = refine if self.layout.count() == 2: self.insert_layout(1, self.Qgrid) self.insert_layout( 2, self.checkboxes(('copy', 'Copy to all entries', True), ('mask', 'Create masked transforms', True), ('overwrite', 'Overwrite transforms', False))) self.refine.initialize_grid() self.update_grid()
def choose_entry(self): try: refine = NXRefine(self.entry) if refine.xp is None: raise NeXusError("No peaks in entry") except NeXusError as error: report_error("Refining Lattice", error) return self.refine = refine self.set_title(f"Refining {self.refine.name}") if self.layout.count() == 2: self.insert_layout(1, self.parameters.grid_layout) self.insert_layout(2, self.refine_buttons) self.insert_layout(3, self.orientation_buttons) self.insert_layout(4, self.parameters.report_layout()) self.insert_layout(5, self.lattice_buttons) self.update_parameters() self.update_table()
def __init__(self, parent=None): super(LatticeDialog, self).__init__(parent) self.select_entry(self.choose_entry) self.refine = NXRefine() self.parameters = GridParameters() self.parameters.add('symmetry', self.refine.symmetries, 'Symmetry', slot=self.set_lattice_parameters) self.parameters.add('centring', self.refine.centrings, 'Cell Centring') self.parameters.add('a', self.refine.a, 'Unit Cell - a (Ang)', slot=self.set_lattice_parameters) self.parameters.add('b', self.refine.b, 'Unit Cell - b (Ang)', slot=self.set_lattice_parameters) self.parameters.add('c', self.refine.c, 'Unit Cell - c (Ang)', slot=self.set_lattice_parameters) self.parameters.add('alpha', self.refine.alpha, 'Unit Cell - alpha (deg)', slot=self.set_lattice_parameters) self.parameters.add('beta', self.refine.beta, 'Unit Cell - beta (deg)', slot=self.set_lattice_parameters) self.parameters.add('gamma', self.refine.gamma, 'Unit Cell - gamma (deg)', slot=self.set_lattice_parameters) self.parameters['symmetry'].value = self.refine.symmetry self.parameters['centring'].value = self.refine.centring action_buttons = self.action_buttons(('Plot', self.plot_lattice), ('Save', self.write_parameters)) self.set_layout(self.entry_layout, self.parameters.grid(), action_buttons, self.close_buttons()) self.set_title('Defining Lattice')
def __init__(self, parent=None): super(OrientationDialog, self).__init__(parent) self.select_entry(self.choose_entry) self.refine = NXRefine(self.entry) self.refine.read_parameters() self.parameters = GridParameters() self.parameters.add('phi_start', self.refine.phi, 'Phi Start (deg)') self.parameters.add('phi_step', self.refine.phi_step, 'Phi Step (deg)') self.parameters.add('chi', self.refine.chi, 'Chi (deg)') self.parameters.add('omega', self.refine.omega, 'Omega (deg)') self.parameters.add('polar', self.refine.polar_max, 'Max. Polar Angle (deg)') self.parameters.add('polar_tolerance', self.refine.polar_tolerance, 'Polar Angle Tolerance') self.parameters.add('peak_tolerance', self.refine.peak_tolerance, 'Peak Angle Tolerance') action_buttons = self.action_buttons( ('Generate Grains', self.generate_grains), ('List Peaks', self.list_peaks)) self.grain_layout = QtWidgets.QHBoxLayout() self.grain_combo = QtWidgets.QComboBox() self.grain_combo.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) self.grain_combo.currentIndexChanged.connect(self.set_grain) self.grain_textbox = QtWidgets.QLabel() self.grain_layout.addWidget(self.grain_combo) self.grain_layout.addStretch() self.grain_layout.addWidget(self.grain_textbox) bottom_layout = QtWidgets.QHBoxLayout() self.result_textbox = QtWidgets.QLabel() bottom_layout.addWidget(self.result_textbox) bottom_layout.addStretch() bottom_layout.addWidget(self.close_buttons()) self.set_layout(self.entry_layout, self.parameters.grid(), action_buttons, bottom_layout) self.set_title('Defining Orientation')
def choose_entry(self): self.refine = NXRefine(self.entry) self.update_parameters()
def __init__(self, parent=None): super(RefineLatticeDialog, self).__init__(parent) self.select_entry(self.choose_entry) self.refine = NXRefine() self.parameters = GridParameters() self.parameters.add('symmetry', self.refine.symmetries, 'Symmetry', None, self.set_lattice_parameters) self.parameters.add('a', self.refine.a, 'Unit Cell - a (Ang)', False, slot=self.set_lattice_parameters) self.parameters.add('b', self.refine.b, 'Unit Cell - b (Ang)', False, slot=self.set_lattice_parameters) self.parameters.add('c', self.refine.c, 'Unit Cell - c (Ang)', False, slot=self.set_lattice_parameters) self.parameters.add('alpha', self.refine.alpha, 'Unit Cell - alpha (deg)', False, slot=self.set_lattice_parameters) self.parameters.add('beta', self.refine.beta, 'Unit Cell - beta (deg)', False, slot=self.set_lattice_parameters) self.parameters.add('gamma', self.refine.gamma, 'Unit Cell - gamma (deg)', False, slot=self.set_lattice_parameters) self.parameters.add('wavelength', self.refine.wavelength, 'Wavelength (Ang)', False) self.parameters.add('distance', self.refine.distance, 'Distance (mm)', False) self.parameters.add('yaw', self.refine.yaw, 'Yaw (deg)', False) self.parameters.add('pitch', self.refine.pitch, 'Pitch (deg)', False) self.parameters.add('roll', self.refine.roll, 'Roll (deg)') self.parameters.add('xc', self.refine.xc, 'Beam Center - x', False) self.parameters.add('yc', self.refine.yc, 'Beam Center - y', False) self.parameters.add('phi', self.refine.phi, 'Phi Start (deg)', False) self.parameters.add('phi_step', self.refine.phi_step, 'Phi Step (deg)') self.parameters.add('chi', self.refine.chi, 'Chi (deg)', False) self.parameters.add('omega', self.refine.omega, 'Omega (deg)', False) self.parameters.add('twotheta', self.refine.twotheta, 'Two Theta (deg)') self.parameters.add('gonpitch', self.refine.gonpitch, 'Goniometer Pitch (deg)', False) self.parameters.add('polar', self.refine.polar_max, 'Max. Polar Angle (deg)', None, self.set_polar_max) self.parameters.add('polar_tolerance', self.refine.polar_tolerance, 'Polar Angle Tolerance') self.parameters.add('peak_tolerance', self.refine.peak_tolerance, 'Peak Angle Tolerance') self.set_symmetry() self.refine_buttons = self.action_buttons( ('Refine Angles', self.refine_angles), ('Refine HKLs', self.refine_hkls), ('Restore', self.restore_parameters), ('Reset', self.reset_parameters)) self.orientation_button = self.action_buttons( ('Refine Orientation Matrix', self.refine_orientation)) self.lattice_buttons = self.action_buttons( ('Plot', self.plot_lattice), ('List', self.list_peaks), ('Save', self.write_parameters)) self.set_layout(self.entry_layout, self.parameters.grid(), self.refine_buttons, self.orientation_button, self.parameters.report_layout(), self.lattice_buttons, self.close_layout()) self.parameters.grid_layout.setVerticalSpacing(1) self.layout.setSpacing(2) self.set_title('Refining Lattice') self.peaks_box = None self.table_model = None self.fit_report = []
def choose_entry(self): self.refine = NXRefine(self.entry) self.update_parameters() if self.peaks_box: self.update_table()