Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

gwenwhite
Copy link
Contributor

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!

@codecov
Copy link

codecov bot commented Dec 31, 2021

Codecov Report

Merging #31 (11783aa) into master (2750eac) will decrease coverage by 0.86%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
cmeutils/plot_tools.py 50.00% <50.00%> (ø)

Copy link
Member

@jennyfothergill jennyfothergill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @gwenwhite! :)

cmeutils/tests/test_plot.py Outdated Show resolved Hide resolved
cmeutils/tests/test_plot.py Outdated Show resolved Hide resolved
cmeutils/plot_tools.py Outdated Show resolved Hide resolved
cmeutils/plot_tools.py Outdated Show resolved Hide resolved
cmeutils/plot_tools.py Outdated Show resolved Hide resolved
cmeutils/plot_tools.py Outdated Show resolved Hide resolved
Copy link
Member

@jennyfothergill jennyfothergill left a 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
Copy link
Member

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

Suggested change
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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

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 :)

@chrisjonesBSU
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants