Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Zelenka
prasopes
Commits
803f0281
Commit
803f0281
authored
Aug 12, 2020
by
Yan
Browse files
Reactivity - Experimental support - header readout
* In reactivityParams header parameters can be selected now.
parent
000e8b79
Changes
3
Hide whitespace changes
Inline
Side-by-side
prasopes/__init__.py
View file @
803f0281
...
...
@@ -13,7 +13,7 @@ from . import zcetools_help
from
.
import
reactivitytools
__version__
=
"0.0.3
3
"
__version__
=
"0.0.3
4
"
__all__
=
[
'config'
,
'datatools'
,
'docks'
,
'drltools'
,
'drltoos_gui'
,
'filetools'
,
...
...
prasopes/config.py
View file @
803f0281
...
...
@@ -37,6 +37,7 @@ def settings():
(
"imggen/reactspecspec_yinch"
,
2
),
(
"imggen/reactspecspec_dpi"
,
300
),
(
"reactivity/index"
,
0
),
(
"reactivity/activetab"
,
0
),
(
"recents"
,
""
)}
[
settings
.
setValue
(
*
i
)
for
i
in
defvals
if
not
settings
.
contains
(
i
[
0
])]
...
...
prasopes/reactivitytools.py
View file @
803f0281
...
...
@@ -25,19 +25,21 @@ settings = cf.settings()
class
reactivityParam
(
QtWidgets
.
QHBoxLayout
):
"""Layout with annotated text/spin box connected to settings"""
def
__init__
(
self
,
parselect
,
type
,
valname
,
vallabel
,
def
__init__
(
self
,
parselect
,
tabber
,
type
,
valname
,
vallabel
,
min
=
None
,
max
=
None
,
decimals
=
4
):
super
().
__init__
()
self
.
valname
=
valname
self
.
addWidget
(
QtWidgets
.
QLabel
(
vallabel
,
alignment
=
130
))
def
getconfval
(
name
=
self
.
valname
,
parselect
=
parselect
):
par
=
"reactivity/{}_par{}"
.
format
(
name
,
parselect
.
currentIndex
())
def
getconfval
(
name
=
self
.
valname
,
parselect
=
parselect
,
tabber
=
tabber
):
ind
=
-
1
if
tabber
.
currentIndex
()
else
parselect
.
currentIndex
()
par
=
"reactivity/{}_par{}"
.
format
(
name
,
ind
)
logger
.
debug
(
"Getting "
+
par
)
return
settings
.
value
(
par
,
type
=
type
)
def
setconfval
(
x
,
name
=
self
.
valname
,
parselect
=
parselect
):
par
=
"reactivity/{}_par{}"
.
format
(
name
,
parselect
.
currentIndex
())
def
setconfval
(
x
,
name
=
self
.
valname
,
parselect
=
parselect
,
tabber
=
tabber
):
ind
=
-
1
if
tabber
.
currentIndex
()
else
parselect
.
currentIndex
()
par
=
"reactivity/{}_par{}"
.
format
(
name
,
ind
)
logger
.
debug
(
"Setting "
+
par
)
settings
.
setValue
(
par
,
x
)
if
type
in
(
int
,
float
):
...
...
@@ -52,12 +54,16 @@ class reactivityParam(QtWidgets.QHBoxLayout):
self
.
dial
.
valueChanged
.
connect
(
setconfval
)
parselect
.
currentIndexChanged
.
connect
(
lambda
_
:
self
.
dial
.
setValue
(
getconfval
()))
tabber
.
currentChanged
.
connect
(
lambda
_
:
self
.
dial
.
setValue
(
getconfval
()))
elif
type
==
str
:
self
.
dial
=
QtWidgets
.
QLineEdit
()
self
.
dial
.
setText
(
getconfval
())
self
.
dial
.
textChanged
.
connect
(
setconfval
)
parselect
.
currentIndexChanged
.
connect
(
lambda
_
:
self
.
dial
.
setText
(
getconfval
()))
tabber
.
currentChanged
.
connect
(
lambda
_
:
self
.
dial
.
setText
(
getconfval
()))
else
:
raise
ValueError
(
"excepted 'float', 'str' or 'int' as type"
)
self
.
addWidget
(
self
.
dial
,
stretch
=
1
)
...
...
@@ -112,6 +118,11 @@ def update_parselect(augCanvas, parselect):
parselect
.
setCurrentIndex
(
index
)
def
tab_changed
(
fnc
,
index
):
settings
.
setValue
(
"reactivity/activetab"
,
index
)
fnc
()
def
pop_dial
(
augCanvas
,
drls
,
graph
,
labels
,
parselect
):
logger
.
debug
(
"populating reactivity dialog"
)
# Do not do anything when data set is not populated
...
...
@@ -119,7 +130,9 @@ def pop_dial(augCanvas, drls, graph, labels, parselect):
return
def
getconfval
(
name
,
type
,
parselect
=
parselect
):
par
=
"reactivity/{}_par{}"
.
format
(
name
,
parselect
.
currentIndex
())
parind
=
-
1
if
settings
.
value
(
"reactivity/activetab"
)
\
else
parselect
.
currentIndex
()
par
=
"reactivity/{}_par{}"
.
format
(
name
,
parind
)
logger
.
debug
(
"Getting "
+
par
)
return
settings
.
value
(
par
,
type
=
type
)
graph
.
clear
()
...
...
@@ -129,6 +142,7 @@ def pop_dial(augCanvas, drls, graph, labels, parselect):
colorargs
=
[
row
for
row
in
range
(
drls
[
'dt'
].
rowCount
())
if
drls
[
'dt'
].
cellWidget
(
row
,
0
).
checkState
()
==
2
]
params
=
augCanvas
.
ms
[
'params'
][
1
]
headers
=
np
.
concatenate
(
augCanvas
.
ms
[
'headers'
],
axis
=
0
)
parlen
=
len
(
params
)
if
len
(
names
)
<
2
:
return
...
...
@@ -145,40 +159,51 @@ def pop_dial(augCanvas, drls, graph, labels, parselect):
lastpos
=
0
coef1
=
getconfval
(
"coef_a"
,
float
)
coef2
=
getconfval
(
"coef_b"
,
float
)
for
time
in
times
:
toavg
=
[]
for
i
in
range
(
lastpos
,
parlen
):
if
float
(
params
[
i
][
0
])
==
time
:
toavg
.
append
((
float
(
params
[
i
][
parselect
.
currentIndex
()])
-
coef1
)
*
coef2
)
lastpos
=
i
elif
float
(
params
[
i
][
0
])
>
time
and
i
>
0
:
# i>0 condition to handle possibility of invalid first scan.
# (was observed in-wild on TSQ once)
break
if
len
(
toavg
)
!=
0
:
pressures
.
append
([
time
,
np
.
average
(
toavg
)])
if
len
(
pressures
)
==
0
:
QtWidgets
.
QMessageBox
.
critical
(
None
,
"No times loaded"
,
"Did not located any valid parameters.
\n
"
"It is either start of the acquisition,
\n
"
"or the timestamps has been corrupted."
)
return
nptpressures
=
np
.
asarray
(
pressures
).
T
[
0
]
goodtimes
=
np
.
where
([
t
in
nptpressures
for
t
in
times
])
alpha
=
getconfval
(
"transparency"
,
float
)
transcolors
=
[
np
.
append
(
i
,
alpha
)
for
i
in
gt
.
colors
]
if
not
settings
.
value
(
"reactivity/activetab"
):
for
time
in
times
:
toavg
=
[]
for
i
in
range
(
lastpos
,
parlen
):
if
float
(
params
[
i
][
0
])
==
time
:
toavg
.
append
((
float
(
params
[
i
][
parselect
.
currentIndex
()])
-
coef1
)
*
coef2
)
lastpos
=
i
elif
float
(
params
[
i
][
0
])
>
time
and
i
>
0
:
# i>0 condition to handle possibility of invalid first scan.
# (was observed in-wild on TSQ once)
break
if
len
(
toavg
)
!=
0
:
pressures
.
append
([
time
,
np
.
average
(
toavg
)])
if
len
(
pressures
)
==
0
:
QtWidgets
.
QMessageBox
.
critical
(
None
,
"No times loaded"
,
"Did not located any valid parameters.
\n
"
"It is either start of the acquisition,
\n
"
"or the timestamps has been corrupted."
)
return
nptpressures
=
np
.
asarray
(
pressures
).
T
[
0
]
goodtimes
=
np
.
where
([
t
in
nptpressures
for
t
in
times
])
for
i
in
range
(
1
,
len
(
intensities
)):
label
=
drls
[
'pt'
].
item
(
colorargs
[
i
],
0
).
text
()
relint
=
np
.
divide
(
intensities
[
i
],
np
.
clip
(
np
.
sum
(
intensities
,
0
),
np
.
finfo
(
np
.
float32
).
eps
,
None
),
dtype
=
np
.
float64
)
graph
.
plot
(
np
.
asarray
(
pressures
).
T
[
1
],
relint
[
goodtimes
],
label
=
label
,
color
=
(
transcolors
[
colorargs
[
i
]
%
len
(
transcolors
)]
/
255
),
marker
=
"."
,
markersize
=
getconfval
(
"markersize"
,
float
),
linestyle
=
"None"
)
if
not
settings
.
value
(
"reactivity/activetab"
):
graph
.
plot
(
np
.
asarray
(
pressures
).
T
[
1
],
relint
[
goodtimes
],
label
=
label
,
color
=
(
transcolors
[
colorargs
[
i
]
%
len
(
transcolors
)]
/
255
),
marker
=
"."
,
markersize
=
getconfval
(
"markersize"
,
float
),
linestyle
=
"None"
)
else
:
transheads
=
headers
.
T
hdrindex
=
min
(
getconfval
(
"headerindex"
,
int
),
len
(
headers
.
T
)
-
1
)
graph
.
plot
(
transheads
[
hdrindex
],
relint
,
label
=
label
,
color
=
(
transcolors
[
colorargs
[
i
]
%
len
(
transcolors
)]
/
255
),
marker
=
"."
,
markersize
=
getconfval
(
"markersize"
,
float
),
linestyle
=
"None"
)
if
getconfval
(
"showlabel"
,
int
):
legend
=
graph
.
legend
(
loc
=
getconfval
(
"labelloc"
,
int
))
[
lh
.
_legmarker
.
set_alpha
(
1
)
for
lh
in
legend
.
legendHandles
]
...
...
@@ -217,32 +242,49 @@ def main_window(parent, augCanvas, update_signal, drls):
gt
.
zoom_factory
(
dialspect
,
1.15
,
reactlabels
)
gt
.
pan_factory
(
dialspect
,
reactlabels
)
parlabel
=
QtWidgets
.
QLabel
(
"Parameter: "
)
tabberlabel
=
QtWidgets
.
QLabel
(
"Operate on:"
)
tabber
=
QtWidgets
.
QTabWidget
()
parselect_widget
=
QtWidgets
.
QWidget
()
parselect_layout
=
QtWidgets
.
QVBoxLayout
(
parselect_widget
)
parselect
=
QtWidgets
.
QComboBox
()
update_parselect
(
augCanvas
,
parselect
)
parselect
.
currentIndexChanged
.
connect
(
lambda
x
:
settings
.
setValue
(
"reactivity/index"
,
x
))
parselect_layout
.
addWidget
(
parselect
)
headerselect
=
QtWidgets
.
QWidget
()
hdrselect_layout
=
QtWidgets
.
QVBoxLayout
(
headerselect
)
hdrtext
=
QtWidgets
.
QLabel
(
"Please select the index of header variable you want to operate on. "
"If the index number will be higher than the highest active index, "
"last parameter will be used"
)
hdrtext
.
setWordWrap
(
True
)
hdrindex
=
reactivityParam
(
parselect
,
tabber
,
int
,
"headerindex"
,
"Index (0-n): "
,
0
)
hdrselect_layout
.
addWidget
(
hdrtext
)
hdrselect_layout
.
addLayout
(
hdrindex
)
formula
=
QtWidgets
.
QLabel
(
"Formula for the x-axis: (Parameter - a) * b"
)
xannlayout
=
reactivityParam
(
parselect
,
str
,
"xlabel"
,
"x axis label:"
)
xannlayout
=
reactivityParam
(
parselect
,
tabber
,
str
,
"xlabel"
,
"x axis label:"
)
xannlayout
.
addStretch
()
figann
=
reactivityParam
(
parselect
,
str
,
"figann"
,
"Figure annotation:"
)
figann
=
reactivityParam
(
parselect
,
tabber
,
str
,
"figann"
,
"Figure annotation:"
)
translayout
=
reactivityParam
(
parselect
,
int
,
"transparency"
,
"Transparency (0-255): "
,
0
,
255
)
parselect
,
tabber
,
int
,
"transparency"
,
"Transparency (0-255): "
,
0
,
255
)
translayout
.
addStretch
()
labelloclayout
=
reactivityParam
(
parselect
,
int
,
"labelloc"
,
"Label location (0-10): "
,
0
,
10
)
parselect
,
tabber
,
int
,
"labelloc"
,
"Label location (0-10): "
,
0
,
10
)
layouts
=
[
xannlayout
,
figann
,
translayout
,
labelloclayout
]
layouts
.
append
(
reactivityParam
(
parselect
,
int
,
"showlabel"
,
"Show Label? (0-1): "
,
0
,
1
))
parselect
,
tabber
,
int
,
"showlabel"
,
"Show Label? (0-1): "
,
0
,
1
))
layouts
.
append
(
reactivityParam
(
parselect
,
float
,
"markersize"
,
"dot size: "
,
0
))
layouts
.
append
(
reactivityParam
(
parselect
,
float
,
"coef_a"
,
"a: "
))
layouts
.
append
(
reactivityParam
(
parselect
,
float
,
"coef_b"
,
"b: "
))
parselect
,
tabber
,
float
,
"markersize"
,
"dot size: "
,
0
))
layouts
.
append
(
reactivityParam
(
parselect
,
tabber
,
float
,
"coef_a"
,
"a: "
))
layouts
.
append
(
reactivityParam
(
parselect
,
tabber
,
float
,
"coef_b"
,
"b: "
))
pushbtn
=
QtWidgets
.
QPushButton
(
"Update"
)
pushbtn
.
clicked
.
connect
(
lambda
:
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
))
pushbtn
.
clicked
.
connect
(
lambda
:
update_fnc
())
expbtn
=
QtWidgets
.
QPushButton
(
"Export"
)
expbtn
.
clicked
.
connect
(
lambda
:
export_dial
(
...
...
@@ -254,18 +296,20 @@ def main_window(parent, augCanvas, update_signal, drls):
buttlayout
.
addWidget
(
expbtn
)
layouts
.
append
(
buttlayout
)
param_layout
=
QtWidgets
.
QHBoxLayout
()
[
param_layout
.
addWidget
(
i
)
for
i
in
[
parlabel
,
parselect
]]
param_layout
.
addStretch
()
dial_widget
.
keyPressEvent
=
lambda
event
:
key_pressed
(
event
,
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
)
tabber
.
addTab
(
parselect_widget
,
"Parameter"
)
tabber
.
addTab
(
headerselect
,
"Header"
)
tabber
.
setCurrentIndex
(
settings
.
value
(
"reactivity/activetab"
,
type
=
int
))
tabber
.
currentChanged
.
connect
(
lambda
index
:
tab_changed
(
lambda
:
update_fnc
(),
index
))
dial_layout
=
QtWidgets
.
QVBoxLayout
(
dial_widget
)
dial_layout
.
addWidget
(
graph_canvas
,
stretch
=
1
)
dial_layout
.
addLayout
(
param_layout
)
dial_layout
.
addWidget
(
tabberlabel
)
dial_layout
.
addWidget
(
tabber
)
dial_layout
.
addWidget
(
formula
)
[
dial_layout
.
addLayout
(
i
)
for
i
in
layouts
]
dial_widget
.
setFocus
()
dial_widget
.
show
()
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
)
update_fnc
(
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment