mirror of
https://github.com/gwm17/spspy.git
synced 2024-11-22 18:18:52 -05:00
Add in levels export for SPSPlot. Fix some unit label typos.
This commit is contained in:
parent
8ca50ee621
commit
ad0c38e313
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ __pycache__/
|
|||
.vs/
|
||||
*.sps
|
||||
*.spanc
|
||||
*.csv
|
|
@ -2,6 +2,7 @@ from .SPSReaction import *
|
|||
from .SPSTarget import *
|
||||
from .data.NuclearData import *
|
||||
from dataclasses import dataclass, field
|
||||
import csv
|
||||
|
||||
@dataclass
|
||||
class Excitation:
|
||||
|
@ -61,4 +62,10 @@ class SPSPlot:
|
|||
rho = datum.rxn.convert_ejectile_KE_2_rho(ke)
|
||||
datum.excitations.append(Excitation(excitation, ke, rho))
|
||||
|
||||
|
||||
def export_reaction_data(self, fileName: str) -> None:
|
||||
with open(fileName, "w", newline='') as outputFile:
|
||||
csvWriter = csv.writer(outputFile, dialect="excel")
|
||||
csvWriter.writerow(["Reaction", "Excitation(MeV)", "Rho(cm)", "EjectileKE(MeV)", "Z-Offset(cm)"])
|
||||
for datum in self.data.values():
|
||||
for point in datum.excitations:
|
||||
csvWriter.writerow([repr(datum.rxn), f"{point.excitation:.3f}", f"{point.rho:.3f}", f"{point.kineticEnergy:.3f}", f"{point.fpZ:.3f}"])
|
||||
|
|
|
@ -76,6 +76,11 @@ class SPSPlotGUI(QMainWindow):
|
|||
newReactionAction.triggered.connect(self.handle_new_reaction)
|
||||
newTargetAction.triggered.connect(self.handle_new_target)
|
||||
|
||||
self.exportMenu = self.menuBar().addMenu("&Export")
|
||||
exportLevels = QAction("Export levels to csv...", self)
|
||||
self.exportMenu.addAction(exportLevels)
|
||||
exportLevels.triggered.connect(self.handle_export_levels)
|
||||
|
||||
def create_inputs(self) -> None:
|
||||
inputLayout = QHBoxLayout()
|
||||
self.inputGroupBox = QGroupBox("Adjustable Inputs", self.plotTab)
|
||||
|
@ -109,7 +114,7 @@ class SPSPlotGUI(QMainWindow):
|
|||
self.exButton.toggle()
|
||||
self.keButton = QRadioButton("Ejectile Kinetic energy (MeV)", self.energyButtonGroup)
|
||||
self.keButton.toggled.connect(self.handle_ke_switch)
|
||||
self.zButton = QRadioButton("Focal Plane Z Shift (mm)", self.energyButtonGroup)
|
||||
self.zButton = QRadioButton("Focal Plane Z Shift (cm)", self.energyButtonGroup)
|
||||
self.zButton.toggled.connect(self.handle_z_switch)
|
||||
buttonLayout.addWidget(self.exButton)
|
||||
buttonLayout.addWidget(self.keButton)
|
||||
|
@ -209,6 +214,11 @@ class SPSPlotGUI(QMainWindow):
|
|||
self.plotType = PlotType.PLOT_Z
|
||||
self.update_plot()
|
||||
|
||||
def handle_export_levels(self) -> None:
|
||||
fileName = QFileDialog.getSaveFileName(self, "Export Levels to CSV","./","Comma-Separated Values File (*.csv)")
|
||||
if fileName[0]:
|
||||
self.sps.export_reaction_data(fileName[0])
|
||||
|
||||
def add_reaction(self, rxnParams: RxnParameters, targName: str) -> None:
|
||||
rxnParams.beamEnergy = self.bkeInput.value()
|
||||
rxnParams.spsAngle = self.angleInput.value()
|
||||
|
|
Loading…
Reference in New Issue
Block a user