no idea
This commit is contained in:
parent
136e8a380c
commit
447e88b212
@ -3,40 +3,8 @@ import rlxnix as rlx
|
|||||||
from scipy.signal import welch
|
from scipy.signal import welch
|
||||||
|
|
||||||
def all_coming_together(freq_array, power_array, points_list, categories, num_harmonics_list, colors, delta=2.5, threshold=0.5):
|
def all_coming_together(freq_array, power_array, points_list, categories, num_harmonics_list, colors, delta=2.5, threshold=0.5):
|
||||||
"""
|
# Initialize dictionaries and lists
|
||||||
Process a list of points, calculating integrals, checking validity, and preparing harmonics for valid points.
|
valid_points = []
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
freq_array : np.array
|
|
||||||
Array of frequencies corresponding to the power values.
|
|
||||||
power_array : np.array
|
|
||||||
Array of power spectral density values.
|
|
||||||
points_list : list
|
|
||||||
List of harmonic frequency points to process.
|
|
||||||
categories : list
|
|
||||||
List of corresponding categories for each point.
|
|
||||||
num_harmonics_list : list
|
|
||||||
List of the number of harmonics for each point.
|
|
||||||
colors : list
|
|
||||||
List of colors corresponding to each point's category.
|
|
||||||
delta : float, optional
|
|
||||||
Radius of the range for integration around each point (default is 2.5).
|
|
||||||
threshold : float, optional
|
|
||||||
Threshold value to compare integrals with local mean (default is 0.5).
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
valid_points : list
|
|
||||||
A continuous list of harmonics for all valid points.
|
|
||||||
color_mapping : dict
|
|
||||||
A dictionary mapping categories to corresponding colors.
|
|
||||||
category_harmonics : dict
|
|
||||||
A mapping of categories to their harmonic frequencies.
|
|
||||||
messages : list
|
|
||||||
A list of messages for each point, stating whether it was valid or not.
|
|
||||||
"""
|
|
||||||
valid_points = [] # A continuous list of harmonics for valid points
|
|
||||||
color_mapping = {}
|
color_mapping = {}
|
||||||
category_harmonics = {}
|
category_harmonics = {}
|
||||||
messages = []
|
messages = []
|
||||||
@ -46,21 +14,25 @@ def all_coming_together(freq_array, power_array, points_list, categories, num_ha
|
|||||||
num_harmonics = num_harmonics_list[i]
|
num_harmonics = num_harmonics_list[i]
|
||||||
color = colors[i]
|
color = colors[i]
|
||||||
|
|
||||||
# Step 1: Calculate the integral for the point
|
# Calculate the integral for the point
|
||||||
integral, local_mean = calculate_integral_2(freq_array, power_array, point, delta)
|
integral, local_mean = calculate_integral_2(freq_array, power_array, point, delta)
|
||||||
|
|
||||||
# Step 2: Check if the point is valid
|
# Check if the point is valid
|
||||||
valid = valid_integrals(integral, local_mean, point, threshold)
|
valid = valid_integrals(integral, local_mean, point, threshold)
|
||||||
if valid:
|
if valid:
|
||||||
# Step 3: Prepare harmonics if the point is valid
|
# Prepare harmonics if the point is valid
|
||||||
harmonics, color_map, category_harm = prepare_harmonic(point, category, num_harmonics, color)
|
harmonics, color_map, category_harm = prepare_harmonic(point, category, num_harmonics, color)
|
||||||
valid_points.extend(harmonics) # Use extend() to append harmonics in a continuous manner
|
valid_points.extend(harmonics)
|
||||||
color_mapping.update(color_map)
|
color_mapping[category] = color # Store color for category
|
||||||
category_harmonics.update(category_harm)
|
category_harmonics[category] = harmonics
|
||||||
messages.append(f"The point {point} is valid.")
|
messages.append(f"The point {point} is valid.")
|
||||||
else:
|
else:
|
||||||
messages.append(f"The point {point} is not valid.")
|
messages.append(f"The point {point} is not valid.")
|
||||||
|
|
||||||
|
# Debugging print statements
|
||||||
|
print("Color Mapping:", color_mapping)
|
||||||
|
print("Category Harmonics:", category_harmonics)
|
||||||
|
|
||||||
return valid_points, color_mapping, category_harmonics, messages
|
return valid_points, color_mapping, category_harmonics, messages
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user