def select_datafile(self): datafile = QtGui.QFileDialog.getOpenFileName() self.data_file.setText(datafile) datafile = str(datafile) if datafile and is_hdf5(datafile): path = HDF5Dialog.getPath(datafile) self.data_file_hdf5.setText(path or "")
def detector_changed(self): """ Called by the UI when the combo-box value is changed """ logger.debug("detector_changed") detector = str(self.detector.currentText()).lower() inst = pyFAI.detectors.detector_factory(detector) if inst.force_pixel: self.pixel1.setText(str(inst.pixel1)) self.pixel2.setText(str(inst.pixel2)) self.detectorfile.setText("") elif self.detectorfile.text(): detectorfile = str(self.detectorfile.text()).strip() if op.isfile(detectorfile): if is_hdf5(detectorfile): det = pyFAI.detectors.detector_factory(detectorfile) self.pixel1.setText(str(det.pixel1)) self.pixel2.setText(str(det.pixel2)) self.detector.setCurrentIndex( self.all_detectors.index("nexusdetector")) else: try: spline = pyFAI.spline.Spline(detectorfile) except Exception as error: logger.error("failed %s on %s" % (error, detectorfile)) else: self.pixel1.setText(str(spline.pixelSize[1] * 1e-6)) self.pixel2.setText(str(spline.pixelSize[0] * 1e-6)) self.detector.setCurrentIndex( self.all_detectors.index("frelon")) else: logger.warning("No such detector file %s" % detectorfile)
def detector_changed(self): """ Called by the UI when the combo-box value is changed """ logger.debug("detector_changed") detector = str(self.detector.currentText()).lower() inst = pyFAI.detectors.detector_factory(detector) if inst.force_pixel: self.pixel1.setText(str(inst.pixel1)) self.pixel2.setText(str(inst.pixel2)) self.detectorfile.setText("") elif self.detectorfile.text(): detectorfile = str(self.detectorfile.text()).strip() if op.isfile(detectorfile): if is_hdf5(detectorfile): det = pyFAI.detectors.detector_factory(detectorfile) self.pixel1.setText(str(det.pixel1)) self.pixel2.setText(str(det.pixel2)) self.detector.setCurrentIndex(self.all_detectors.index("nexusdetector")) else: try: spline = pyFAI.spline.Spline(detectorfile) except Exception as error: logger.error("failed %s on %s" % (error, detectorfile)) else: self.pixel1.setText(str(spline.pixelSize[1] * 1e-6)) self.pixel2.setText(str(spline.pixelSize[0] * 1e-6)) self.detector.setCurrentIndex(self.all_detectors.index("frelon")) else: logger.warning("No such detector file %s" % detectorfile)
def test_new_detector(self): fname = os.path.join(self.tmpdir, "nxs.h5") nxs = io.Nexus(fname, "r+") nxs.new_detector() nxs.close() self.assert_(io.is_hdf5(fname), "nexus file is an HDF5")
def select_maskfile(self): logger.debug("select_maskfile") maskfile = str(QtGui.QFileDialog.getOpenFileName()) if maskfile: self.mask_file.setText(maskfile or "") self.do_mask.setChecked(True) if is_hdf5(maskfile): path = HDF5Dialog.getPath(maskfile) self.mask_file_hdf5.setText(path or "")
def select_darkcurrent(self): logger.debug("select_darkcurrent") darkcurrent = str(QtGui.QFileDialog.getOpenFileName()) if darkcurrent: self.dark_current.setText(str_(darkcurrent)) self.do_dark.setChecked(True) if is_hdf5(darkcurrent): path = HDF5Dialog.getPath(darkcurrent) self.dark_current_hdf5.setText(path or "")
def select_flatfield(self): logger.debug("select_flatfield") flatfield = str(QtGui.QFileDialog.getOpenFileName()) if flatfield: self.flat_field.setText(str_(flatfield)) self.do_flat.setChecked(True) if is_hdf5(flatfield): path = HDF5Dialog.getPath(flatfield) self.flat_field_hdf5.setText(path or "")
def test_new_detector(self): if io.h5py is None: logger.warning("H5py not present, skipping test_io.TestNexus") return fname = os.path.join(self.tmpdir, "nxs.h5") nxs = io.Nexus(fname, "a") nxs.new_detector() nxs.close() self.assertTrue(io.is_hdf5(fname), "nexus file is an HDF5")
def test_new_detector(self): if io.h5py is None: logger.warning("H5py not present, skipping test_io.TestNexus") return fname = os.path.join(self.tmpdir, "nxs.h5") nxs = io.Nexus(fname, "r+") nxs.new_detector() nxs.close() self.assertTrue(io.is_hdf5(fname), "nexus file is an HDF5")
def select_detectorfile(self): logger.debug("select_detectorfile") splinefile = str(QtGui.QFileDialog.getOpenFileName()) if splinefile: self.detectorfile.setText(splinefile) if is_hdf5(splinefile): det = pyFAI.detectors.detector_factory(splinefile) self.pixel1.setText(str(det.pixel1)) self.pixel2.setText(str(det.pixel2)) self.detector.setCurrentIndex(self.all_detectors.index("nexusdetector")) else: try: spline = pyFAI.spline.Spline(splinefile) except Exception as error: logger.error("failed %s on %s" % (error, splinefile)) else: if spline.pixelSize: self.pixel1.setText(str(spline.pixelSize[1] * 1e-6)) self.pixel2.setText(str(spline.pixelSize[0] * 1e-6)) self.detector.setCurrentIndex(self.all_detectors.index("frelon"))
def select_detectorfile(self): logger.debug("select_detectorfile") splinefile = str(QtGui.QFileDialog.getOpenFileName()) if splinefile: self.detectorfile.setText(splinefile) if is_hdf5(splinefile): det = pyFAI.detectors.detector_factory(splinefile) self.pixel1.setText(str(det.pixel1)) self.pixel2.setText(str(det.pixel2)) self.detector.setCurrentIndex( self.all_detectors.index("nexusdetector")) else: try: spline = pyFAI.spline.Spline(splinefile) except Exception as error: logger.error("failed %s on %s" % (error, splinefile)) else: if spline.pixelSize: self.pixel1.setText(str(spline.pixelSize[1] * 1e-6)) self.pixel2.setText(str(spline.pixelSize[0] * 1e-6)) self.detector.setCurrentIndex( self.all_detectors.index("frelon"))
def select_dark_hdf5(self): logger.debug("select_dark_hdf5") datafile = str(self.dark_current.text()) if datafile and is_hdf5(datafile): path = HDF5Dialog.getPath(datafile) self.dark_current_hdf5.setText(path or "")
def select_flat_hdf5(self): logger.debug("select_flat_hdf5") datafile = str(self.flat_field.text()) if datafile and is_hdf5(datafile): path = HDF5Dialog.getPath(datafile) self.flat_field_hdf5.setText(path or "")
def select_mask_hdf5(self): logger.debug("select_mask_hdf5") datafile = str(self.mask_file.text()) if datafile and is_hdf5(datafile): path = HDF5Dialog.getPath(datafile) self.mask_file_hdf5.setText(path or "")