Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
prasopes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Zelenka
prasopes
Commits
f9362000
Commit
f9362000
authored
May 28, 2020
by
3Yan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reactivity tools rewrote and improved
* added flexibility in plotting * rewrote the code
parent
f58e84a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
37 deletions
+59
-37
prasopes/__init__.py
prasopes/__init__.py
+1
-1
prasopes/config.py
prasopes/config.py
+2
-0
prasopes/reactivitytools.py
prasopes/reactivitytools.py
+56
-36
No files found.
prasopes/__init__.py
View file @
f9362000
...
@@ -13,7 +13,7 @@ from . import zcetools_help
...
@@ -13,7 +13,7 @@ from . import zcetools_help
from
.
import
reactivitytools
from
.
import
reactivitytools
__version__
=
"0.0.2
3
"
__version__
=
"0.0.2
4
"
__all__
=
[
'config'
,
'datatools'
,
'docks'
,
'drltools'
,
'drltoos_gui'
,
'filetools'
,
__all__
=
[
'config'
,
'datatools'
,
'docks'
,
'drltools'
,
'drltoos_gui'
,
'filetools'
,
...
...
prasopes/config.py
View file @
f9362000
...
@@ -24,6 +24,8 @@ def settings():
...
@@ -24,6 +24,8 @@ def settings():
(
"reactivity/index"
,
0
),
(
"reactivity/index"
,
0
),
(
"reactivity/coef1"
,
0
),
(
"reactivity/coef1"
,
0
),
(
"reactivity/coef2"
,
0
),
(
"reactivity/coef2"
,
0
),
(
"reactivity/transparency"
,
200
),
(
"reactivity/markersize"
,
10
),
(
"recents"
,
""
)}
(
"recents"
,
""
)}
[
settings
.
setValue
(
*
i
)
[
settings
.
setValue
(
*
i
)
for
i
in
defvals
if
not
settings
.
contains
(
i
[
0
])]
for
i
in
defvals
if
not
settings
.
contains
(
i
[
0
])]
...
...
prasopes/reactivitytools.py
View file @
f9362000
...
@@ -21,11 +21,10 @@ matplotlib.use("Qt5Agg")
...
@@ -21,11 +21,10 @@ matplotlib.use("Qt5Agg")
logger
=
logging
.
getLogger
(
'reactivityLogger'
)
logger
=
logging
.
getLogger
(
'reactivityLogger'
)
def
key_pressed
(
event
,
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
def
key_pressed
(
event
,
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
print
(
"trigged"
)
if
event
.
key
()
==
QtCore
.
Qt
.
Key_C
:
if
event
.
key
()
==
QtCore
.
Qt
.
Key_C
:
if
event
.
modifiers
().
__int__
()
==
QtCore
.
Qt
.
ControlModifier
:
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
):
def
update_parselect
(
augCanvas
,
parselect
):
...
@@ -40,11 +39,11 @@ def update_parselect(augCanvas, parselect):
...
@@ -40,11 +39,11 @@ def update_parselect(augCanvas, parselect):
parselect
.
setCurrentIndex
(
index
)
parselect
.
setCurrentIndex
(
index
)
def
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
def
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
paintfig
=
Figure
(
figsize
=
(
3.5
,
2
),
dpi
=
300
,
constrained_layout
=
True
)
paintfig
=
Figure
(
figsize
=
(
3.5
,
3
),
dpi
=
300
,
constrained_layout
=
True
)
FigureCanvas
(
paintfig
)
FigureCanvas
(
paintfig
)
printplot
=
paintfig
.
add_subplot
(
111
)
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_xlim
(
grph
.
get_xlim
())
printplot
.
set_ylim
(
grph
.
get_ylim
())
printplot
.
set_ylim
(
grph
.
get_ylim
())
paintfig
.
canvas
.
draw
()
paintfig
.
canvas
.
draw
()
...
@@ -55,18 +54,21 @@ def paint_image(augCanvas, drls, grph, labels, parselect, coef1, coef2):
...
@@ -55,18 +54,21 @@ def paint_image(augCanvas, drls, grph, labels, parselect, coef1, coef2):
return
image
return
image
def
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
):
def
clip_spect_img
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
):
image
=
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
,
coef1
,
coef2
)
image
=
paint_image
(
augCanvas
,
drls
,
grph
,
labels
,
parselect
)
QtWidgets
.
QApplication
.
clipboard
().
clear
()
QtWidgets
.
QApplication
.
clipboard
().
clear
()
[
QtWidgets
.
QApplication
.
clipboard
().
setImage
(
image
,
i
)
for
i
in
range
(
2
)]
[
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"
)
logger
.
debug
(
"populating reactivity dialog"
)
# Do not do anything when data set is not populated
# Do not do anything when data set is not populated
if
len
(
augCanvas
.
ds
)
==
0
:
if
len
(
augCanvas
.
ds
)
==
0
:
return
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
)
update_parselect
(
augCanvas
,
parselect
)
graph
.
clear
()
graph
.
clear
()
gt
.
pop_plot
([
0
],
[
0
],
graph
,
labels
)
gt
.
pop_plot
([
0
],
[
0
],
graph
,
labels
)
...
@@ -83,8 +85,8 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
...
@@ -83,8 +85,8 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
toavg
=
[]
toavg
=
[]
for
i
in
range
(
lastpos
,
parlen
):
for
i
in
range
(
lastpos
,
parlen
):
if
float
(
params
[
i
][
0
])
==
time
:
if
float
(
params
[
i
][
0
])
==
time
:
toavg
.
append
((
float
(
params
[
i
][
parselect
.
currentIndex
()])
toavg
.
append
((
float
(
-
coef1
.
value
())
*
coef2
.
value
()
)
params
[
i
][
parselect
.
currentIndex
()])
-
coef1
)
*
coef2
)
lastpos
=
i
lastpos
=
i
elif
float
(
params
[
i
][
0
])
>
time
and
i
>
0
:
elif
float
(
params
[
i
][
0
])
>
time
and
i
>
0
:
# i>0 condition to handle possibility of invalid first scan.
# i>0 condition to handle possibility of invalid first scan.
...
@@ -100,14 +102,18 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
...
@@ -100,14 +102,18 @@ def pop_dial(augCanvas, drls, graph, labels, parselect, coef1, coef2):
return
return
nptpressures
=
np
.
asarray
(
pressures
).
T
[
0
]
nptpressures
=
np
.
asarray
(
pressures
).
T
[
0
]
goodtimes
=
np
.
where
([
t
in
nptpressures
for
t
in
times
])
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
)):
for
i
in
range
(
1
,
len
(
intensities
)):
label
=
drls
[
'pt'
].
item
(
colorargs
[
i
],
0
).
text
()
relint
=
np
.
divide
(
intensities
[
i
],
np
.
clip
(
np
.
sum
(
relint
=
np
.
divide
(
intensities
[
i
],
np
.
clip
(
np
.
sum
(
intensities
,
0
),
np
.
finfo
(
np
.
float32
).
eps
,
None
),
intensities
,
0
),
np
.
finfo
(
np
.
float32
).
eps
,
None
),
dtype
=
np
.
float64
)
dtype
=
np
.
float64
)
graph
.
plot
(
np
.
asarray
(
pressures
).
T
[
1
],
relint
[
goodtimes
],
graph
.
plot
(
np
.
asarray
(
pressures
).
T
[
1
],
relint
[
goodtimes
],
label
=
names
[
i
],
color
=
(
gt
.
colors
[
label
=
label
,
color
=
(
transcolors
[
colorargs
[
i
]
%
len
(
gt
.
colors
)]
/
255
),
marker
=
"."
,
colorargs
[
i
]
%
len
(
transcolors
)]
/
255
),
marker
=
"."
,
markersize
=
1
,
linestyle
=
"None"
)
markersize
=
markersize
,
linestyle
=
"None"
)
graph
.
legend
(
loc
=
2
)
graph
.
autoscale
(
True
)
graph
.
autoscale
(
True
)
graph
.
figure
.
canvas
.
draw
()
graph
.
figure
.
canvas
.
draw
()
...
@@ -155,41 +161,55 @@ def main_window(parent, augCanvas, update_signal, drls):
...
@@ -155,41 +161,55 @@ def main_window(parent, augCanvas, update_signal, drls):
xannlayout
=
QtWidgets
.
QHBoxLayout
()
xannlayout
=
QtWidgets
.
QHBoxLayout
()
[
xannlayout
.
addWidget
(
i
)
for
i
in
[
xlabelabel
,
xlabeldial
]]
[
xannlayout
.
addWidget
(
i
)
for
i
in
[
xlabelabel
,
xlabeldial
]]
xannlayout
.
addStretch
()
xannlayout
.
addStretch
()
label1
=
QtWidgets
.
QLabel
(
"a: "
,
alignment
=
130
)
coef1
=
QtWidgets
.
QDoubleSpinBox
(
translayout
=
QtWidgets
.
QHBoxLayout
()
decimals
=
4
,
minimum
=
float
(
"-inf"
),
maximum
=
float
(
"inf"
))
translabel
=
QtWidgets
.
QLabel
(
"Transparency (0-255): "
)
coef1
.
setValue
(
cf
.
settings
().
value
(
"reactivity/coef1"
,
type
=
float
))
transbox
=
QtWidgets
.
QSpinBox
(
minimum
=
0
,
maximum
=
255
)
coef1
.
valueChanged
.
connect
(
lambda
x
:
transbox
.
setValue
(
cf
.
settings
().
value
(
cf
.
settings
().
setValue
(
"reactivity/coef1"
,
x
))
"reactivity/transparency"
,
type
=
int
))
label2
=
QtWidgets
.
QLabel
(
"b: "
,
alignment
=
130
)
transbox
.
valueChanged
.
connect
(
lambda
x
:
coef2
=
QtWidgets
.
QDoubleSpinBox
(
cf
.
settings
().
setValue
(
"reactivity/transparency"
,
x
))
decimals
=
4
,
minimum
=
float
(
"-inf"
),
maximum
=
float
(
"inf"
))
[
translayout
.
addWidget
(
i
)
for
i
in
[
translabel
,
transbox
]]
coef2
.
setValue
(
cf
.
settings
().
value
(
"reactivity/coef2"
,
type
=
float
))
translayout
.
addStretch
()
coef2
.
valueChanged
.
connect
(
lambda
x
:
cf
.
settings
().
setValue
(
"reactivity/coef2"
,
x
))
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
=
QtWidgets
.
QPushButton
(
"Recalculate"
)
pushbtn
.
clicked
.
connect
(
lambda
:
pop_dial
(
pushbtn
.
clicked
.
connect
(
lambda
:
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
,
coef1
,
coef2
))
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
))
param_layout
=
QtWidgets
.
QHBoxLayout
()
param_layout
=
QtWidgets
.
QHBoxLayout
()
[
param_layout
.
addWidget
(
i
)
for
i
in
[
parlabel
,
parselect
]]
[
param_layout
.
addWidget
(
i
)
for
i
in
[
parlabel
,
parselect
]]
param_layout
.
addStretch
()
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
(
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
=
QtWidgets
.
QVBoxLayout
(
dial_widget
)
dial_layout
.
addWidget
(
graph_canvas
,
stretch
=
1
)
dial_layout
.
addWidget
(
graph_canvas
,
stretch
=
1
)
dial_layout
.
addLayout
(
xannlayout
)
dial_layout
.
addLayout
(
param_layout
)
dial_layout
.
addLayout
(
param_layout
)
dial_layout
.
addWidget
(
formula
)
dial_layout
.
addWidget
(
formula
)
dial_layout
.
addLayout
(
coef_layout
)
[
dial_layout
.
addLayout
(
i
)
for
i
in
layouts
]
dial_layout
.
addWidget
(
pushbtn
)
dial_layout
.
addWidget
(
pushbtn
)
dial_widget
.
setFocus
()
dial_widget
.
setFocus
()
dial_widget
.
show
()
dial_widget
.
show
()
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
,
coef1
,
coef2
)
pop_dial
(
augCanvas
,
drls
,
dialspect
,
reactlabels
,
parselect
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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