Update ccl_findpeaks.py
This commit is contained in:
parent
90c0256595
commit
d30b348425
@ -15,54 +15,49 @@ def ccl_findpeaks(
|
||||
i.e. will only detect peaks above 75% of max intensity
|
||||
|
||||
prominence - defines a drop of values that must be between two peaks, must be positive number
|
||||
i.e. if promimence is 20, it will detect two neigbouring peaks of 300 and 310 intesities,
|
||||
i.e. if promimence is 20, it will detect two neigbouring peaks of 300 and 310 intesities,
|
||||
if none of the itermediate values are lower that 290
|
||||
|
||||
smooth - if true, smooths data by savitzky golay filter, if false - no smoothing
|
||||
|
||||
window_size - window size for savgol filter, must be odd positive integer
|
||||
|
||||
poly_order = order of the polynomial used in savgol filter, must be positive integer smaller than
|
||||
poly_order = order of the polynomial used in savgol filter, must be positive integer smaller than
|
||||
window_size returns: dictionary with following structure:
|
||||
D{M34{ 'num_of_peaks': 1, #num of peaks
|
||||
'peak_indexes': [20], # index of peaks in omega array
|
||||
'peak_heights': [90.], # height of the peaks (if data vere smoothed
|
||||
'peak_heights': [90.], # height of the peaks (if data vere smoothed
|
||||
its the heigh of the peaks in smoothed data)
|
||||
"""
|
||||
|
||||
if type(data) is not dict and data["file_type"] != "ccl":
|
||||
print("Data is not a dictionary or was not made from ccl file")
|
||||
|
||||
if 0 <= int_threshold <= 1:
|
||||
pass
|
||||
else:
|
||||
int_threshold = 0.75
|
||||
if not 0 <= int_threshold <= 1:
|
||||
int_threshold = 0.8
|
||||
print(
|
||||
"Invalid value for int_threshold, select value between 0 and 1, new value set to:",
|
||||
int_threshold,
|
||||
)
|
||||
if isinstance(window_size, int) is True and (window_size % 2) != 0 and window_size >= 1:
|
||||
pass
|
||||
else:
|
||||
|
||||
if isinstance(window_size, int) is False or (window_size % 2) == 0 or window_size <= 1:
|
||||
window_size = 7
|
||||
print(
|
||||
"Invalid value for window_size, select positive odd integer, new value set to:",
|
||||
window_size,
|
||||
)
|
||||
if isinstance(poly_order, int) is True and window_size > poly_order >= 1:
|
||||
pass
|
||||
else:
|
||||
"Invalid value for window_size, select positive odd integer, new value set to!:",
|
||||
window_size)
|
||||
|
||||
if isinstance(poly_order, int) is False or window_size < poly_order:
|
||||
poly_order = 3
|
||||
print(
|
||||
"Invalid value for poly_order, select positive integer smaller than window_size, new value set to:",
|
||||
poly_order,
|
||||
)
|
||||
if isinstance(prominence, (int, float)) is True and prominence > 0:
|
||||
pass
|
||||
else:
|
||||
|
||||
if isinstance(prominence, (int, float)) is False and prominence < 0:
|
||||
prominence = 50
|
||||
print("Invalid value for prominence, select positive number, new value set to:", prominence)
|
||||
|
||||
|
||||
omega = data["Measurements"][str(keys)]["omega"]
|
||||
counts = np.array(data["Measurements"][str(keys)]["counts"])
|
||||
if smooth is True:
|
||||
|
Loading…
x
Reference in New Issue
Block a user