1
0
Fork 0
mirror of https://github.com/gwm17/spspy.git synced 2024-11-22 18:18:52 -05:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Gordon McCann 2562156943 Update README 2022-12-07 11:33:19 -05:00
Gordon McCann ae1781b2fa Fix some formating, make text prettier. 2022-12-07 11:31:50 -05:00
5 changed files with 54 additions and 36 deletions

View File

@ -10,7 +10,7 @@ The recommended install for SPSPy dependencies is via pip.
To create a virtual environment with pip in the terminal for MacOS or Linux use `python3 -m venv env` to create a local virtual environment named `env` (or whatever name you'd like), or on Windows use `py -m venv env` to do the same. To activate your new environment run `source env/bin/activate` in MacOS or Linux, or `.\env\Scripts\activate`. Now you can run the above `pip` command to install all dependencies to the virtual environment. To leave the virtual environment use the command `deactivate` in your terminal. To create a virtual environment with pip in the terminal for MacOS or Linux use `python3 -m venv env` to create a local virtual environment named `env` (or whatever name you'd like), or on Windows use `py -m venv env` to do the same. To activate your new environment run `source env/bin/activate` in MacOS or Linux, or `.\env\Scripts\activate`. Now you can run the above `pip` command to install all dependencies to the virtual environment. To leave the virtual environment use the command `deactivate` in your terminal.
## SPSPlot ## SPSPlot
This tool is intended to be used for guiding the settings of the SPS to show specific states on the focal plane detector. The user gives the program reaction information, and the program runs through the kinematics to calculate the energies of ejecta into the the SESPS. To evaluate different states, the program scrapes a list of levels from [NNDC](https://www.nndc.bnl.gov/), and these levels are then passed on to the reaction handler. These levels are then shown on the screen with labels. The labels can be modified to show either the excitation energy of the state, the kinetic energy of the ejectile, or the focal plane z-offset for a state. Note that since levels are obtained from NNDC, SPSPlot requires an internet connection. This tool is intended to be used for guiding the settings of the SPS to show specific states on the focal plane detector. The user gives the program reaction information, and the program runs through the kinematics to calculate the energies of ejecta into the the SESPS. To evaluate different states, the program scrapes a list of levels from [NNDC](https://www.nndc.bnl.gov/), and these levels are then passed on to the reaction handler. These levels are then shown on the screen with labels. The labels can be modified to show either the excitation energy of the state, the kinetic energy of the ejectile, or the focal plane z-offset for a state. Note that since levels are obtained from NNDC, SPSPlot requires an internet connection. SPSPlot can also export the calculated reaction information to a csv file.
## SPANC ## SPANC
SPANC is the program used to calibrate SESPS focal plane spectra. It works by the user specifying a target, reaction, calibration peaks, and output peaks. The target is a description of the physical target foil used in the SPS, which is used to calculate energy loss effects. The target must contain the isotope used as the target in the reaction description. The reaction indicates to the program what type of ejecta are expected, as well as the settings of the spectrograph. Calibration data is given as centroids from a spectrum with correspoding excitation energies, as well as associated uncertainties. The calibration peaks are then fit using the scipy ODR package (see scipy ODR for more documentation). The fit is plotted, and the results are shown in a table. Additionally, residuals are plotted and shown in a table. The user can then feed the program an output peak, or a peak for which the user would like to calculate the excitation energy of a state using the calibration fit. The peak excitation energy will then be reported, with uncertainty. The user can also give a FWHM to be converted from focal plane position to energy. SPANC is the program used to calibrate SESPS focal plane spectra. It works by the user specifying a target, reaction, calibration peaks, and output peaks. The target is a description of the physical target foil used in the SPS, which is used to calculate energy loss effects. The target must contain the isotope used as the target in the reaction description. The reaction indicates to the program what type of ejecta are expected, as well as the settings of the spectrograph. Calibration data is given as centroids from a spectrum with correspoding excitation energies, as well as associated uncertainties. The calibration peaks are then fit using the scipy ODR package (see scipy ODR for more documentation). The fit is plotted, and the results are shown in a table. Additionally, residuals are plotted and shown in a table. The user can then feed the program an output peak, or a peak for which the user would like to calculate the excitation energy of a state using the calibration fit. The peak excitation energy will then be reported, with uncertainty. The user can also give a FWHM to be converted from focal plane position to energy.

View File

@ -19,6 +19,9 @@ import matplotlib as mpl
import sys import sys
import pickle import pickle
DEFAULT_RHO_MIN: float = 69.0
DEFAULT_RHO_MAX: float = 87.0
class PlotType(Enum): class PlotType(Enum):
PLOT_EX = auto() PLOT_EX = auto()
PLOT_KE = auto() PLOT_KE = auto()
@ -49,11 +52,12 @@ class SPSPlotGUI(QMainWindow):
self.create_canvas() self.create_canvas()
self.create_inputs() self.create_inputs()
self.create_target_table() self.create_target_table()
self.update_plot()
self.show() self.show()
def create_canvas(self) -> None: def create_canvas(self) -> None:
self.canvas = MPLCanvas(self.plotTab, width=14, height=5, dpi=100) self.canvas = MPLCanvas(self.plotTab, width=14, height=5, dpi=100)
self.plotLayout.addWidget(self.canvas, 5) self.plotLayout.addWidget(self.canvas, 4)
def create_menus(self) -> None: def create_menus(self) -> None:
self.fileMenu = self.menuBar().addMenu("&File") self.fileMenu = self.menuBar().addMenu("&File")
@ -82,58 +86,67 @@ class SPSPlotGUI(QMainWindow):
exportLevels.triggered.connect(self.handle_export_levels) exportLevels.triggered.connect(self.handle_export_levels)
def create_inputs(self) -> None: def create_inputs(self) -> None:
inputLayout = QHBoxLayout() inputLayout = QVBoxLayout()
self.inputGroupBox = QGroupBox("Adjustable Inputs", self.plotTab) self.inputGroupBox = QGroupBox("Adjustable Inputs", self.plotTab)
rhoMinLabel = QLabel("Rho Min", self.inputGroupBox)
self.rhoMinInput = QDoubleSpinBox(self.inputGroupBox) self.spsGroupBox = QGroupBox("SPS Parameters", self.inputGroupBox)
spsGroupLayout = QHBoxLayout()
rhoMinLabel = QLabel("<p>&rho;<sub>Min<\sub><\p>", self.spsGroupBox)
self.rhoMinInput = QDoubleSpinBox(self.spsGroupBox)
self.rhoMinInput.setRange(0.0, 150.0) self.rhoMinInput.setRange(0.0, 150.0)
self.rhoMinInput.setValue(DEFAULT_RHO_MIN)
self.sps.rhoMin = DEFAULT_RHO_MIN
self.rhoMinInput.setSuffix(" cm") self.rhoMinInput.setSuffix(" cm")
rhoMaxLabel = QLabel("RhoMax", self.inputGroupBox) rhoMaxLabel = QLabel("<p>&rho;<sub>Max<\sub><\p>", self.spsGroupBox)
self.rhoMaxInput = QDoubleSpinBox(self.inputGroupBox) self.rhoMaxInput = QDoubleSpinBox(self.spsGroupBox)
self.rhoMaxInput.setRange(0.0,150.0) self.rhoMaxInput.setRange(0.0,150.0)
self.rhoMaxInput.setValue(DEFAULT_RHO_MAX)
self.sps.rhoMax = DEFAULT_RHO_MAX
self.rhoMaxInput.setSuffix(" cm") self.rhoMaxInput.setSuffix(" cm")
bkeLabel = QLabel("Beam KE", self.inputGroupBox) bkeLabel = QLabel("<p>E<sub>beam<\sub><\p>", self.spsGroupBox)
self.bkeInput = QDoubleSpinBox(self.inputGroupBox) self.bkeInput = QDoubleSpinBox(self.spsGroupBox)
self.bkeInput.setRange(0.0, 500.0) self.bkeInput.setRange(0.0, 500.0)
self.bkeInput.setSuffix(" MeV") self.bkeInput.setSuffix(" MeV")
bfieldLabel = QLabel("B-field", self.inputGroupBox) bfieldLabel = QLabel("B", self.spsGroupBox)
self.bfieldInput = QDoubleSpinBox(self.inputGroupBox) self.bfieldInput = QDoubleSpinBox(self.spsGroupBox)
self.bfieldInput.setRange(0.0, 17.0) self.bfieldInput.setRange(0.0, 17.0)
self.bfieldInput.setSuffix(" kG") self.bfieldInput.setSuffix(" kG")
angleLabel = QLabel("Angle", self.inputGroupBox) angleLabel = QLabel("<p>&theta;<sub>SPS<\sub><\p>", self.spsGroupBox)
self.angleInput = QDoubleSpinBox(self.inputGroupBox) self.angleInput = QDoubleSpinBox(self.spsGroupBox)
self.angleInput.setRange(0.0, 180.0) self.angleInput.setRange(0.0, 180.0)
self.angleInput.setSuffix(" deg") self.angleInput.setSuffix(" deg")
self.runButton = QPushButton("Set", self.inputGroupBox) self.runButton = QPushButton("Set", self.spsGroupBox)
self.runButton.clicked.connect(self.handle_run) self.runButton.clicked.connect(self.handle_run)
spsGroupLayout.addWidget(rhoMinLabel, 1)
spsGroupLayout.addWidget(self.rhoMinInput, 2)
spsGroupLayout.addWidget(rhoMaxLabel,1 )
spsGroupLayout.addWidget(self.rhoMaxInput, 2)
spsGroupLayout.addWidget(bkeLabel, 1)
spsGroupLayout.addWidget(self.bkeInput, 2)
spsGroupLayout.addWidget(bfieldLabel, 1)
spsGroupLayout.addWidget(self.bfieldInput, 2)
spsGroupLayout.addWidget(angleLabel, 1)
spsGroupLayout.addWidget(self.angleInput, 2)
spsGroupLayout.addWidget(self.runButton, 1)
self.spsGroupBox.setLayout(spsGroupLayout)
self.energyButtonGroup = QGroupBox("Ex/KE switch",self.plotTab) self.energyButtonGroup = QGroupBox("Labels",self.plotTab)
buttonLayout = QHBoxLayout() buttonLayout = QHBoxLayout()
self.exButton = QRadioButton("Excitation energy (MeV)", self.energyButtonGroup) self.exButton = QRadioButton("Excitation Energy(MeV)", self.energyButtonGroup)
self.exButton.toggled.connect(self.handle_ex_switch) self.exButton.toggled.connect(self.handle_ex_switch)
self.exButton.toggle() self.exButton.toggle()
self.keButton = QRadioButton("Ejectile Kinetic energy (MeV)", self.energyButtonGroup) self.keButton = QRadioButton("Ejectile KE(MeV)", self.energyButtonGroup)
self.keButton.toggled.connect(self.handle_ke_switch) self.keButton.toggled.connect(self.handle_ke_switch)
self.zButton = QRadioButton("Focal Plane Z Shift (cm)", self.energyButtonGroup) self.zButton = QRadioButton("FocalPlane Z-Shift(cm)", self.energyButtonGroup)
self.zButton.toggled.connect(self.handle_z_switch) self.zButton.toggled.connect(self.handle_z_switch)
buttonLayout.addWidget(self.exButton) buttonLayout.addWidget(self.exButton)
buttonLayout.addWidget(self.keButton) buttonLayout.addWidget(self.keButton)
buttonLayout.addWidget(self.zButton) buttonLayout.addWidget(self.zButton)
self.energyButtonGroup.setLayout(buttonLayout) self.energyButtonGroup.setLayout(buttonLayout)
inputLayout.addWidget(rhoMinLabel) inputLayout.addWidget(self.spsGroupBox)
inputLayout.addWidget(self.rhoMinInput)
inputLayout.addWidget(rhoMaxLabel)
inputLayout.addWidget(self.rhoMaxInput)
inputLayout.addWidget(bkeLabel)
inputLayout.addWidget(self.bkeInput)
inputLayout.addWidget(bfieldLabel)
inputLayout.addWidget(self.bfieldInput)
inputLayout.addWidget(angleLabel)
inputLayout.addWidget(self.angleInput)
inputLayout.addWidget(self.runButton)
self.inputGroupBox.setLayout(inputLayout)
inputLayout.addWidget(self.energyButtonGroup) inputLayout.addWidget(self.energyButtonGroup)
self.inputGroupBox.setLayout(inputLayout)
self.plotLayout.addWidget(self.inputGroupBox, 1) self.plotLayout.addWidget(self.inputGroupBox, 1)
@ -142,7 +155,9 @@ class SPSPlotGUI(QMainWindow):
tableLayout = QVBoxLayout() tableLayout = QVBoxLayout()
self.targetTable = QTableWidget(self.targetGroup) self.targetTable = QTableWidget(self.targetGroup)
self.targetTable.setColumnCount(6) self.targetTable.setColumnCount(6)
self.targetTable.setHorizontalHeaderLabels(["Layer1 Thickness(ug/cm^2", "Layer1 (Z, A, S)","Layer2 Thickness(ug/cm^2", "Layer2 (Z, A, S)","Layer3 Thickness(ug/cm^2", "Layer3 (Z, A, S)"]) self.targetTable.setHorizontalHeaderLabels(["L1 Thickness(ug/cm^2)", "L1 Compound",
"L2 Thickness(ug/cm^2)", "L2 Compound",
"L3 Thickness(ug/cm^2)", "Layer3 Compound"])
tableLayout.addWidget(self.targetTable) tableLayout.addWidget(self.targetTable)
self.targetGroup.setLayout(tableLayout) self.targetGroup.setLayout(tableLayout)
self.targetLayout.addWidget(self.targetGroup) self.targetLayout.addWidget(self.targetGroup)
@ -257,6 +272,7 @@ class SPSPlotGUI(QMainWindow):
self.canvas.axes.set_xlim(self.sps.rhoMin, self.sps.rhoMax) self.canvas.axes.set_xlim(self.sps.rhoMin, self.sps.rhoMax)
self.canvas.axes.set_yticks(range(1,len(self.sps.data)+2)) self.canvas.axes.set_yticks(range(1,len(self.sps.data)+2))
self.canvas.axes.set_yticklabels(ylabels) self.canvas.axes.set_yticklabels(ylabels)
self.canvas.axes.set_xlabel(r"$\rho$ (cm)")
self.canvas.draw() self.canvas.draw()
def update_inputs(self): def update_inputs(self):
@ -275,6 +291,8 @@ class SPSPlotGUI(QMainWindow):
self.targetTable.setCellWidget(row, 1+col*2, QLabel(str(layer))) self.targetTable.setCellWidget(row, 1+col*2, QLabel(str(layer)))
self.targetTable.resizeColumnsToContents() self.targetTable.resizeColumnsToContents()
self.targetTable.resizeRowsToContents() self.targetTable.resizeRowsToContents()
def run_spsplot_ui(): def run_spsplot_ui():
mpl.use("Qt5Agg") mpl.use("Qt5Agg")

View File

@ -110,7 +110,7 @@ class SpancGUI(QMainWindow):
targetLayout = QVBoxLayout() targetLayout = QVBoxLayout()
self.targetTable = QTableWidget(self.targetGroup) self.targetTable = QTableWidget(self.targetGroup)
self.targetTable.setColumnCount(6) self.targetTable.setColumnCount(6)
self.targetTable.setHorizontalHeaderLabels(["Layer1 Thickness(ug/cm^2", "Layer1 (Z, A, S)","Layer2 Thickness(ug/cm^2", "Layer2 (Z, A, S)","Layer3 Thickness(ug/cm^2", "Layer3 (Z, A, S)"]) self.targetTable.setHorizontalHeaderLabels(["L1 Thickness(ug/cm^2)", "L1 Compound","L2 Thickness(ug/cm^2)", "L2 Compound","L3 Thickness(ug/cm^2)", "L3 Compound"])
targetLayout.addWidget(self.targetTable) targetLayout.addWidget(self.targetTable)
self.targetGroup.setLayout(targetLayout) self.targetGroup.setLayout(targetLayout)
self.tablelayout.addWidget(self.targetGroup) self.tablelayout.addWidget(self.targetGroup)

View File

@ -11,7 +11,7 @@ matplotlib.rcParams["ytick.color"] = "w"
matplotlib.rcParams["text.color"] = "w" matplotlib.rcParams["text.color"] = "w"
class MPLCanvas(FigureCanvasQTAgg): class MPLCanvas(FigureCanvasQTAgg):
def __init__(self, parent=None, width=5, height=4, dpi=100): def __init__(self, parent=None, width=3, height=4, dpi=100):
self.fig = Figure(figsize=(width, height), dpi=dpi, edgecolor="black",linewidth=0.5) self.fig = Figure(figsize=(width, height), dpi=dpi, edgecolor="black",linewidth=0.5)
self.axes = self.fig.add_subplot(111) self.axes = self.fig.add_subplot(111)
self.axes.spines['top'].set_visible(False) self.axes.spines['top'].set_visible(False)

View File

@ -94,9 +94,9 @@ class ReactionDialog(QDialog):
self.bfieldInput = QDoubleSpinBox(self.parameterGroupBox) self.bfieldInput = QDoubleSpinBox(self.parameterGroupBox)
self.bfieldInput.setRange(MINIMUM_MAG_FIELD, MAXIMUM_MAG_FIELD) self.bfieldInput.setRange(MINIMUM_MAG_FIELD, MAXIMUM_MAG_FIELD)
self.bfieldInput.setDecimals(6) self.bfieldInput.setDecimals(6)
parameterLayout.addRow("Beam KE(Mev)",self.bkeInput) parameterLayout.addRow(QLabel("E<sub>beam</sub>(Mev)"),self.bkeInput)
parameterLayout.addRow("Theta(deg)",self.thetaInput) parameterLayout.addRow("<p>&theta;<sub>SPS</sub>(deg)</p>",self.thetaInput)
parameterLayout.addRow("Bfield(kG)",self.bfieldInput) parameterLayout.addRow("B(kG)",self.bfieldInput)
self.parameterGroupBox.setLayout(parameterLayout) self.parameterGroupBox.setLayout(parameterLayout)
self.layout.addWidget(self.parameterGroupBox) self.layout.addWidget(self.parameterGroupBox)