tested and tuned on Veghel Lab system
This commit is contained in:
parent
5d20d50822
commit
06f35acc4e
2 changed files with 15 additions and 13 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
# Configuration file for scanner service
|
# Configuration file for scanner service
|
||||||
# it is automatically re-loaded between scans
|
# it is automatically re-loaded between scans
|
||||||
start_freq: 10000.0
|
start_freq: 1000
|
||||||
stop_freq: 0.1
|
stop_freq: 0.2
|
||||||
freq_step_multiply: 0.95
|
freq_step_multiply: 0.95
|
||||||
|
allowed_noise_level: 9
|
||||||
|
skip_scans_for_noisy_freqs: 5
|
||||||
ampl: 1600
|
ampl: 1600
|
||||||
interference_freq: 0.052
|
|
||||||
interference_bandwidth: 0.008
|
|
||||||
noise_scan: False
|
noise_scan: False
|
||||||
|
|
|
||||||
16
scanner.py
16
scanner.py
|
|
@ -15,7 +15,7 @@ import os
|
||||||
data_rows = [] # global 2-D list
|
data_rows = [] # global 2-D list
|
||||||
state = {}
|
state = {}
|
||||||
blacklist = []
|
blacklist = []
|
||||||
ALLOWED_NOISE_LEVEL = 100.0
|
Inoise_baseline = 0.1
|
||||||
|
|
||||||
PATTERN = re.compile(
|
PATTERN = re.compile(
|
||||||
r"Va=(?P<Va>[\d.-]+)\s+Vp=(?P<Vp>[\d.-]+)\s+\|\s+"
|
r"Va=(?P<Va>[\d.-]+)\s+Vp=(?P<Vp>[\d.-]+)\s+\|\s+"
|
||||||
|
|
@ -198,7 +198,7 @@ class TelnetReader:
|
||||||
print("Interrupted by user.")
|
print("Interrupted by user.")
|
||||||
print(data_rows)
|
print(data_rows)
|
||||||
if state["freq"]>0.00001: # check if scan ended normally (e.g. no abort due to clipping)
|
if state["freq"]>0.00001: # check if scan ended normally (e.g. no abort due to clipping)
|
||||||
if False:
|
if True: # XXXDB
|
||||||
dump_into_database()
|
dump_into_database()
|
||||||
else:
|
else:
|
||||||
dump_csv("measurements.csv")
|
dump_csv("measurements.csv")
|
||||||
|
|
@ -217,6 +217,7 @@ class TelnetReader:
|
||||||
|
|
||||||
def process_line(self, line):
|
def process_line(self, line):
|
||||||
global state
|
global state
|
||||||
|
global Inoise_baseline
|
||||||
# print(f"RAW: {line}")
|
# print(f"RAW: {line}")
|
||||||
if not line.startswith("Va="): # skip lines that are not to be analyzed
|
if not line.startswith("Va="): # skip lines that are not to be analyzed
|
||||||
return
|
return
|
||||||
|
|
@ -239,13 +240,15 @@ class TelnetReader:
|
||||||
# there will be a lot of lines, but they will be skipped as they do not match the pattern
|
# there will be a lot of lines, but they will be skipped as they do not match the pattern
|
||||||
else: # regular loop (not initializing)
|
else: # regular loop (not initializing)
|
||||||
extract_to_dataframe(line) # capture the measurement
|
extract_to_dataframe(line) # capture the measurement
|
||||||
if data_rows and (data_rows[-1][11]>ALLOWED_NOISE_LEVEL or data_rows[-1][12]>ALLOWED_NOISE_LEVEL):
|
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)):
|
||||||
# Too much noise: add to blacklist
|
# Too much noise: add to blacklist
|
||||||
print("Too much noise - adding to blacklist")
|
print("Too much noise - adding to blacklist")
|
||||||
blacklist.append({"Freq": state["freq"], "NrToSkip": 10})
|
blacklist.append({"Freq": state["freq"], "NrToSkip": state["skip_scans_for_noisy_freqs"]})
|
||||||
print(f"Blacklist: {blacklist}\r")
|
print(f"Blacklist: {blacklist}\r")
|
||||||
del data_rows[-1] # remove this last entry from the list (for DB it is okay, but for CSV things will shift)
|
del data_rows[-1] # remove this last entry from the list (for DB it is okay, but for CSV things will shift)
|
||||||
# print(f"minmax: {data_rows[7]},{data_rows[8]},{data_rows[9]},{data_rows[10] }\n")
|
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 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
|
||||||
state["freq"] = 0 # force ending of the scan, and write no data in the database
|
state["freq"] = 0 # force ending of the scan, and write no data in the database
|
||||||
# calculate next freq
|
# calculate next freq
|
||||||
|
|
@ -313,11 +316,10 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
reader.read_loop()
|
reader.read_loop()
|
||||||
# decrement all freq's in blacklist:
|
# decrement all freq's in blacklist:
|
||||||
print(f"Before decrementing: {blacklist}")
|
|
||||||
for item in blacklist:
|
for item in blacklist:
|
||||||
item["NrToSkip"] -= 1
|
item["NrToSkip"] -= 1
|
||||||
blacklist = [item for item in blacklist if item["NrToSkip"] != 0] # remove all zero items
|
blacklist = [item for item in blacklist if item["NrToSkip"] != 0] # remove all zero items
|
||||||
print(f"After removing zeros: {blacklist}")
|
print(f"Blacklist: {blacklist}")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
reader.disconnect()
|
reader.disconnect()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue