mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
fixed varience into code
This commit is contained in:
parent
0bb70e7966
commit
3726b96b86
1 changed files with 2 additions and 3 deletions
|
|
@ -15,13 +15,12 @@ CHANNELS = 1
|
||||||
MIN_EDGES = 1000 # sanity threshold
|
MIN_EDGES = 1000 # sanity threshold
|
||||||
|
|
||||||
def detect_rising_edges(signal):
|
def detect_rising_edges(signal):
|
||||||
# signal: flattened 1D numpy array
|
|
||||||
above_zero = signal > 0
|
above_zero = signal > 0
|
||||||
edges = np.where(np.logical_and(~above_zero[:-1], above_zero[1:]))[0]
|
edges = np.where(np.logical_and(~above_zero[:-1], above_zero[1:]))[0]
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
def analyze_pulse_durations(edges, samplerate):
|
def analyze_pulse_durations(edges, samplerate):
|
||||||
durations = np.diff(edges) / samplerate # in seconds
|
durations = np.diff(edges) / samplerate
|
||||||
if len(durations) == 0:
|
if len(durations) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
@ -41,7 +40,7 @@ def analyze_pulse_durations(edges, samplerate):
|
||||||
def verdict(pulse_data):
|
def verdict(pulse_data):
|
||||||
if pulse_data is None or pulse_data["count"] < MIN_EDGES:
|
if pulse_data is None or pulse_data["count"] < MIN_EDGES:
|
||||||
return "❌ No signal or not enough pulses"
|
return "❌ No signal or not enough pulses"
|
||||||
elif 30 < pulse_data["short_pct"] < 70:
|
elif 20 <= pulse_data["short_pct"] <= 80:
|
||||||
return f"✅ LTC-like bi-phase signal detected ({pulse_data['count']} pulses)"
|
return f"✅ LTC-like bi-phase signal detected ({pulse_data['count']} pulses)"
|
||||||
else:
|
else:
|
||||||
return f"⚠️ Inconsistent signal — may be non-LTC or noisy"
|
return f"⚠️ Inconsistent signal — may be non-LTC or noisy"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue