-
Notifications
You must be signed in to change notification settings - Fork 5
Sensor response low photoelectron signal function #6
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
Open
bpalmeiro
wants to merge
8
commits into
nu-ZOO:main
Choose a base branch
from
bpalmeiro:fingersignalfunction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
020976a
Cosmetics on the github actions
bpalmeiro ffcce96
Add a temporal test for allow merging
bpalmeiro 7f9ad7b
Add __init__.py in tools
bpalmeiro 24634b0
Add function
bpalmeiro 73a2279
Add test
bpalmeiro 9e48cd2
add documentation & improve logic
jwaiton 5a1e2dc
Alter ppf function to reflect inputted poisson mu
jwaiton 255261c
add case protection for when poismu is determined to be zero
jwaiton 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 hidden or 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 hidden or 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,2 @@ | ||
| def test_dummy(): | ||
| pass |
Empty file.
This file contains hidden or 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,59 @@ | ||
| import numpy as np | ||
| import scipy.stats as scs | ||
|
|
||
|
|
||
| def finger_signal(xs : np.array, | ||
| bl : float , | ||
| amp : float , | ||
| gain : float , | ||
| sigmabl : float , | ||
| sigmaq : float , | ||
| poismu : float , | ||
| maxpercent : float = 0.999 | ||
| ) -> np.array: | ||
| ''' | ||
| A function that returns a `finger plot' distribution; a | ||
| poissonian distribution convoluted with gaussians. This distribution | ||
| characterises the output expected from a PMT/SiPM charge histogram | ||
| where x is the charge or PEs and y is the number of counts. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| xs : An array of 'x' values, typically PEs or ADCs | ||
| bl : The value beyond zero at which the poisson peaks occur [1] | ||
| amp : The amplitude applied to the poissonian peaks | ||
| gain : The gain (shift in x) applied to the poissonian peaks | ||
| sigmabl : The inherent sigma of each gaussian. | ||
| sigmaq : The sigma of each gaussian related to which poisson peak | ||
| it's related to. | ||
| maxpercent : The percentage of the poissonian distribution that is | ||
|
|
||
| Returns | ||
| ------- | ||
| result : The expected y values that given (x,y) describe the | ||
| finger plot distribution. | ||
|
|
||
| Footnotes | ||
| --------- | ||
| [1] Generally these peaks would initialise at begin at x = 0 but in | ||
| practice this isn't always the case | ||
| ''' | ||
|
|
||
| # Collect the position and amplitudes of the finger plot peaks | ||
| if poismu != 0: | ||
| poispeaks_pos = np.arange(0, scs.poisson.ppf(maxpercent, poismu)) | ||
| else: | ||
| poispeaks_pos = np.array([0]) | ||
| realpeaks_pos = gain * poispeaks_pos + bl | ||
| realpeaks_amp = amp * scs.poisson.pmf(poispeaks_pos, poismu) | ||
|
|
||
| # start y values collection | ||
| result = np.zeros_like(xs) | ||
|
|
||
| # generate y values (results) that describe the poissonian distribution with | ||
| # gaussian convolution across each peak | ||
| for i in range(0, len(poispeaks_pos)): | ||
| result += realpeaks_amp[i] * scs.norm.pdf(xs, loc=realpeaks_pos[i], | ||
| scale=np.sqrt(sigmabl**2 + sigmaq**2 * i)) | ||
|
|
||
| return result | ||
This file contains hidden or 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,19 @@ | ||
| import numpy as np | ||
| import scipy.stats as scs | ||
|
|
||
| from . fit_functions import finger_signal | ||
|
|
||
| from hypothesis import given | ||
| from hypothesis.strategies import floats | ||
|
|
||
| @given(floats(min_value = -10, max_value = 10), | ||
| floats(min_value = -500, max_value = 500), | ||
| floats(min_value = 1, max_value = 2), | ||
| floats(min_value = 0, max_value = 200)) | ||
| def test_finger_signal_gaus_when_poisson_zero(bl, gain, sbl, sq): | ||
jwaiton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| xaux = np.linspace(-10, 10, 1000) | ||
| yres = finger_signal(xaux, bl, 1, gain, sbl, sq, 0) | ||
| ygau = scs.norm.pdf(xaux, loc=bl, scale=sbl) | ||
|
|
||
| assert np.array_equal(yres, ygau) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.