Commit 0d9bcea6 authored by 3Yan's avatar 3Yan

Reactivity support - improvement

* Reactivity support as intended
* code not tested against files in progres
* stability not tested
parent 75ea1514
......@@ -21,6 +21,9 @@ def settings():
("imggen/dpi", 300),
("imggen/xtics", 5),
("imggen/onlymanann", False),
("reactivity/index", 0),
("reactivity/coef1", 0),
("reactivity/coef2", 0),
("recents", "")}
[settings.setValue(*i)
for i in defvals if not settings.contains(i[0])]
......
......@@ -20,12 +20,23 @@ matplotlib.use("Qt5Agg")
logger = logging.getLogger('drlLogger')
def update_parselect(augCanvas, parselect):
index = parselect.currentIndex()
if index == -1:
index = cf.settings().value("reactivity/index", type=int)
parlist = [ ": ".join([str(i), j]) for i,j in
enumerate(augCanvas.ms['params'][0])]
parselect.clear()
parselect.addItems(parlist)
if index <= len(parlist):
parselect.setCurrentIndex(index)
def pop_dial(augCanvas, drls, graph, labels):
def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
logger.debug("populating reactivity dialog")
# Do not do anything when data set is not populated
if len(augCanvas.ds) == 0:
return
update_parselect(augCanvas, parselect)
graph.clear()
gt.pop_plot([0], [0], graph, labels)
names, times, intensities = drl.get_daughterset(augCanvas.ds, drls)
......@@ -39,8 +50,8 @@ def pop_dial(augCanvas, drls, graph, labels):
toavg = []
for i in range(lastpos,parlen):
if float(params[i][0]) == time:
#toavg.append(param[36])
toavg.append((-(float(params[i][1])-24.09))/1000)
toavg.append((float(params[i][parselect.currentIndex()])
-coef1.value())*coef2.value())
lastpos = i
elif float(params[i][0]) > time:
break
......@@ -68,7 +79,8 @@ def main_window(parent, augCanvas, update_signal, drls):
QtWidgets.QDialog.closeEvent(widget, event)
def update_fnc():
pop_dial(augCanvas, drls, dialspect, reactlabels)
pop_dial(augCanvas, drls, dialspect, reactlabels, parselect,
coef1, coef2)
dial_widget = QtWidgets.QDialog(
parent, windowTitle='TSQ reactivity interpreter')
......@@ -84,8 +96,42 @@ def main_window(parent, augCanvas, update_signal, drls):
gt.zoom_factory(dialspect, 1.15, reactlabels)
gt.pan_factory(dialspect, reactlabels)
parlabel = QtWidgets.QLabel("Parameter: ")
parselect = QtWidgets.QComboBox()
parselect.currentIndexChanged.connect(lambda x:
cf.settings().setValue("reactivity/index", x))
formula = QtWidgets.QLabel(
"Formula for the x-axis: (Parameter - a) * b")
label1 = QtWidgets.QLabel("a: ", alignment=130)
coef1 = QtWidgets.QDoubleSpinBox(
decimals=4, minimum=float("-inf"), maximum=float("inf"))
coef1.setValue(cf.settings().value("reactivity/coef1", type=float))
coef1.valueChanged.connect(lambda x:
cf.settings().setValue("reactivity/coef1", x))
label2 = QtWidgets.QLabel("b: ", alignment=130)
coef2 = QtWidgets.QDoubleSpinBox(
decimals=4, minimum=float("-inf"), maximum=float("inf"))
coef2.setValue(cf.settings().value("reactivity/coef2", type=float))
coef2.valueChanged.connect(lambda x:
cf.settings().setValue("reactivity/coef2", x))
pushbtn = QtWidgets.QPushButton("Recalculate")
pushbtn.clicked.connect(lambda: pop_dial(
augCanvas, drls, dialspect, reactlabels, parselect, coef1, coef2))
param_layout = QtWidgets.QHBoxLayout()
[param_layout.addWidget(i) for i in [parlabel, parselect]]
param_layout.addStretch()
coef_layout = QtWidgets.QHBoxLayout()
for i in [label1, coef1, label2, coef2]:
coef_layout.addWidget(i)
dial_layout = QtWidgets.QVBoxLayout(dial_widget)
dial_layout.addWidget(graph_canvas)
dial_layout.addLayout(param_layout)
dial_layout.addWidget(formula)
dial_layout.addLayout(coef_layout)
dial_layout.addWidget(pushbtn)
dial_widget.setFocus()
dial_widget.show()
pop_dial(augCanvas, drls, dialspect, reactlabels)
pop_dial(augCanvas, drls, dialspect, reactlabels, parselect, coef1, coef2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment