Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
5569cf74
Commit
5569cf74
authored
Jul 26, 2019
by
Tobias WEBER
Browse files
event filtering in cov tool
parent
a5fafd58
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/tascalc/cov.py
View file @
5569cf74
...
...
@@ -42,6 +42,28 @@ k2_to_E = 1./E_to_k2 # k^2 -> E
#
# normalises events and filters out too low probabilities
#
def
filter_events
(
Q
,
E
,
w
):
# normalise intensity/probability
w
/=
np
.
max
(
w
)
# filter out too low probabilities
eps
=
1e-4
beloweps
=
lambda
d
:
np
.
abs
(
d
)
<=
eps
nonzero_idx
=
[
i
for
i
in
range
(
len
(
w
))
if
not
beloweps
(
w
[
i
])]
Q
=
Q
[
nonzero_idx
]
E
=
E
[
nonzero_idx
]
w
=
w
[
nonzero_idx
]
return
[
Q
,
E
,
w
]
#
# loads a list of neutron events in the [ ki_vec, kf_vec, pos_vec, wi, wf ] format
#
...
...
@@ -56,7 +78,7 @@ def load_events_kikf(filename):
Q
=
ki
-
kf
E
=
k2_to_E
*
(
np
.
multiply
(
ki
,
ki
).
sum
(
1
)
-
np
.
multiply
(
kf
,
kf
).
sum
(
1
))
return
[
Q
,
E
,
w
]
return
filter_events
(
Q
,
E
,
w
)
...
...
@@ -65,11 +87,12 @@ def load_events_kikf(filename):
#
def
load_events_QE
(
filename
):
dat
=
np
.
loadtxt
(
filename
)
Q
=
dat
[:,
Q_start_idx
:
Q_start_idx
+
3
]
E
=
dat
[:,
E_idx
]
w
=
dat
[:,
w_idx
]
return
[
Q
,
E
,
w
]
return
filter_events
(
Q
,
E
,
w
)
...
...
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