Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
358773ddef | ||
|
|
d0930261f7 | ||
|
|
a03a3c2e4b | ||
|
|
c102d4145c |
@@ -28,10 +28,6 @@ import locale
|
||||
from datetime import datetime
|
||||
|
||||
matplotlib.use('Agg')
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
|
||||
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" # For paired peaks names
|
||||
@@ -54,6 +50,22 @@ KLIPPAIN_COLORS = {
|
||||
}
|
||||
|
||||
|
||||
# Set the best locale for time and date formating (generation of the titles)
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
# Override the built-in print function to avoid problem in Klipper due to locale settings
|
||||
original_print = print
|
||||
def print_with_c_locale(*args, **kwargs):
|
||||
original_locale = locale.setlocale(locale.LC_ALL, None)
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
original_print(*args, **kwargs)
|
||||
locale.setlocale(locale.LC_ALL, original_locale)
|
||||
print = print_with_c_locale
|
||||
|
||||
|
||||
######################################################################
|
||||
# Computation of the PSD graph
|
||||
######################################################################
|
||||
@@ -330,15 +342,15 @@ def compute_mhi(combined_data, similarity_coefficient, num_unpaired_peaks):
|
||||
def mhi_lut(mhi):
|
||||
if 0 <= mhi <= 30:
|
||||
return "Excellent mechanical health"
|
||||
elif 31 <= mhi <= 45:
|
||||
elif 30 < mhi <= 45:
|
||||
return "Good mechanical health"
|
||||
elif 46 <= mhi <= 55:
|
||||
elif 45 < mhi <= 55:
|
||||
return "Acceptable mechanical health"
|
||||
elif 56 <= mhi <= 70:
|
||||
elif 55 < mhi <= 70:
|
||||
return "Potential signs of a mechanical issue"
|
||||
elif 71 <= mhi <= 85:
|
||||
elif 70 < mhi <= 85:
|
||||
return "Likely a mechanical issue"
|
||||
elif 86 <= mhi <= 100:
|
||||
elif 85 < mhi <= 100:
|
||||
return "Mechanical issue detected"
|
||||
|
||||
|
||||
|
||||
@@ -35,10 +35,6 @@ import locale
|
||||
from datetime import datetime
|
||||
|
||||
matplotlib.use('Agg')
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
|
||||
PEAKS_DETECTION_THRESHOLD = 0.05
|
||||
@@ -52,6 +48,22 @@ KLIPPAIN_COLORS = {
|
||||
}
|
||||
|
||||
|
||||
# Set the best locale for time and date formating (generation of the titles)
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
# Override the built-in print function to avoid problem in Klipper due to locale settings
|
||||
original_print = print
|
||||
def print_with_c_locale(*args, **kwargs):
|
||||
original_locale = locale.setlocale(locale.LC_ALL, None)
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
original_print(*args, **kwargs)
|
||||
locale.setlocale(locale.LC_ALL, original_locale)
|
||||
print = print_with_c_locale
|
||||
|
||||
|
||||
######################################################################
|
||||
# Computation
|
||||
######################################################################
|
||||
@@ -73,7 +85,7 @@ def calibrate_shaper_with_damping(datas, max_smoothing):
|
||||
fr, zeta = compute_damping_ratio(psd, freqs)
|
||||
|
||||
print("Recommended shaper is %s @ %.1f Hz" % (shaper.name, shaper.freq))
|
||||
print("Axis has a resonant frequency ω0=%.1fHz with an estimated damping ratio ζ=%.3f" % (fr, zeta))
|
||||
print("Axis has a main resonant frequency at %.1fHz with an estimated damping ratio of %.3f" % (fr, zeta))
|
||||
|
||||
return shaper.name, all_shapers, calibration_data, fr, zeta
|
||||
|
||||
|
||||
@@ -29,10 +29,6 @@ import locale
|
||||
from datetime import datetime
|
||||
|
||||
matplotlib.use('Agg')
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
|
||||
PEAKS_DETECTION_THRESHOLD = 0.05
|
||||
@@ -46,6 +42,22 @@ KLIPPAIN_COLORS = {
|
||||
}
|
||||
|
||||
|
||||
# Set the best locale for time and date formating (generation of the titles)
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
# Override the built-in print function to avoid problem in Klipper due to locale settings
|
||||
original_print = print
|
||||
def print_with_c_locale(*args, **kwargs):
|
||||
original_locale = locale.setlocale(locale.LC_ALL, None)
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
original_print(*args, **kwargs)
|
||||
locale.setlocale(locale.LC_ALL, original_locale)
|
||||
print = print_with_c_locale
|
||||
|
||||
|
||||
######################################################################
|
||||
# Computation
|
||||
######################################################################
|
||||
|
||||
@@ -63,7 +63,16 @@ def get_belts_graph():
|
||||
current_date = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
lognames = []
|
||||
|
||||
for filename in glob.glob('/tmp/raw_data_axis*.csv'):
|
||||
globbed_files = glob.glob('/tmp/raw_data_axis*.csv')
|
||||
if not globbed_files:
|
||||
print("No CSV files found in the /tmp folder to create the belt graphs!")
|
||||
sys.exit(1)
|
||||
if len(globbed_files) < 2:
|
||||
print("Not enough CSV files found in the /tmp folder. Two files are required for the belt graphs!")
|
||||
sys.exit(1)
|
||||
sorted_files = sorted(globbed_files, key=os.path.getmtime, reverse=True)
|
||||
|
||||
for filename in sorted_files[:2]:
|
||||
# Wait for the file handler to be released by Klipper
|
||||
while is_file_open(filename):
|
||||
time.sleep(3)
|
||||
@@ -86,13 +95,13 @@ def get_belts_graph():
|
||||
def get_shaper_graph():
|
||||
current_date = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
|
||||
# Get all the files and sort them based on last modified time to select the most recent one
|
||||
globbed_files = glob.glob('/tmp/raw_data*.csv')
|
||||
if len(globbed_files) > 1:
|
||||
print("There is more than 1 measurement.csv found in the /tmp folder. Unable to plot the shaper graphs!")
|
||||
print("Please clean the files in the /tmp folder and start again.")
|
||||
if not globbed_files:
|
||||
print("No CSV files found in the /tmp folder to create the input shaper graphs!")
|
||||
sys.exit(1)
|
||||
|
||||
filename = globbed_files[0]
|
||||
sorted_files = sorted(globbed_files, key=os.path.getmtime, reverse=True)
|
||||
filename = sorted_files[0]
|
||||
|
||||
# Wait for the file handler to be released by Klipper
|
||||
while is_file_open(filename):
|
||||
@@ -114,7 +123,15 @@ def get_vibrations_graph(axis_name):
|
||||
current_date = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
lognames = []
|
||||
|
||||
for filename in glob.glob('/tmp/adxl345-*.csv'):
|
||||
globbed_files = glob.glob('/tmp/adxl345-*.csv')
|
||||
if not globbed_files:
|
||||
print("No CSV files found in the /tmp folder to create the vibration graphs!")
|
||||
sys.exit(1)
|
||||
if len(globbed_files) < 3:
|
||||
print("Not enough CSV files found in the /tmp folder. At least 3 files are required for the vibration graphs!")
|
||||
sys.exit(1)
|
||||
|
||||
for filename in globbed_files:
|
||||
# Wait for the file handler to be released by Klipper
|
||||
while is_file_open(filename):
|
||||
time.sleep(3)
|
||||
|
||||
Reference in New Issue
Block a user