-
Notifications
You must be signed in to change notification settings - Fork 11
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
Plotting func/peak finder #31
Conversation
…d wrote a very simple unit test for the function.
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 99.55% 98.68% -0.87%
==========================================
Files 5 6 +1
Lines 224 228 +4
==========================================
+ Hits 223 225 +2
- Misses 1 3 +2
|
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.
Great work, @gwenwhite! :)
Co-authored-by: Jenny <[email protected]>
array of numbers.
…ite/cmeutils into plotting-func/peak-finder
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.
Getting close :)
---------- | ||
data : numpy.ndarray, shape (N,1) | ||
Such as x, y, OR z. | ||
max_height : int, default None |
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.
I think the height can be a float
max_height : int, default None | |
height : float, default None |
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html
@@ -5,7 +5,7 @@ | |||
import numpy as np | |||
import freud | |||
|
|||
from cmeutils.tests.base_test import BaseTest |
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.
Were the tests not working for you without this change? It might be because cmeutils is not installed in your environment or not installed in an editable way? (i.e., pip install -e .
) Not sure.
@@ -0,0 +1,16 @@ | |||
import pytest | |||
|
|||
import scipy.signal as signal |
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.
import scipy.signal as signal |
Here we don't need to import this function because we want to use your find peaks function
def test_find_peaks(self, rdf_txt): | ||
line= np.genfromtxt(rdf_txt, names=True, delimiter=",") | ||
y= line["rdf"] | ||
peaks = signal.find_peaks(y) |
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.
peaks = signal.find_peaks(y) | |
peaks = find_peaks(y) |
y= line["rdf"] | ||
peaks = signal.find_peaks(y) | ||
assert isinstance(y, np.ndarray) | ||
assert isinstance(peaks, tuple) |
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.
Nice, now last step just check that a couple of peaks are in the right place. I do wonder if scipy.signal.find_peaks
is used with no arguments (the default of your function), if any peaks will be found... I would plot this to make sure it makes sense :)
I'm going to close this for now as its gone stale and is a bit outdated, we can make a new PR to add peak finding tools. |
Not sure if this is the type of peak finder we are looking for (mentioned in issue #27), but I gave it a try. The function calculates the average data values given, and any value greater than the average is recognized as a "peak". Thus far I have only tested it on PE and RDF data/plots and it worked. Therefore, I am not sure how well it will work for any data that we can't just steal the Y-values from (if that makes sense). Anyways, I am open to suggestions and feedback!