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
f9362000
Commit
f9362000
authored
May 28, 2020
by
3Yan
Browse files
Reactivity tools rewrote and improved
* added flexibility in plotting * rewrote the code
parent
f58e84a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
prasopes/__init__.py
View file @
f9362000
...
...
@@ -13,7 +13,7 @@ from . import zcetools_help
from
.
import
reactivitytools
__version__
=
"0.0.2
3
"
__version__
=
"0.0.2
4
"
__all__
=
[
'config'
,
'datatools'
,
'docks'
,
'drltools'
,
'drltoos_gui'
,
'filetools'
,
...
...
prasopes/config.py
View file @
f9362000
...
...
@@ -24,6 +24,8 @@ def settings():
(
"reactivity/index"
,
0
),
(
"reactivity/coef1"
,
0
),
(
"reactivity/coef2"
,
0
),
(
"reactivity/transparency"
,
200
),
(
"reactivity/markersize"
,
10
),
(
"recents"
,
""
)}
[
settings
.
setValue
(
*
i
)
for
i
in
defvals
if
not
settings
.
contains
(
i
[
0
])]
...
...
prasopes/reactivitytools.py
View file @
f9362000
...
...
@@ -21,11 +21,10 @@ matplotlib.use("Qt5Agg")
logger
=
logging
.
getLogger
(
'reactivityLogger'
)
def
key_pressed
(
event
,
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
print
(
"trigged"
)
def
key_pressed
(
event
,
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
if
event
.
key
()
==
QtCore
.
Qt
.
Key_C
:
if
event
.
modifiers
().
__int__
()
==
QtCore
.
Qt
.
ControlModifier
:
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
)
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
)
def
update_parselect
(
augCanvas
,
parselect
):
...
...
@@ -40,11 +39,11 @@ def update_parselect(augCanvas, parselect):
parselect
.
setCurrentIndex
(
index
)
def
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
paintfig
=
Figure
(
figsize
=
(
3.5
,
2
),
dpi
=
300
,
constrained_layout
=
True
)
def
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
paintfig
=
Figure
(
figsize
=
(
3.5
,
3
),
dpi
=
300
,
constrained_layout
=
True
)
FigureCanvas
(
paintfig
)
printplot
=
paintfig
.
add_subplot
(
111
)
pop_dial
(
augCanvas
,
drls
,
printplot
,
labels
,
parselect
,
coef1
,
coef2
)
pop_dial
(
augCanvas
,
drls
,
printplot
,
labels
,
parselect
)
printplot
.
set_xlim
(
grph
.
get_xlim
())
printplot
.
set_ylim
(
grph
.
get_ylim
())
paintfig
.
canvas
.
draw
()
...
...
@@ -55,18 +54,21 @@ def paint_image(augCanvas, drls, grph, labels, parselect, coef1, coef2):
return
image
def
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
image
=
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
)
def
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
image
=
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
)
QtWidgets
.
QApplication
.
clipboard
().
clear
()
[
QtWidgets
.
QApplication
.
clipboard
().
setImage
(
image
,
i
)
for
i
in
range
(
2
)]
def
pop_dial
(
augCanvas
,
drls
,
graph
,
labels
,
parselect
,
coef1
,
coef2
):
def
pop_dial
(
augCanvas
,
drls
,
graph
,
labels
,
parselect
):
logger
.
debug
(
"populating reactivity dialog"
)
# Do not do anything when data set is not populated
if
len
(
augCanvas
.
ds
)
==
0
:
return
coef1
=
cf
.
settings
().
value
(
"reactivity/coef1"
,
type
=
float
)
coef2
=
cf
.
settings
().
value
(
"reactivity/coef2"
,
type
=
float
)
markersize
=
cf
.
settings
().
value
(
"reactivity/markersize"
,
type
=
float
)
update_parselect
(
augCanvas
,
parselect
)
graph
.
clear
()
gt
.
pop_plot
([
0
],
[
0
],
graph
,
labels
)
...
...
@@ -83,8 +85,8 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
toavg
=
[]
for
i
in
range
(
lastpos
,
parlen
):
if
float
(
params
[
i
][
0
])
==
time
:
toavg
.
append
((
float
(
params
[
i
][
parselect
.
currentIndex
()])
-
coef1
.
value
())
*
coef2
.
value
()
)
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.
...
...
@@ -100,14 +102,18 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
return
nptpressures
=
np
.
asarray
(
pressures
).
T
[
0
]
goodtimes
=
np
.
where
([
t
in
nptpressures
for
t
in
times
])
alpha
=
cf
.
settings
().
value
(
"reactivity/transparency"
,
type
=
int
)
transcolors
=
[
np
.
append
(
i
,
alpha
)
for
i
in
gt
.
colors
]
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
=
names
[
i
],
color
=
(
gt
.
colors
[
colorargs
[
i
]
%
len
(
gt
.
colors
)]
/
255
),
marker
=
"."
,
markersize
=
1
,
linestyle
=
"None"
)
label
=
label
,
color
=
(
transcolors
[
colorargs
[
i
]
%
len
(
transcolors
)]
/
255
),
marker
=
"."
,
markersize
=
markersize
,
linestyle
=
"None"
)
graph
.
legend
(
loc
=
2
)
graph
.
autoscale
(
True
)
graph
.
figure
.
canvas
.
draw
()
...
...
@@ -155,41 +161,55 @@ def main_window(parent, augCanvas, update_signal, drls):
xannlayout
=
QtWidgets
.
QHBoxLayout
()
[
xannlayout
.
addWidget
(
i
)
for
i
in
[
xlabelabel
,
xlabeldial
]]
xannlayout
.
addStretch
()
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
))
translayout
=
QtWidgets
.
QHBoxLayout
()
translabel
=
QtWidgets
.
QLabel
(
"Transparency (0-255): "
)
transbox
=
QtWidgets
.
QSpinBox
(
minimum
=
0
,
maximum
=
255
)
transbox
.
setValue
(
cf
.
settings
().
value
(
"reactivity/transparency"
,
type
=
int
))
transbox
.
valueChanged
.
connect
(
lambda
x
:
cf
.
settings
().
setValue
(
"reactivity/transparency"
,
x
))
[
translayout
.
addWidget
(
i
)
for
i
in
[
translabel
,
transbox
]]
translayout
.
addStretch
()
layouts
=
[]
layouts
.
append
(
xannlayout
)
layouts
.
append
(
translayout
)
valnames
=
[
"markersize"
,
"coef1"
,
"coef2"
]
valtexts
=
[
"dot size: "
,
"a: "
,
"b: "
]
coefs
=
[]
for
i
in
range
(
len
(
valnames
)):
newlayout
=
QtWidgets
.
QHBoxLayout
()
label
=
QtWidgets
.
QLabel
(
valtexts
[
i
],
alignment
=
130
)
coef
=
QtWidgets
.
QDoubleSpinBox
(
decimals
=
4
,
minimum
=
float
(
"-inf"
),
maximum
=
float
(
"inf"
))
coef
.
setValue
(
cf
.
settings
().
value
(
"reactivity/{}"
.
format
(
valnames
[
i
]),
type
=
float
))
coefs
.
append
(
coef
)
newlayout
.
addWidget
(
label
)
newlayout
.
addWidget
(
coef
,
stretch
=
1
)
layouts
.
append
(
newlayout
)
list
(
map
(
lambda
i
:
coefs
[
i
].
valueChanged
.
connect
(
lambda
x
:
cf
.
settings
().
setValue
(
"reactivity/{}"
.
format
(
valnames
[
i
]),
x
)),
range
(
len
(
valnames
))))
pushbtn
=
QtWidgets
.
QPushButton
(
"Recalculate"
)
pushbtn
.
clicked
.
connect
(
lambda
:
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
,
coef1
,
coef2
))
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
))
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_widget
.
keyPressEvent
=
lambda
event
:
key_pressed
(
event
,
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
,
coef1
,
coef2
)
event
,
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
)
dial_layout
=
QtWidgets
.
QVBoxLayout
(
dial_widget
)
dial_layout
.
addWidget
(
graph_canvas
,
stretch
=
1
)
dial_layout
.
addLayout
(
xannlayout
)
dial_layout
.
addLayout
(
param_layout
)
dial_layout
.
addWidget
(
formula
)
dial_layout
.
addLayout
(
coef_
layout
)
[
dial_layout
.
addLayout
(
i
)
for
i
in
layout
s
]
dial_layout
.
addWidget
(
pushbtn
)
dial_widget
.
setFocus
()
dial_widget
.
show
()
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
,
coef1
,
coef2
)
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
)
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