Skip to content
GitLab
Menu
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
c6b3697a
Commit
c6b3697a
authored
Jul 30, 2019
by
3Yan
Committed by
Yan
Aug 10, 2019
Browse files
Parameters change support - pt4
* zce fixed * reformulated time subselection routine - improved readability
parent
f937738c
Changes
2
Hide whitespace changes
Inline
Side-by-side
prasopes/graphtools.py
View file @
c6b3697a
...
...
@@ -108,39 +108,33 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
mpl_chromatogram
.
clear
()
for
i
,
subset
in
enumerate
(
ds
):
selection
=
chrom_data
[
'timesarg'
][
i
]
if
cf
.
settings
().
value
(
"view/oddeven"
,
type
=
bool
):
for
j
in
range
(
2
):
chromx
=
subset
[
'chrom_dat'
][
0
,
:][
j
::
2
]
chromy
=
subset
[
'chrom_dat'
][
1
,
:][
j
::
2
]
pop_plot
(
chromx
,
chromy
,
mpl_chromatogram
,
chrom_data
,
colornum
=
i
*
2
+
j
)
if
not
np
.
array_equal
(
chrom_data
[
'timesarg'
][
i
][
j
::
2
],
[]):
if
not
chrom_data
[
'timesarg'
][
i
][
0
]
%
2
==
0
:
k
=
1
-
j
else
:
k
=
j
if
not
np
.
array_equal
(
selection
[
j
::
2
],
[]):
clr
=
i
*
2
+
j
if
selection
[
0
]
%
2
==
0
\
else
i
*
2
+
(
1
-
j
)
ms_x
=
subset
[
'masses'
]
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
chrom_data
[
'timesarg'
][
i
][
j
::
2
]],
axis
=
0
)
pop_plot
(
ms_x
,
ms_y
,
mpl_spectrum
,
ms_data
,
colornum
=
i
*
2
+
k
)
dots_x
=
subset
[
'chrom_dat'
][
0
,
chrom_data
[
'timesarg'
][
i
][
j
::
2
]]
dots_y
=
subset
[
'chrom_dat'
][
1
,
chrom_data
[
'timesarg'
][
i
][
j
::
2
]]
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
selection
[
j
::
2
]],
axis
=
0
)
pop_plot
(
ms_x
,
ms_y
,
mpl_spectrum
,
ms_data
,
colornum
=
clr
)
dots_x
=
subset
[
'chrom_dat'
][
0
,
selection
[
j
::
2
]]
dots_y
=
subset
[
'chrom_dat'
][
1
,
selection
[
j
::
2
]]
mpl_chromatogram
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
colors
[(
i
*
2
+
k
)
%
len
(
colors
)]
/
255
))
colors
[(
clr
)
%
len
(
colors
)]
/
255
))
else
:
chromx
=
subset
[
'chrom_dat'
][
0
,
:]
chromy
=
subset
[
'chrom_dat'
][
1
,
:]
pop_plot
(
chromx
,
chromy
,
mpl_chromatogram
,
chrom_data
,
colornum
=
i
)
if
not
np
.
array_equal
(
chrom_data
[
'timesarg'
][
i
]
,
[]):
if
not
np
.
array_equal
(
selection
,
[]):
ms_x
=
subset
[
'masses'
]
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
chrom_data
[
'timesarg'
][
i
]],
axis
=
0
)
ms_y
=
np
.
mean
(
subset
[
'matrix'
][
selection
],
axis
=
0
)
pop_plot
(
ms_x
,
ms_y
,
mpl_spectrum
,
ms_data
,
colornum
=
i
)
dots_x
=
subset
[
'chrom_dat'
][
0
,
chrom_data
[
'timesarg'
][
i
]
]
dots_y
=
subset
[
'chrom_dat'
][
1
,
chrom_data
[
'timesarg'
][
i
]
]
dots_x
=
subset
[
'chrom_dat'
][
0
,
selection
]
dots_y
=
subset
[
'chrom_dat'
][
1
,
selection
]
mpl_chromatogram
.
plot
(
dots_x
,
dots_y
,
'.'
,
color
=
(
colors
[
i
%
len
(
colors
)]
/
255
))
...
...
prasopes/zcetools.py
View file @
c6b3697a
...
...
@@ -25,31 +25,31 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
zcespec
.
clear
()
gradspect
.
clear
()
coff_
d
[
'x'
]
=
data_set
[
'masses'
]
-
196
coff_
d
[
'y'
]
=
np
.
mean
(
data_set
[
'matrix'
],
axis
=
0
)
grad_
d
[
'x'
]
=
coff_
d
[
'x'
]
halfl
=
int
(
len
(
grad_
d
[
'x'
]
)
/
2
)
grad_
d
[
'y'
]
=
-
np
.
gradient
(
coff_
d
[
'y'
]
)
\
if
np
.
sum
(
coff_
d
[
'y'
]
[:
halfl
])
>
np
.
sum
(
coff_
d
[
'y'
]
[
halfl
:])
\
else
np
.
gradient
(
coff_
d
[
'y'
]
)
coff_
x
=
data_set
[
0
][
'masses'
]
-
196
coff_
y
=
np
.
mean
(
data_set
[
0
][
'matrix'
],
axis
=
0
)
grad_
x
=
coff_
x
halfl
=
int
(
len
(
grad_
x
)
/
2
)
grad_
y
=
-
np
.
gradient
(
coff_
y
)
\
if
np
.
sum
(
coff_
y
[:
halfl
])
>
np
.
sum
(
coff_
y
[
halfl
:])
\
else
np
.
gradient
(
coff_
y
)
gradspect
.
axhline
(
0
,
color
=
"#FF000088"
,
linestyle
=
":"
)
zcespec
.
axhline
(
0
,
color
=
"#0000FF88"
,
linestyle
=
":"
)
gt
.
pop_plot
(
zcespec
,
coff_d
)
gt
.
pop_plot
(
gradspect
,
grad_d
)
gt
.
pop_plot
(
coff_x
,
coff_y
,
zcespec
,
coff_d
)
gt
.
pop_plot
(
grad_x
,
grad_y
,
gradspect
,
grad_d
)
gradspect
.
lines
[
-
1
].
set_color
(
"red"
)
gradspect
.
set_ylim
(
bottom
=
gradspect
.
get_ylim
()[
1
]
*
-
0.1
)
zcespec
.
set_title
(
"COFF"
,
loc
=
"center"
)
maxarg
=
np
.
argmax
(
grad_
d
[
'y'
]
)
grad_d
[
'gmax'
]
=
coff_
d
[
'x'
]
[
maxarg
]
halfmax
=
np
.
max
(
grad_
d
[
'y'
]
)
/
2
peakargs
=
np
.
where
(
grad_
d
[
'y'
]
>
halfmax
)[
0
]
maxarg
=
np
.
argmax
(
grad_
y
)
grad_d
[
'gmax'
]
=
coff_
x
[
maxarg
]
halfmax
=
np
.
max
(
grad_
y
)
/
2
peakargs
=
np
.
where
(
grad_
y
>
halfmax
)[
0
]
start
=
[
peakargs
[
0
]
-
1
,
peakargs
[
0
]]
end
=
[
peakargs
[
-
1
]
+
1
,
peakargs
[
-
1
]]
grad_d
[
'fwhm_y'
]
=
[
halfmax
,
halfmax
]
grad_d
[
'fwhm_x'
]
=
[
np
.
interp
(
halfmax
,
grad_
d
[
'y'
]
[
start
],
grad_
d
[
'x'
]
[
start
]),
np
.
interp
(
halfmax
,
grad_
d
[
'y'
]
[
end
],
grad_
d
[
'x'
]
[
end
])]
np
.
interp
(
halfmax
,
grad_
y
[
start
],
grad_
x
[
start
]),
np
.
interp
(
halfmax
,
grad_
y
[
end
],
grad_
x
[
end
])]
grad_d
[
'fwhm'
]
=
grad_d
[
'fwhm_x'
][
1
]
-
grad_d
[
'fwhm_x'
][
0
]
gradspect
.
plot
(
grad_d
[
'fwhm_x'
],
grad_d
[
'fwhm_y'
],
"#880088"
)
...
...
@@ -60,7 +60,7 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
gradspect
.
annotate
(
' FWHM = {:.2f}'
.
format
(
grad_d
[
'fwhm'
]),
xy
=
(
grad_d
[
'fwhm_x'
][
1
],
grad_d
[
'fwhm_y'
][
1
]))
gradspect
.
annotate
(
'{:.2f}'
.
format
(
grad_d
[
'gmax'
]),
xy
=
(
grad_
d
[
'x'
]
[
maxarg
],
grad_
d
[
'y'
]
[
maxarg
]))
xy
=
(
grad_
x
[
maxarg
],
grad_
y
[
maxarg
]))
zcespec
.
figure
.
canvas
.
draw
()
...
...
@@ -120,11 +120,10 @@ def print_graph(ds, coff, coffgrad, filename):
def
dialog
(
parent
,
ds
,
filename
,
update_signal
):
coff
=
dict
(
x
=
[
0
],
y
=
[
0
],
name
=
""
,
xlabel
=
"Voltage (V)"
,
ylabel
=
"ion count"
)
coffgrad
=
dict
(
x
=
[
0
],
y
=
[
0
],
c_ymin
=-
0.1
,
name
=
""
,
xlabel
=
""
,
ylabel
=
"ion count gradient"
,
gmax
=
None
,
fwhm_x
=
None
,
fwhm_y
=
None
,
fwhm
=
None
)
coff
=
dict
(
name
=
""
,
xlabel
=
"Voltage (V)"
,
ylabel
=
"ion count"
)
coffgrad
=
dict
(
c_ymin
=-
0.1
,
name
=
""
,
xlabel
=
""
,
ylabel
=
"ion count gradient"
,
gmax
=
None
,
fwhm_x
=
None
,
fwhm_y
=
None
,
fwhm
=
None
)
def
onclose
(
widget
,
event
,
update_fnc
):
logger
.
debug
(
"ZCE window custom close routine called"
)
...
...
Write
Preview
Supports
Markdown
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