Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BEA data analysis utils
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philipp Niedermayer
BEA data analysis utils
Commits
2f5994bd
Commit
2f5994bd
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Background subtraction for IPM data
parent
b004b936
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data.py
+17
-5
17 additions, 5 deletions
data.py
with
17 additions
and
5 deletions
data.py
+
17
−
5
View file @
2f5994bd
...
@@ -150,8 +150,8 @@ class IPMData(Trace):
...
@@ -150,8 +150,8 @@ class IPMData(Trace):
hf
:
np
.
ndarray
=
None
hf
:
np
.
ndarray
=
None
def
apply_calibration
(
self
,
time_range
):
def
subtract_background
(
self
,
time_range
):
"""
Calibrates the profile data by s
ubtract
ing
the average profile measured in the given timespan
"""
S
ubtract the average profile measured in the given timespan
Note that this does not affect rms beam sizes
Note that this does not affect rms beam sizes
...
@@ -162,13 +162,16 @@ class IPMData(Trace):
...
@@ -162,13 +162,16 @@ class IPMData(Trace):
self
.
y
-=
np
.
mean
(
self
.
y
[
window
],
axis
=
0
)
self
.
y
-=
np
.
mean
(
self
.
y
[
window
],
axis
=
0
)
@classmethod
@classmethod
def
from_file
(
cls
,
fname
,
clean
=
False
,
from_event
=
None
,
time_offset
=
0
,
verbose
=
0
):
def
from_file
(
cls
,
fname
,
*
,
clean
=
False
,
subtract_background
=
True
,
from_event
=
None
,
time_offset
=
0
,
verbose
=
0
):
"""
Read in profile data from a *.tgz file saved with IPM application
"""
Read in profile data from a *.tgz file saved with IPM application
:param fname: path to filename
:param fname: path to filename
:param clean: use adc_clean.dat instead of adc.dat
:param clean: if True, use calibrated data from adc_clean.dat instead of raw data from adc.dat
:param from_event: return data from this event, time will also be relative to this event
:param from_event: return data from this event on, time will also be relative to this event
:param subtract_background: if True, subtract background level prior to injection
References:
References:
Giacomini, Tino <T.Giacomini@gsi.de>
Giacomini, Tino <T.Giacomini@gsi.de>
...
@@ -209,6 +212,15 @@ class IPMData(Trace):
...
@@ -209,6 +212,15 @@ class IPMData(Trace):
scl
=
np
.
loadtxt
(
tar
.
extractfile
(
'
scl.dat
'
),
skiprows
=
1
)
scl
=
np
.
loadtxt
(
tar
.
extractfile
(
'
scl.dat
'
),
skiprows
=
1
)
index
,
beam_current
,
dipole
,
hf
,
event_40
,
event_45
,
event_51
,
event_user
=
scl
.
T
index
,
beam_current
,
dipole
,
hf
,
event_40
,
event_45
,
event_51
,
event_user
=
scl
.
T
# background subtraction
if
subtract_background
:
assert
np
.
max
(
event_40
)
==
1
,
f
'
Requested background subtraction prior to injection (event 40), but event 40 not found in data
'
nbg
=
np
.
argmax
(
event_40
)
-
3
# before injection
x
-=
np
.
mean
(
x
[:
nbg
,
:],
axis
=
0
)
y
-=
np
.
mean
(
y
[:
nbg
,
:],
axis
=
0
)
if
verbose
:
print
(
f
'
Background subtracted (first
{
nbg
}
profiles or
{
t
[
nbg
]
}
s)
'
)
# offset relative to from_event
offset
=
0
offset
=
0
if
from_event
is
None
:
if
from_event
is
None
:
offset
=
0
offset
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment