mirror of
https://github.com/gwm17/spspy.git
synced 2024-11-26 12:08:51 -05:00
Compare commits
3 Commits
c866c07abc
...
1d6af4966a
Author | SHA1 | Date | |
---|---|---|---|
Gordon McCann | 1d6af4966a | ||
Gordon McCann | 41781a374f | ||
Gordon McCann | 462e959100 |
|
@ -80,6 +80,12 @@ class Spanc:
|
|||
self.calibrations[data.peakID] = data
|
||||
return
|
||||
|
||||
def remove_calibration(self, data: Peak) -> bool:
|
||||
if data.peakID not in self.calibrations.keys():
|
||||
return False
|
||||
self.calibrations.pop(data.peakID)
|
||||
return True
|
||||
|
||||
def add_output(self, data: Peak) -> None:
|
||||
if data.peakID == INVALID_PEAK_ID:
|
||||
data.peakID = len(self.outputs)
|
||||
|
|
|
@ -116,6 +116,7 @@ class SpancGUI(QMainWindow):
|
|||
self.tablelayout.addWidget(self.targetGroup)
|
||||
self.targetTable.resizeColumnsToContents()
|
||||
self.targetTable.cellDoubleClicked.connect(self.handle_update_target)
|
||||
self.targetTable.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
||||
|
||||
def create_reaction_table(self) -> None:
|
||||
self.rxnGroup = QGroupBox("Reactions", self.tableTab)
|
||||
|
@ -128,30 +129,33 @@ class SpancGUI(QMainWindow):
|
|||
self.tablelayout.addWidget(self.rxnGroup)
|
||||
self.reactionTable.resizeColumnsToContents()
|
||||
self.reactionTable.cellDoubleClicked.connect(self.handle_update_reaction)
|
||||
self.reactionTable.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
||||
|
||||
def create_calibration_table(self) -> None:
|
||||
self.calGroup = QGroupBox("Calibration Peaks", self.tableTab)
|
||||
calLayout = QVBoxLayout()
|
||||
self.calibrationTable = QTableWidget(self.calGroup)
|
||||
self.calibrationTable.setColumnCount(8)
|
||||
self.calibrationTable.setHorizontalHeaderLabels(["Reaction","x(mm)","ux stat.(mm)","ux sys.(mm)","rho(cm)","urho(cm)","Ex(MeV)","uEx(MeV)"])
|
||||
self.calibrationTable.setColumnCount(9)
|
||||
self.calibrationTable.setHorizontalHeaderLabels(["Peak ID","Reaction","x(mm)","ux stat.(mm)","ux sys.(mm)","rho(cm)","urho(cm)","Ex(MeV)","uEx(MeV)"])
|
||||
calLayout.addWidget(self.calibrationTable)
|
||||
self.calGroup.setLayout(calLayout)
|
||||
self.tablelayout.addWidget(self.calGroup)
|
||||
self.calibrationTable.resizeColumnsToContents()
|
||||
self.calibrationTable.cellDoubleClicked.connect(self.handle_update_calibration)
|
||||
self.calibrationTable.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
||||
|
||||
def create_output_table(self) -> None:
|
||||
self.outGroup = QGroupBox("Output Peaks", self.tableTab)
|
||||
outLayout = QVBoxLayout()
|
||||
self.outputTable = QTableWidget(self.outGroup)
|
||||
self.outputTable.setColumnCount(12)
|
||||
self.outputTable.setHorizontalHeaderLabels(["Reaction","x(mm)","ux stat.(mm)","ux sys.(mm)","rho(cm)","urho(cm)","Ex(MeV)","uEx(MeV)","FWHM(mm)","uFWHM(mm)","FWHM(MeV)","uFWHM(MeV)"])
|
||||
self.outputTable.setColumnCount(13)
|
||||
self.outputTable.setHorizontalHeaderLabels(["Peak ID", "Reaction","x(mm)","ux stat.(mm)","ux sys.(mm)","rho(cm)","urho(cm)","Ex(MeV)","uEx(MeV)","FWHM(mm)","uFWHM(mm)","FWHM(MeV)","uFWHM(MeV)"])
|
||||
outLayout.addWidget(self.outputTable)
|
||||
self.outGroup.setLayout(outLayout)
|
||||
self.tablelayout.addWidget(self.outGroup)
|
||||
self.outputTable.resizeColumnsToContents()
|
||||
self.outputTable.cellDoubleClicked.connect(self.handle_update_output)
|
||||
self.outputTable.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
||||
|
||||
def create_fit_result_text(self) -> None:
|
||||
self.fitTextGroup = QGroupBox("Fit Results", self.plotTab)
|
||||
|
@ -234,11 +238,15 @@ class SpancGUI(QMainWindow):
|
|||
return
|
||||
|
||||
def handle_update_calibration(self, row: int, col: int) -> None:
|
||||
peakData = self.spanc.calibrations[row]
|
||||
peakID = int(self.calibrationTable.item(row, 0).text())
|
||||
peakData = self.spanc.calibrations[peakID]
|
||||
calDia = PeakDialog(PeakType.CALIBRATION, self.spanc.reactions.keys(), self, peak=peakData)
|
||||
calDia.new_peak.connect(self.spanc.add_calibration)
|
||||
calDia.delete_peak.connect(self.spanc.remove_calibration)
|
||||
if calDia.exec():
|
||||
self.update_calibration_table()
|
||||
if self.spanc.isFit == True:
|
||||
self.handle_run_fit()
|
||||
return
|
||||
|
||||
def handle_new_output(self) -> None:
|
||||
|
@ -249,7 +257,8 @@ class SpancGUI(QMainWindow):
|
|||
return
|
||||
|
||||
def handle_update_output(self, row: int, col: int) -> None:
|
||||
peakData = self.spanc.calibrations[row]
|
||||
peakID = int(self.calibrationTable.item(row, 0).text())
|
||||
peakData = self.spanc.outputs[peakID]
|
||||
outDia = PeakDialog(PeakType.OUTPUT, self.spanc.reactions.keys(), self, peak=peakData)
|
||||
outDia.new_peak.connect(self.spanc.add_output)
|
||||
if outDia.exec():
|
||||
|
@ -319,14 +328,15 @@ class SpancGUI(QMainWindow):
|
|||
self.calibrationTable.setRowCount(len(self.spanc.calibrations))
|
||||
self.calibrationTable.setVerticalHeaderLabels(self.spanc.calibrations.keys())
|
||||
for row, peak in enumerate(self.spanc.calibrations.values()):
|
||||
self.calibrationTable.setItem(row, 0, QTableWidgetItem(peak.rxnName))
|
||||
self.calibrationTable.setItem(row, 1, QTableWidgetItem(str(peak.position)))
|
||||
self.calibrationTable.setItem(row, 2, QTableWidgetItem(str(peak.positionErrStat)))
|
||||
self.calibrationTable.setItem(row, 3, QTableWidgetItem(str(peak.positionErrSys)))
|
||||
self.calibrationTable.setItem(row, 4, QTableWidgetItem(str(peak.rho)))
|
||||
self.calibrationTable.setItem(row, 5, QTableWidgetItem(str(peak.rhoErr)))
|
||||
self.calibrationTable.setItem(row, 6, QTableWidgetItem(str(peak.excitation)))
|
||||
self.calibrationTable.setItem(row, 7, QTableWidgetItem(str(peak.excitationErr)))
|
||||
self.calibrationTable.setItem(row, 0, QTableWidgetItem(str(peak.peakID)))
|
||||
self.calibrationTable.setItem(row, 1, QTableWidgetItem(peak.rxnName))
|
||||
self.calibrationTable.setItem(row, 2, QTableWidgetItem(str(peak.position)))
|
||||
self.calibrationTable.setItem(row, 3, QTableWidgetItem(str(peak.positionErrStat)))
|
||||
self.calibrationTable.setItem(row, 4, QTableWidgetItem(str(peak.positionErrSys)))
|
||||
self.calibrationTable.setItem(row, 5, QTableWidgetItem(str(peak.rho)))
|
||||
self.calibrationTable.setItem(row, 6, QTableWidgetItem(str(peak.rhoErr)))
|
||||
self.calibrationTable.setItem(row, 7, QTableWidgetItem(str(peak.excitation)))
|
||||
self.calibrationTable.setItem(row, 8, QTableWidgetItem(str(peak.excitationErr)))
|
||||
self.calibrationTable.resizeColumnsToContents()
|
||||
self.calibrationTable.resizeRowsToContents()
|
||||
|
||||
|
@ -334,18 +344,19 @@ class SpancGUI(QMainWindow):
|
|||
self.outputTable.setRowCount(len(self.spanc.outputs))
|
||||
self.outputTable.setVerticalHeaderLabels(self.spanc.outputs.keys())
|
||||
for row, peak in enumerate(self.spanc.outputs.values()):
|
||||
self.outputTable.setItem(row, 0, QTableWidgetItem(peak.rxnName))
|
||||
self.outputTable.setItem(row, 1, QTableWidgetItem(str(peak.position)))
|
||||
self.outputTable.setItem(row, 2, QTableWidgetItem(str(peak.positionErrStat)))
|
||||
self.outputTable.setItem(row, 3, QTableWidgetItem(str(peak.positionErrSys)))
|
||||
self.outputTable.setItem(row, 4, QTableWidgetItem(str(peak.rho)))
|
||||
self.outputTable.setItem(row, 5, QTableWidgetItem(str(peak.rhoErr)))
|
||||
self.outputTable.setItem(row, 6, QTableWidgetItem(str(peak.excitation)))
|
||||
self.outputTable.setItem(row, 7, QTableWidgetItem(str(peak.excitationErr)))
|
||||
self.outputTable.setItem(row, 8, QTableWidgetItem(str(peak.positionFWHM)))
|
||||
self.outputTable.setItem(row, 9, QTableWidgetItem(str(peak.positionFWHMErr)))
|
||||
self.outputTable.setItem(row, 10, QTableWidgetItem(str(peak.excitationFWHM)))
|
||||
self.outputTable.setItem(row, 11, QTableWidgetItem(str(peak.excitationFWHMErr)))
|
||||
self.outputTable.setItem(row, 0, QTableWidgetItem(str(peak.peakID)))
|
||||
self.outputTable.setItem(row, 1, QTableWidgetItem(peak.rxnName))
|
||||
self.outputTable.setItem(row, 2, QTableWidgetItem(str(peak.position)))
|
||||
self.outputTable.setItem(row, 3, QTableWidgetItem(str(peak.positionErrStat)))
|
||||
self.outputTable.setItem(row, 4, QTableWidgetItem(str(peak.positionErrSys)))
|
||||
self.outputTable.setItem(row, 5, QTableWidgetItem(str(peak.rho)))
|
||||
self.outputTable.setItem(row, 6, QTableWidgetItem(str(peak.rhoErr)))
|
||||
self.outputTable.setItem(row, 7, QTableWidgetItem(str(peak.excitation)))
|
||||
self.outputTable.setItem(row, 8, QTableWidgetItem(str(peak.excitationErr)))
|
||||
self.outputTable.setItem(row, 9, QTableWidgetItem(str(peak.positionFWHM)))
|
||||
self.outputTable.setItem(row, 10, QTableWidgetItem(str(peak.positionFWHMErr)))
|
||||
self.outputTable.setItem(row, 11, QTableWidgetItem(str(peak.excitationFWHM)))
|
||||
self.outputTable.setItem(row, 12, QTableWidgetItem(str(peak.excitationFWHMErr)))
|
||||
self.outputTable.resizeColumnsToContents()
|
||||
self.outputTable.resizeRowsToContents()
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ from ..Spanc import Peak, PeakType, INVALID_PEAK_ID
|
|||
from PySide6.QtWidgets import QLabel
|
||||
from PySide6.QtWidgets import QVBoxLayout, QFormLayout, QGroupBox
|
||||
from PySide6.QtWidgets import QComboBox, QDoubleSpinBox
|
||||
from PySide6.QtWidgets import QDialog, QDialogButtonBox
|
||||
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QPushButton
|
||||
from PySide6.QtCore import Signal
|
||||
|
||||
class PeakDialog(QDialog):
|
||||
new_peak = Signal(Peak)
|
||||
delete_peak = Signal(Peak)
|
||||
|
||||
def __init__(self, peakType: PeakType, rxnList: list[str], parent=None, peak: Peak=None):
|
||||
super().__init__(parent)
|
||||
|
@ -26,14 +27,19 @@ class PeakDialog(QDialog):
|
|||
if peakType == PeakType.CALIBRATION:
|
||||
self.create_calibration_inputs()
|
||||
if peak is not None:
|
||||
self.setWindowTitle(f"Update A {peakType.value} Peak")
|
||||
self.set_calibration_inputs(peak)
|
||||
self.peakID = peak.peakID
|
||||
self.buttonBox.accepted.connect(self.send_update_calibration_peak)
|
||||
self.deleteButton = QPushButton("Delete", self)
|
||||
self.deleteButton.clicked.connect(self.send_delete_calibration_peak)
|
||||
self.centralLayout.addWidget(self.deleteButton)
|
||||
else:
|
||||
self.buttonBox.accepted.connect(self.send_calibration_peak)
|
||||
elif peakType == PeakType.OUTPUT:
|
||||
self.create_output_inputs()
|
||||
if peak is not None:
|
||||
self.setWindowTitle(f"Update A {peakType.value} Peak")
|
||||
self.set_output_inputs(peak)
|
||||
self.peakID = peak.peakID
|
||||
self.buttonBox.accepted.connect(self.send_update_output_peak)
|
||||
|
@ -58,8 +64,8 @@ class PeakDialog(QDialog):
|
|||
self.uexInput = QDoubleSpinBox(self.inputGroupBox)
|
||||
self.uexInput.setDecimals(6)
|
||||
inputLayout.addRow("Position(mm)", self.xInput)
|
||||
inputLayout.addRow("Position Stat. Error(mm)", self.uxstatInput)
|
||||
inputLayout.addRow("Position Sys. Error(mm)", self.uxsysInput)
|
||||
inputLayout.addRow("Position Stat. Error(mm)", self.uxstatInput)
|
||||
inputLayout.addRow("Excitation Energy(MeV)", self.exInput)
|
||||
inputLayout.addRow("Excitation Energy Error(MeV)", self.uexInput)
|
||||
self.inputGroupBox.setLayout(inputLayout)
|
||||
|
@ -82,8 +88,8 @@ class PeakDialog(QDialog):
|
|||
self.ufwhmInput = QDoubleSpinBox(self.inputGroupBox)
|
||||
self.ufwhmInput.setDecimals(6)
|
||||
inputLayout.addRow("Position(mm)", self.xInput)
|
||||
inputLayout.addRow("Position Stat. Error(mm)", self.uxstatInput)
|
||||
inputLayout.addRow("Position Sys. Error(mm)", self.uxsysInput)
|
||||
inputLayout.addRow("Position Stat. Error(mm)", self.uxstatInput)
|
||||
inputLayout.addRow("Position FWHM(mm)", self.fwhmInput)
|
||||
inputLayout.addRow("Position FWHM Error(mm)", self.ufwhmInput)
|
||||
self.inputGroupBox.setLayout(inputLayout)
|
||||
|
@ -115,6 +121,12 @@ class PeakDialog(QDialog):
|
|||
positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(), rxnName=self.rxnNameBox.currentText(), peakID=self.peakID)
|
||||
self.new_peak.emit(peak)
|
||||
|
||||
def send_delete_calibration_peak(self) -> None:
|
||||
peak = Peak(excitation=self.exInput.value(), excitationErr=self.uexInput.value(), position=self.xInput.value(),
|
||||
positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(), rxnName=self.rxnNameBox.currentText(), peakID=self.peakID)
|
||||
self.delete_peak.emit(peak)
|
||||
self.done(3)
|
||||
|
||||
def send_output_peak(self) -> None:
|
||||
peak = Peak(position=self.xInput.value(), positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(),
|
||||
positionFWHM=self.fwhmInput.value(), positionFWHMErr=self.ufwhmInput.value(), rxnName=self.rxnNameBox.currentText(), peakID=INVALID_PEAK_ID)
|
||||
|
|
Loading…
Reference in New Issue
Block a user