Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion xpdtools/pipelines/qoi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import scipy.signal as sig

import numpy as np
from .raw_pipeline import mean, pdf, q
from bluesky.callbacks import LivePlot

r = pdf.pluck(0)
true_pdf = pdf.pluck(1)
Expand Down Expand Up @@ -29,3 +30,44 @@

pdf_argrelmax_kwargs = pdf_peaks.upstreams[0].kwargs
mean_argrelmax_kwargs = mean_peaks.upstreams[0].kwargs

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a lot of extra lines, can we reduce it down to 1?


def max_value(pdf):
Copy link
Member

Choose a reason for hiding this comment

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

these need docstrings.

Copy link
Author

Choose a reason for hiding this comment

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

I believe this is the old commit. The more recent commit has these functions moved to the tools.py file with docstrings.

return np.amax(pdf.pluck(1))


def total_counts(pdf):
return len(pdf.pluck(0))


def tallest_peak(pdf):
peaks = sig.find_peaks(pdf.pluck(1))
height = []
r_val = []
for i in peaks[0]:
height.append(pdf.pluck(1)[i])
r_val.append(pdf.pluck(0)[i])
return np.amax(r_val), np.amax(height)

#doesn't quite work yet
def oscillation_behavior(pdf):
def func(x, a, b, c):
return a * np.exp(-b * x) + c
for i in range(len(pdf.pluck(0))):
if pdf.pluck(1)[i] >= 20:
idx = i
break
peaks = sig.find_peaks(pdf.pluck(1)[idx:])
height = []
r_val = []
for i in peaks[0]:
height.append(pdf.pluck(1)[i])
r_val.append(pdf.pluck(0)[i])

highest_value_stream = pdf.map(max_value)
total_counts_stream = pdf.map(total_counts)
tallest_peak_height, tallest_peak_position = pdf.map(tallest_peak)