-
Notifications
You must be signed in to change notification settings - Fork 10
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
Initial QOIs #61
base: master
Are you sure you want to change the base?
Initial QOIs #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
import numpy as np | ||
from scipy.integrate import simps | ||
import scipy.stats as stats | ||
import scipy.signal as sig | ||
from skbeam.core.accumulators.binned_statistic import BinnedStatistic1D | ||
from skbeam.core.mask import margin | ||
from xpdtools.jit_tools import mask_ring_median, mask_ring_mean, ring_zscore | ||
|
@@ -581,3 +583,90 @@ def inner(x, *args, **kwargs): | |
return func(*args, **kwargs) | ||
|
||
return inner | ||
|
||
|
||
def max_value(g): | ||
"""Returns largest value | ||
|
||
Parameters | ||
---------- | ||
g : ndarray | ||
g(r) of the pdf | ||
|
||
Returns | ||
------- | ||
float : | ||
Maximum g value | ||
|
||
""" | ||
return np.amax(g) | ||
|
||
|
||
def tallest_peak(g, r): | ||
"""Returns r,g(r) of the tallest peak | ||
|
||
Parameters | ||
---------- | ||
g : ndarray | ||
g(r) of the pdf | ||
|
||
r : ndarray | ||
corresponding r values | ||
|
||
Returns | ||
------- | ||
float : | ||
r value of the tallest peak | ||
float : | ||
g(r) value of the tallest peak | ||
|
||
""" | ||
peaks = sig.find_peaks(g) | ||
height = [] | ||
r_val = [] | ||
for i in peaks[0]: | ||
height.append(g[i]) | ||
r_val.append(r[i]) | ||
return r_val[np.argmax(height)], np.amax(height) | ||
|
||
|
||
def total_counts(g): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not certain we need this function if it is only calling |
||
"""Returns total number of data points in graph | ||
|
||
Parameters | ||
---------- | ||
g : ndarray | ||
g(r) of the pdf | ||
|
||
Returns | ||
------- | ||
int : | ||
total number of data points | ||
|
||
""" | ||
return len(g) | ||
|
||
|
||
def average_pearson(group, g, r): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also compute the complete pearson correction? (Maybe as a separate function?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I may be confused on the stats here, to my knowledge the pearson's coefficients can be used on two different datasets. Is there a separate coefficient to compare a dataset to an entire group of datasets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could return the list of pearson's coefficents for the new pdf and all the prior pdfs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Sasaank poke There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pushed this into the other pr There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok |
||
"""Computes the average pearson of this PDF with the rest of the group | ||
|
||
Parameters | ||
---------- | ||
g : ndarray | ||
g(r) of the pdf | ||
|
||
r : ndarray | ||
corresponding r values | ||
group : ndarray | ||
Group of PDFs (PDFs as tuples (g,r)) | ||
Returns | ||
------- | ||
float : | ||
Average pearson's coefficient | ||
|
||
""" | ||
val = 0 | ||
for i in group: | ||
r, p = stats.pearsonr((g, r), i) | ||
val = val + r | ||
return val/len(group) |
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.
This is not so helpful. Bear in mind what the docstring is for. It is for a user to understand what this function is for and how it should be used. Also, the docstring shouldn't include the function name, which is effectively what your's does.
In other words, why do we (or rather a user) need this function (rather than just typing np.amax())?