Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waveform cleaner #973

Merged
merged 24 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f1b8096
New directory tree for the atmosphere calibration code
FrancaCassol Sep 28, 2017
66346d1
Fix doc error
FrancaCassol Oct 20, 2017
88ad9d3
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
Mar 5, 2018
cff4c0b
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
Mar 7, 2018
b126726
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
Mar 14, 2018
ee945fb
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Apr 17, 2018
8819d22
remove ctapipe/atmosphere and doc/atmosphere
FrancaCassol Jun 1, 2018
474bf53
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Jun 5, 2018
d74df8f
remove ctapipe/atmosphere and doc/atmosphere
FrancaCassol Jun 5, 2018
653d4c7
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Jul 20, 2018
9d129a0
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Dec 17, 2018
b41bfc0
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Feb 7, 2019
06764b4
Merge branch 'master' of https://github.com/cta-observatory/ctapipe
FrancaCassol Feb 19, 2019
69433e5
Added BaselineWaveformCleaner which returns the waveform baseline sub…
FrancaCassol Feb 20, 2019
7fe79bd
Improved code comments
FrancaCassol Feb 20, 2019
7bbafb2
Corrected bug and added test of baseline_cleaner
FrancaCassol Feb 20, 2019
78e8b7d
Change of the BaselineWaveformCleaner argument names
FrancaCassol Feb 20, 2019
326c2cf
Minor changes for Travis
FrancaCassol Feb 20, 2019
a010a59
Style changes
FrancaCassol Feb 20, 2019
0dfaa12
Style change
FrancaCassol Feb 20, 2019
76b0105
Changed argument name in a more meaniful one
FrancaCassol Feb 20, 2019
e2d9853
Changed name of variable with better choice
FrancaCassol Feb 21, 2019
ad0cead
Merge branch 'master' into waveform_cleaner
watsonjj Feb 27, 2019
d585206
Add missing comma
watsonjj Feb 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion ctapipe/image/tests/test_waveform_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from ctapipe.image.waveform_cleaning import (NullWaveformCleaner,
CHECMWaveformCleanerAverage,
CHECMWaveformCleanerLocal)
CHECMWaveformCleanerLocal,
BaselineWaveformCleaner)


def test_null_cleaner(example_event):
Expand Down Expand Up @@ -48,3 +49,24 @@ def test_checm_cleaner_local(example_event):

assert_almost_equal(data_ped[0, 0, 0], -2.8, 1)
assert_almost_equal(cleaned[0, 0, 0], -15.9, 1)


def test_baseline_cleaner():

# waveform : first 20 samples = 0, second 20 samples = 10
waveform = np.full((2, 1855, 40), 10)
waveform[:, :, 0:20] = 0

cleaner = BaselineWaveformCleaner()

cleaner.baseline_start = 0
cleaner.baseline_end = 20
cleaned = cleaner.apply(waveform)
assert (cleaned.mean() == 5)

cleaner.baseline_start = 20
cleaner.baseline_end = 40
cleaned = cleaner.apply(waveform)
assert (cleaned.mean() == -5)


20 changes: 19 additions & 1 deletion ctapipe/image/waveform_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
LocalPeakIntegrator)

__all__ = ['WaveformCleanerFactory', 'CHECMWaveformCleanerAverage',
'CHECMWaveformCleanerLocal',
'CHECMWaveformCleanerLocal', 'BaselineWaveformCleaner',
'NullWaveformCleaner']


Expand Down Expand Up @@ -67,6 +67,24 @@ def apply(self, waveforms):
return waveforms


class BaselineWaveformCleaner(WaveformCleaner):
"""
Basic waveform cleaner that subtracts the waveform baseline
estimated as the mean waveform value in the interval [baseline_start,baseline_end]
"""
baseline_start = Int(0, help='Start sample for baseline estimation').tag(config=True)

baseline_end = Int(10, help='End sample for baseline estimation').tag(config=True)

def apply(self, waveforms):
# Subtract baseline
baseline_corrected = waveforms - np.mean(
waveforms[:, :, self.baseline_start:self.baseline_end], axis=2
)[:, :, None]

return baseline_corrected


class CHECMWaveformCleaner(WaveformCleaner):
"""
Waveform cleaner used by CHEC-M.
Expand Down