Tested and working with new Q method

This commit is contained in:
gertjan 2026-03-25 11:17:22 +01:00
parent a64bfe98c5
commit b07edd3839

View file

@ -16,6 +16,7 @@ data_rows = [] # global 2-D list
state = {}
blacklist = []
Inoise_baseline = 0.1
n_clip_events = 0
PATTERN = re.compile(
r"Va=(?P<Va>[\d.-]+)\s+Vp=(?P<Vp>[\d.-]+)\s*\|\s*"
@ -221,6 +222,7 @@ class TelnetReader:
def process_line(self, line):
global state
global Inoise_baseline
global n_clip_events
print(line)
if not line.startswith("Va="): # skip lines that are not to be analyzed
return
@ -242,7 +244,7 @@ class TelnetReader:
extract_to_dataframe(line) # capture the measurement
if state["freq"]>3.0:
Inoise_baseline = 0.8*Inoise_baseline + 0.2*data_rows[-1][12] # remember last baseline around 3Hz (assuming top-down scanning)
if data_rows and (data_rows[-1][11]>state["allowed_noise_level"] or data_rows[-1][12]>state["allowed_noise_level"] or (state["freq"]<3.0 and data_rows[-1][12]>1.25*Inoise_baseline)):
if data_rows and (state["freq"]>10) and (data_rows[-1][11]>state["allowed_noise_level"] or data_rows[-1][12]>state["allowed_noise_level"]): # or (state["freq"]<3.0 and data_rows[-1][12]>1.25*Inoise_baseline)):
# Too much noise: add to blacklist
print("Too much noise - adding to blacklist")
blacklist.append({"Freq": state["freq"], "NrToSkip": state["skip_scans_for_noisy_freqs"]})
@ -250,7 +252,11 @@ class TelnetReader:
del data_rows[-1] # remove this last entry from the list (for DB it is okay, but for CSV things will shift)
else:
if data_rows and (data_rows[-1][7]<5 or data_rows[-1][8]>250 or data_rows[-1][9]<5 or data_rows[-1][10]>250): # XXXDB
if (++n_clip_events > 2): # react only after multiple clip events (solves startup issue)
if data_rows[-1][9]>0: # make exception (for our broken hardware?)
state["freq"] = 0 # force ending of the scan, and write no data in the database
else:
n_clip_events=0
# calculate next freq
if state["freq"] > 1.0:
freq_multiplier = state["freq_step_multiply"] # calc next freq