-
Notifications
You must be signed in to change notification settings - Fork 270
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
signal extractor SlidingWindowMaxSum #1568
Merged
kosack
merged 15 commits into
cta-observatory:master
from
jsitarek:implement_SlidingWindowMaxSum
Feb 11, 2021
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
beab6d5
a new signal extractor, slightly slower, but with better accuracy (in…
jsitarek 4adb6ae
added missing apply_integration_correction variable to SlidingWindowM…
jsitarek 3cc405f
adding a standard test of the newly added single extractor SlidingWin…
jsitarek 1849d7d
added the test for the extract_sliding_window function that is used b…
jsitarek 7e2844a
fixing a few small issues from codacy scan
jsitarek c9c327e
fixing two trailing whitespaces
jsitarek 439c203
follow up commit on PR #1568
jsitarek 093dca3
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
jsitarek d3528e6
moved the dirty fix of the LST pulse shape to monkeypatch
jsitarek 8a2bce9
solving codacy warnings in PR 1588
jsitarek 84effe4
resolving codacy issues
jsitarek 69749bf
Merge remote-tracking branch 'upstream/master' into implement_Sliding…
jsitarek bf2d2e4
follow up of PR 1568
jsitarek ae70502
fixed an error left in the previous commit that would fail the test
jsitarek 7798779
corrected indentation
jsitarek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Test of sliding window extractor for LST camera pulse shape with | ||
the correction for the integration window completeness | ||
""" | ||
|
||
import numpy as np | ||
import astropy.units as u | ||
from numpy.testing import assert_allclose | ||
from traitlets.config.loader import Config | ||
|
||
from ctapipe.image.extractor import SlidingWindowMaxSum, ImageExtractor | ||
from ctapipe.image.toymodel import WaveformModel | ||
from ctapipe.instrument import SubarrayDescription, TelescopeDescription | ||
|
||
|
||
def test_sw_pulse_lst(): | ||
""" | ||
Test function of sliding window extractor for LST camera pulse shape with | ||
the correction for the integration window completeness | ||
""" | ||
|
||
# prepare array with 1 LST | ||
subarray = SubarrayDescription( | ||
"LST1", | ||
tel_positions={1: np.zeros(3) * u.m}, | ||
tel_descriptions={ | ||
1: TelescopeDescription.from_name(optics_name="LST", camera_name="LSTCam") | ||
}, | ||
) | ||
|
||
telid = list(subarray.tel.keys())[0] | ||
|
||
n_pixels = subarray.tel[telid].camera.geometry.n_pixels | ||
n_samples = 40 | ||
readout = subarray.tel[telid].camera.readout | ||
|
||
random = np.random.RandomState(1) | ||
min_charge = 100 | ||
max_charge = 1000 | ||
charge_true = random.uniform(min_charge, max_charge, n_pixels) | ||
time_true = random.uniform( | ||
n_samples // 2 - 1, n_samples // 2 + 1, n_pixels | ||
) / readout.sampling_rate.to_value(u.GHz) | ||
|
||
waveform_model = WaveformModel.from_camera_readout(readout) | ||
waveform = waveform_model.get_waveform(charge_true, time_true, n_samples) | ||
selected_gain_channel = np.zeros(charge_true.size, dtype=np.int) | ||
|
||
# define extractor | ||
config = Config({"SlidingWindowMaxSum": {"window_width": 8}}) | ||
extractor = SlidingWindowMaxSum(subarray=subarray) | ||
extractor = ImageExtractor.from_name( | ||
"SlidingWindowMaxSum", subarray=subarray, config=config | ||
) | ||
|
||
charge, _ = extractor(waveform, telid, selected_gain_channel) | ||
print(charge / charge_true) | ||
assert_allclose(charge, charge_true, rtol=0.02) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected, I'm not sure why precommit and flake8 did not catch this.
thx @maxnoe for reapproval
@kosack I also need it from you
and then can one of you merge the PR? I do not have permissions for doing it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will merge as soon as both approvals are there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is valid code and since it's a test it is probably also not checked by the documentation build