-
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 1 commit
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import numpy as np | ||
import astropy.units as u | ||
from numpy.testing import assert_allclose | ||
|
||
from ctapipe.image.extractor import SlidingWindowMaxSum | ||
from ctapipe.image.toymodel import WaveformModel | ||
from ctapipe.instrument import SubarrayDescription, TelescopeDescription | ||
|
||
from ctapipe.utils import datasets | ||
|
||
datasets.DEFAULT_URL = "http://cccta-dataserver.in2p3.fr/data/ctapipe-extra/v0.3.2/" | ||
|
||
|
||
def test_sw_pulse_lst(): | ||
|
||
# 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) | ||
minCharge = 100 | ||
maxCharge = 1000 | ||
charge_true = random.uniform(minCharge, maxCharge, 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 | ||
extr_width = 8 | ||
extractor = SlidingWindowMaxSum(subarray=subarray) | ||
extractor.window_width = extr_width | ||
charge, peak_time = extractor(waveform, telid, selected_gain_channel) | ||
print(charge / charge_true) | ||
assert_allclose(charge, charge_true, rtol=0.02) | ||
|
||
|
||
test_sw_pulse_lst() |
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.
Shouldn't really set this globally, since it affects all other tests (and definitely should not be committed when we merge the PR). Perhaps for now, you might want to use the
monkeypatch
test fixture instead, something like:see https://docs.pytest.org/en/stable/monkeypatch.html
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.
hmm, I put this test explicitely into a separate file to avoid affecting other files with a global variable, because I thought that each file is run independently.
either way, now modified as suggested by you