def openFile(self): filepath, filter = QtGui.QFileDialog.getOpenFileName(parent=self, caption='Open a PL spectrum file') if not filepath: return dirpath, filename = os.path.split(filepath) self.setWindowTitle(u'SimpleFit - {}'.format(filename)) spectrum = openMeasuredSpectrum(filepath) # Check if the system response removed is included. # If not, ask user to select a system response file. print spectrum.intensity if not len(spectrum.intensity): sysres_filepath, filter = QtGui.QFileDialog.getOpenFileName( parent=self, caption='Open a system response file') if not sysres_filepath: return spectrum = openMeasuredSpectrum(filepath, sysres_filepath) # remove the previous measured spectrum if self.spectrum: self.plot.removeSpectrum(self.spectrum) # plot the measured spectrum self.plot.addSpectrum(spectrum) self.spectrum = spectrum # update the simulated spectrum self.control.setEnergy(spectrum.energy) self.control.setIntensity(spectrum.intensity)
# Create main window with grid layout w = QtGui.QWidget() layout = QtGui.QHBoxLayout() # Load the user's measured spectrum from simplepl.utils import open_dialog print 'Select a PL file...' filepath = open_dialog('*.*') print 'PL File Path:', filepath print 'Select the system response file to use (if any)...' sysres_filepath = open_dialog('*.*') print 'System Response File Path:', sysres_filepath measuredSpectrum = openMeasuredSpectrum(filepath, sysres_filepath) energy = measuredSpectrum.getEnergy() intensity = measuredSpectrum.getIntensity() # Create some simulated spectrum bg = ConstantSpectrum(energy=energy) peak1 = GaussianSpectrum(energy=energy) peak2 = GaussianSpectrum(energy=energy) peak3 = GaussianSpectrum(energy=energy) sum = SummedSpectrum(bg, peak1, peak2, peak3) sum.energy = energy bg.constant.max = peak1.amplitude.max = \ peak2.amplitude.max = peak3.amplitude.max = intensity.max() peak1.center.min = peak2.center.min = peak3.center.min = energy.min() peak1.center.max = peak2.center.max = peak3.center.max = energy.max() peak1.center.value = peak2.center.value = \