implemented F4-FFT res conditioning
This commit is contained in:
43
main.py
43
main.py
@ -117,6 +117,29 @@ def resize_2d_interpolate(data, target_rows, target_cols):
|
||||
return data_resampled
|
||||
|
||||
|
||||
def BF_fft_postprocessor(spectrum: np.ndarray) -> np.ndarray:
|
||||
"""Болванка постобработки FFT-данных, полученных из файла (F4).
|
||||
|
||||
Принимает 1D массив амплитуд спектра и возвращает преобразованный массив
|
||||
той же длины. По умолчанию — тождественное преобразование.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
spec_L = len(spectrum)
|
||||
spectrum_lower = spectrum[:spec_L//2]
|
||||
spectrum_higher = spectrum[spec_L//2:]
|
||||
|
||||
spectrum[:spec_L//2] = spectrum_higher
|
||||
spectrum[spec_L//2:] = spectrum_lower[::-1]
|
||||
|
||||
try:
|
||||
print ("spectrum processed")
|
||||
return np.asarray(spectrum_tmp, dtype=float)
|
||||
except Exception:
|
||||
return spectrum
|
||||
|
||||
|
||||
def load_data_with_type(filename):
|
||||
"""Загружает данные и определяет их тип по первой строке."""
|
||||
with open(filename, 'r') as f:
|
||||
@ -164,18 +187,31 @@ def parse_hex_file(filename):
|
||||
# 3) Иначе F4 (если нет F0)
|
||||
# 4) Иначе F3 (sqrt)
|
||||
# 5) Иначе D0 как RAW
|
||||
#print("cur:", cur)
|
||||
if cur["F0"]:
|
||||
# print("got F0!")
|
||||
seg_sync.append(np.asarray(cur["F0"], dtype=float))
|
||||
elif cur["F1"] and cur["F2"] and len(cur["F1"]) == len(cur["F2"]):
|
||||
print("got F1,F2!")
|
||||
re = np.asarray(cur["F1"], dtype=float)
|
||||
im = np.asarray(cur["F2"], dtype=float)
|
||||
seg_fourier.append(np.sqrt(re * re + im * im))
|
||||
elif cur["F4"]:
|
||||
seg_fourier.append(np.asarray(cur["F4"], dtype=float))
|
||||
# print("got F4!")
|
||||
|
||||
# print("got fourier!")
|
||||
# FOURIER данные получены напрямую из файла (F4)
|
||||
col = np.asarray(cur["F4"], dtype=float)
|
||||
col = BF_fft_postprocessor(col)
|
||||
seg_fourier.append(col)
|
||||
elif cur["F3"]:
|
||||
# print("got F3!")
|
||||
|
||||
arr = np.asarray(cur["F3"], dtype=float)
|
||||
seg_fourier.append(np.sqrt(np.maximum(0.0, arr)))
|
||||
elif cur["D0"]:
|
||||
# print("got D0!")
|
||||
|
||||
seg_raw.append(np.asarray(cur["D0"], dtype=float))
|
||||
# Сброс
|
||||
cur = {"D0": [], "F0": [], "F1": [], "F2": [], "F3": [], "F4": []}
|
||||
@ -1152,6 +1188,11 @@ class DataAnalyzerApp:
|
||||
for i, col in enumerate(columns):
|
||||
col_time = file_time + timedelta(milliseconds=i * 10)
|
||||
self.bscan_queue.put((col, col_time, DATA_TYPE_FOURIER))
|
||||
# Обновляем график Фурье спектром из файла (берём последний столбец)
|
||||
try:
|
||||
self.FshiftS = np.asarray(columns[-1], dtype=float)
|
||||
except Exception:
|
||||
pass
|
||||
bscan_col = None
|
||||
|
||||
if add_to_bscan and bscan_col is not None and data_type != DATA_TYPE_FOURIER:
|
||||
|
||||
Reference in New Issue
Block a user