Skip to content

Commit

Permalink
intermediate commit saving progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Codrea committed Mar 26, 2024
1 parent bd43833 commit 9037214
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apstools/plans/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def erf_model(x, low, high, width, midpoint):
"""
return (high - low) * 0.5 * (1 - erf((x - midpoint) / width)) + low

def check_signal_change(y_data, window_size=10, std_multiplier=10):
def check_signal_change(y_data, window_size=5, std_multiplier=5):
"""
Checks if the signal has a significant change or if it's just noise.
Expand All @@ -325,16 +325,22 @@ def check_signal_change(y_data, window_size=10, std_multiplier=10):
y_data, np.ones(window_size) / window_size, mode="valid"
)

print(f"y_0: {y_smoothed[0]}")

# Calculate the standard deviation of the smoothed data
std_dev = np.std(y_smoothed)
print(std_dev)

# Find peaks and troughs which are above/below the std_multiplier * std_dev
peaks, _ = find_peaks(
y_smoothed, prominence=y_smoothed[0] + std_multiplier * std_dev
y_smoothed, height=y_smoothed[0] + std_multiplier * std_dev
)
troughs, _ = find_peaks(
y_smoothed, prominence=y_smoothed[0] - std_multiplier * std_dev
-y_smoothed, threshold=y_smoothed[0] + std_multiplier * std_dev
)
print(troughs)
# print(f"peaks: {len(peaks)}")
print(f"troughs: {len(troughs)}")

# Check for significant changes
if len(peaks) > 0 or len(troughs) > 0:
Expand Down

0 comments on commit 9037214

Please sign in to comment.