def __init__(self, parent=None): super(ImportDialog, self).__init__(parent) self.file_type = None layout = QtWidgets.QVBoxLayout() layout.addLayout(self.filebox()) title_layout = QtWidgets.QHBoxLayout() title_label = NXLabel('Title') self.title_box = NXLineEdit() title_layout.addWidget(title_label) title_layout.addWidget(self.title_box) layout.addLayout(title_layout) energy_layout = QtWidgets.QHBoxLayout() energy_label = NXLabel('Incident Energy') self.energy_box = NXLineEdit() self.energy_box.setFixedWidth(150) energy_layout.addWidget(energy_label) energy_layout.addWidget(self.energy_box) energy_layout.addStretch() layout.addLayout(energy_layout) step_layout = QtWidgets.QHBoxLayout() Q_label = NXLabel('dQ') self.Q_box = NXLineEdit() self.Q_box.setFixedWidth(75) E_label = NXLabel('dE') self.E_box = NXLineEdit() self.E_box.setFixedWidth(75) self.convert_box = QtWidgets.QCheckBox('Convert to S(Q,E)') self.convert_box.setChecked(False) step_layout.addWidget(self.convert_box) step_layout.addStretch() step_layout.addWidget(Q_label) step_layout.addWidget(self.Q_box) step_layout.addWidget(E_label) step_layout.addWidget(self.E_box) step_layout.addStretch() layout.addLayout(step_layout) layout.addWidget(self.close_buttons()) self.setLayout(layout) self.setWindowTitle("Import "+str(filetype))
def __init__(self, parent=None): super(ImportDialog, self).__init__(parent) try: import spec2nexus except ImportError: raise NeXusError("Please install the 'spec2nexus' module") self.accepted = False self.import_file = None # must set in self.get_data() self.spec = None # progress bar is updated via calls to pdate_progress() self.progress_bar = QtWidgets.QProgressBar() self.progress_bar.setVisible(False) status_layout = QtWidgets.QHBoxLayout() status_layout.addWidget(self.progress_bar) status_layout.addStretch() status_layout.addWidget(self.close_buttons()) self.layout = QtWidgets.QVBoxLayout() self.layout.addLayout(self.filebox()) self.layout.addLayout(self.scanbox()) self.layout.addLayout(status_layout) self.setLayout(self.layout) self.setWindowTitle("Import " + str(filetype))
def __init__(self, parent=None): super().__init__(parent=parent) try: from globusonline.catalog.client.examples.catalog_wrapper import \ CatalogWrapper except ImportError: raise NeXusError("Cannot import globusonline package") token_file = os.path.join(os.path.expanduser('~'), '.nexpy', 'globusonline', 'gotoken.txt') self.wrap = CatalogWrapper(token='file', token_file=token_file) _, self.catalogs = self.wrap.catalogClient.get_catalogs() catalog_layout = QtWidgets.QHBoxLayout() self.catalog_box = QtWidgets.QComboBox() for catalog in self.catalogs: try: self.catalog_box.addItem(catalog['config']['name']) except Exception: pass self.catalog_box.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) catalog_button = QtWidgets.QPushButton("Choose Catalog") catalog_button.clicked.connect(self.get_catalog) catalog_layout.addWidget(self.catalog_box) catalog_layout.addWidget(catalog_button) self.layout = QtWidgets.QVBoxLayout() self.layout.addLayout(catalog_layout) self.layout.addWidget(self.close_buttons()) self.setLayout(self.layout) self.setWindowTitle("Import " + str(filetype))
def __init__(self, parent=None): super(ImportDialog, self).__init__(parent) self.layout = QtWidgets.QVBoxLayout() self.layout.addLayout(self.directorybox()) self.filter_box = self.make_filterbox() self.layout.addWidget(self.filter_box) self.rangebox = self.make_rangebox() self.layout.addWidget(self.rangebox) status_layout = QtWidgets.QHBoxLayout() self.progress_bar = QtWidgets.QProgressBar() status_layout.addWidget(self.progress_bar) self.progress_bar.setVisible(False) status_layout.addStretch() status_layout.addWidget(self.buttonbox()) self.layout.addLayout(status_layout) self.setLayout(self.layout) self.setWindowTitle("Import " + str(filetype))
def __init__(self, parent=None): super(FindDialog, self).__init__(parent) self.select_entry(self.choose_entry) self.parameters = GridParameters() self.parameters.add('threshold', '', 'Threshold') self.parameters.add('first', '', 'First Frame') self.parameters.add('last', '', 'Last Frame') find_layout = QtWidgets.QHBoxLayout() self.find_button = QtWidgets.QPushButton('Find Peaks') self.find_button.clicked.connect(self.find_peaks) self.peak_count = QtWidgets.QLabel() self.peak_count.setVisible(False) find_layout.addStretch() find_layout.addWidget(self.find_button) find_layout.addWidget(self.peak_count) find_layout.addStretch() self.set_layout(self.entry_layout, self.parameters.grid(), find_layout, self.progress_layout(save=True)) self.progress_bar.setVisible(False) self.progress_bar.setValue(0) self.set_title('Find Peaks') self.reduce = None
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 scanbox(self): """Create widgets for specifying scan range to import.""" scanminlabel = NXLabel("Min. Scan") self.scanmin = NXLineEdit(width=100, align='right') scanmaxlabel = NXLabel("Max. Scan") self.scanmax = NXLineEdit(width=100, align='right') scanbox = QtWidgets.QHBoxLayout() scanbox.addWidget(scanminlabel) scanbox.addWidget(self.scanmin) scanbox.addWidget(scanmaxlabel) scanbox.addWidget(self.scanmax) return scanbox
def scanbox(self): '''create widgets for specifying scan range to import''' scanminlabel = NXLabel("Min. Scan") self.scanmin = NXLineEdit() self.scanmin.setFixedWidth(100) self.scanmin.setAlignment(QtCore.Qt.AlignRight) scanmaxlabel = NXLabel("Max. Scan") self.scanmax = NXLineEdit() self.scanmax.setFixedWidth(100) self.scanmax.setAlignment(QtCore.Qt.AlignRight) scanbox = QtWidgets.QHBoxLayout() scanbox.addWidget(scanminlabel) scanbox.addWidget(self.scanmin) scanbox.addWidget(scanmaxlabel) scanbox.addWidget(self.scanmax) return scanbox
def make_output_box(self): """ Creates a text box and button for selecting the output file. """ output_box = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() file_button = QtWidgets.QPushButton("Choose Output File") file_button.clicked.connect(self.choose_output_file) self.output_file = QtWidgets.QLineEdit(self) self.output_file.setMinimumWidth(300) layout.addWidget(file_button) layout.addWidget(self.output_file) output_box.setLayout(layout) output_box.setVisible(False) return output_box
def get_dataset(self): self.dataset_id = self.get_dataset_id(self.dataset_box.currentText()) _, self.members = self.wrap.catalogClient.get_members( self.catalog_id, self.dataset_id) member_layout = QtWidgets.QHBoxLayout() self.member_box = QtWidgets.QComboBox() for member in self.members: try: self.member_box.addItem(member['data_uri']) except Exception: pass self.member_box.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) member_button = QtWidgets.QPushButton("Choose Member") member_button.clicked.connect(self.get_member) member_layout.addWidget(self.member_box) member_layout.addWidget(member_button) self.layout.insertLayout(2, member_layout)
def get_catalog(self): self.catalog_id = self.get_catalog_id(self.catalog_box.currentText()) _, self.datasets = self.wrap.catalogClient.get_datasets( self.catalog_id) dataset_layout = QtWidgets.QHBoxLayout() self.dataset_box = QtWidgets.QComboBox() for dataset in self.datasets: try: self.dataset_box.addItem(dataset['name']) except Exception: pass self.dataset_box.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) dataset_button = QtWidgets.QPushButton("Choose Dataset") dataset_button.clicked.connect(self.get_dataset) dataset_layout.addWidget(self.dataset_box) dataset_layout.addWidget(dataset_button) self.layout.insertLayout(1, dataset_layout)
def __init__(self, parent=None): super(ImportDialog, self).__init__(parent) skippedbox = QtWidgets.QHBoxLayout() skippedlabel = QtWidgets.QLabel("No. of skipped rows") self.skiprows = QtWidgets.QLineEdit() self.skiprows.setText('0') self.skiprows.setFixedWidth(20) skippedbox.addWidget(skippedlabel) skippedbox.addWidget(self.skiprows) layout = QtWidgets.QVBoxLayout() layout.addLayout(self.filebox()) layout.addLayout(skippedbox) layout.addWidget(self.buttonbox()) self.setLayout(layout) self.setWindowTitle("Import "+str(filetype))
def make_rangebox(self): rangebox = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() rangeminlabel = QtWidgets.QLabel("Min. index") self.rangemin = QtWidgets.QLineEdit() self.rangemin.setFixedWidth(150) self.rangemin.setAlignment(QtCore.Qt.AlignRight) rangemaxlabel = QtWidgets.QLabel("Max. index") self.rangemax = QtWidgets.QLineEdit() self.rangemax.setFixedWidth(150) self.rangemax.setAlignment(QtCore.Qt.AlignRight) layout.addWidget(rangeminlabel) layout.addWidget(self.rangemin) layout.addStretch() layout.addWidget(rangemaxlabel) layout.addWidget(self.rangemax) rangebox.setLayout(layout) rangebox.setVisible(False) return rangebox
def __init__(self, parent=None): super(StackDialog, self).__init__(parent) status_layout = QtWidgets.QHBoxLayout() self.progress_bar = QtWidgets.QProgressBar() status_layout.addWidget(self.progress_bar) self.progress_bar.setVisible(False) status_layout.addStretch() status_layout.addWidget(self.close_buttons(save=True)) self.set_layout(self.directorybox(), self.make_filter_box(), self.make_range_box(), self.make_output_box(), status_layout) self.setLayout(self.layout) self.set_title('Stack Images') self.suffix = ''
def list_peaks(self): if self.peaks_box is not None and self.table_model is not None: self.update_table() return self.peaks_box = BaseDialog(self) self.peaks_box.setMinimumWidth(600) self.peaks_box.setMinimumHeight(600) header = [ 'i', 'x', 'y', 'z', 'Polar', 'Azi', 'Intensity', 'H', 'K', 'L', 'Diff' ] peak_list = self.refine.get_peaks() self.refine.assign_rings() self.rings = self.refine.get_ring_hkls() orient_layout = QtWidgets.QHBoxLayout() if self.refine.primary is None: self.refine.primary = 0 if self.refine.secondary is None: self.refine.secondary = 1 self.primary_box = QtWidgets.QLineEdit(str(self.refine.primary)) self.primary_box.setAlignment(QtCore.Qt.AlignRight) self.primary_box.setFixedWidth(80) self.secondary_box = QtWidgets.QLineEdit(str(self.refine.secondary)) self.secondary_box.setAlignment(QtCore.Qt.AlignRight) self.secondary_box.setFixedWidth(80) orient_button = QtWidgets.QPushButton('Orient') orient_button.clicked.connect(self.orient) orient_layout.addStretch() orient_layout.addWidget(QtWidgets.QLabel('Primary')) orient_layout.addWidget(self.primary_box) orient_layout.addWidget(QtWidgets.QLabel('Secondary')) orient_layout.addWidget(self.secondary_box) orient_layout.addStretch() orient_layout.addWidget(orient_button) self.table_view = QtWidgets.QTableView() self.table_model = NXTableModel(self, peak_list, header) self.table_view.setModel(self.table_model) self.table_view.resizeColumnsToContents() self.table_view.horizontalHeader().stretchLastSection() self.table_view.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.table_view.doubleClicked.connect(self.plot_peak) self.table_view.setSortingEnabled(True) self.table_view.sortByColumn(0, QtCore.Qt.AscendingOrder) layout = QtWidgets.QVBoxLayout() layout.addLayout(orient_layout) layout.addWidget(self.table_view) close_layout = QtWidgets.QHBoxLayout() self.status_text = QtWidgets.QLabel('Score: %.4f' % self.refine.score()) self.tolerance_box = QtWidgets.QLineEdit(str( self.refine.hkl_tolerance)) self.tolerance_box.setAlignment(QtCore.Qt.AlignRight) self.tolerance_box.setMaxLength(5) self.tolerance_box.editingFinished.connect(self.update_table) self.tolerance_box.setFixedWidth(80) save_button = QtWidgets.QPushButton('Save Orientation') save_button.clicked.connect(self.save_orientation) close_button = QtWidgets.QPushButton('Close Window') close_button.clicked.connect(self.close_peaks_box) close_layout.addWidget(self.status_text) close_layout.addStretch() close_layout.addWidget(QtWidgets.QLabel('Threshold')) close_layout.addWidget(self.tolerance_box) close_layout.addStretch() close_layout.addWidget(save_button) close_layout.addStretch() close_layout.addWidget(close_button) layout.addLayout(close_layout) self.peaks_box.setLayout(layout) self.peaks_box.setWindowTitle('%s Peak Table' % self.entry.nxtitle) self.peaks_box.adjustSize() self.peaks_box.show() self.plotview = None
def list_orientations(self): message_box = BaseDialog(self) message_box.setMinimumWidth(600) message_box.setMinimumHeight(600) header = [ 'i', 'x', 'y', 'z', 'Polar', 'Azi', 'Intensity', 'H', 'K', 'L', 'Diff' ] peak_list = self.refine.get_peaks() self.refine.assign_rings() self.rings = self.refine.get_ring_hkls() orient_layout = QtWidgets.QHBoxLayout() if self.refine.primary is None: self.refine.primary = 0 if self.refine.secondary is None: self.refine.secondary = 1 self.primary_box = QtWidgets.QLineEdit(str(self.refine.primary)) self.primary_box.setAlignment(QtCore.Qt.AlignRight) self.primary_box.setFixedWidth(80) self.secondary_box = QtWidgets.QLineEdit(str(self.refine.secondary)) self.secondary_box.setAlignment(QtCore.Qt.AlignRight) self.secondary_box.setFixedWidth(80) orient_button = QtWidgets.QPushButton('Orient') orient_button.clicked.connect(self.orient) refine_button = QtWidgets.QPushButton('Refine') refine_button.clicked.connect(self.refine_orientation) restore_button = QtWidgets.QPushButton('Restore') restore_button.clicked.connect(self.restore_orientation) orient_layout.addStretch() orient_layout.addWidget(QtWidgets.QLabel('Primary')) orient_layout.addWidget(self.primary_box) orient_layout.addWidget(QtWidgets.QLabel('Secondary')) orient_layout.addWidget(self.secondary_box) orient_layout.addStretch() orient_layout.addWidget(orient_button) orient_layout.addWidget(refine_button) orient_layout.addWidget(restore_button) grid = QtWidgets.QGridLayout() grid.setSpacing(10) self.lattice = GridParameters() self.lattice.add('a', self.refine.a, 'a', False) self.lattice.add('b', self.refine.b, 'b', False) self.lattice.add('c', self.refine.c, 'c', False) self.lattice.add('alpha', self.refine.alpha, 'alpha', False) self.lattice.add('beta', self.refine.beta, 'beta', False) self.lattice.add('gamma', self.refine.gamma, 'gamma', False) p = self.lattice['a'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 0, 0, QtCore.Qt.AlignRight) grid.addWidget(p.box, 0, 1, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 0, 2, QtCore.Qt.AlignHCenter) p = self.lattice['b'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 0, 3, QtCore.Qt.AlignRight) grid.addWidget(p.box, 0, 4, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 0, 5, QtCore.Qt.AlignHCenter) p = self.lattice['c'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 0, 6, QtCore.Qt.AlignRight) grid.addWidget(p.box, 0, 7, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 0, 8, QtCore.Qt.AlignHCenter) p = self.lattice['alpha'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 1, 0, QtCore.Qt.AlignRight) grid.addWidget(p.box, 1, 1, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 1, 2, QtCore.Qt.AlignHCenter) p = self.lattice['beta'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 1, 3, QtCore.Qt.AlignRight) grid.addWidget(p.box, 1, 4, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 1, 5, QtCore.Qt.AlignHCenter) p = self.lattice['gamma'] p.box.setFixedWidth(80) label, value, checkbox = p.label, p.value, p.vary grid.addWidget(p.label, 1, 6, QtCore.Qt.AlignRight) grid.addWidget(p.box, 1, 7, QtCore.Qt.AlignHCenter) grid.addWidget(p.checkbox, 1, 8, QtCore.Qt.AlignHCenter) self.table_view = QtWidgets.QTableView() self.table_model = NXTableModel(self, peak_list, header) self.table_view.setModel(self.table_model) self.table_view.resizeColumnsToContents() self.table_view.horizontalHeader().stretchLastSection() self.table_view.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.table_view.doubleClicked.connect(self.plot_peak) self.table_view.setSortingEnabled(True) self.table_view.sortByColumn(0, QtCore.Qt.AscendingOrder) layout = QtWidgets.QVBoxLayout() layout.addLayout(orient_layout) layout.addLayout(grid) layout.addWidget(self.table_view) close_layout = QtWidgets.QHBoxLayout() self.status_text = QtWidgets.QLabel('Score: %.4f' % self.refine.score()) self.tolerance_box = QtWidgets.QLineEdit(str( self.refine.hkl_tolerance)) self.tolerance_box.setAlignment(QtCore.Qt.AlignRight) self.tolerance_box.setMaxLength(5) self.tolerance_box.editingFinished.connect(self.update_table) self.tolerance_box.setFixedWidth(80) save_button = QtWidgets.QPushButton('Save Orientation') save_button.clicked.connect(self.save_orientation) close_button = QtWidgets.QPushButton('Close Window') close_button.clicked.connect(message_box.close) close_layout.addWidget(self.status_text) close_layout.addStretch() close_layout.addWidget(QtWidgets.QLabel('Threshold')) close_layout.addWidget(self.tolerance_box) close_layout.addStretch() close_layout.addWidget(save_button) close_layout.addStretch() close_layout.addWidget(close_button) layout.addLayout(close_layout) message_box.setLayout(layout) message_box.setWindowTitle('%s Peak Table' % self.entry.nxtitle) message_box.adjustSize() message_box.show() self.plotview = None