diff --git a/lddecode/core.py b/lddecode/core.py index 364cd25d7..e4c7eb21c 100644 --- a/lddecode/core.py +++ b/lddecode/core.py @@ -1660,6 +1660,8 @@ def getLine0(self, validpulses): isFirstField_prev = not self.prevfield.isFirstField conf_prev = self.prevfield.sync_confidence + #print(line0loc_local, line0loc_prev, line0loc_next) + # Best case - all three line detectors returned something - perform TOOT using median if line0loc_local is not None and line0loc_next is not None and line0loc_prev is not None: isFirstField_all = (isFirstField_local + isFirstField_prev + isFirstField_next) >= 2 @@ -1741,6 +1743,7 @@ def compute_linelocs(self): self.rawpulses = self.getpulses() if self.rawpulses is None or len(self.rawpulses) == 0: logging.error("Unable to find any sync pulses, jumping one second") + print('x1') return None, None, int(self.rf.freq_hz) self.validpulses = validpulses = self.refinepulses() @@ -1781,7 +1784,7 @@ def compute_linelocs(self): rlineloc_end = np.round(lineloc_end) lineloc_end_distance = np.abs(lineloc_end - rlineloc_end) - if p[0] == 0 and lineloc_end_distance < lineloc_distance: + if p[0] == 0 and rlineloc > 23 and lineloc_end_distance < lineloc_distance: skip_reached = True if skip_reached: @@ -1800,8 +1803,6 @@ def compute_linelocs(self): if p[0] > 0 or (p[0] == 0 and rlineloc < 10): continue - #print(p, lineloc, rlineloc) - linelocs_dict[np.round(lineloc)] = p[1].start linelocs_dist[np.round(lineloc)] = lineloc_distance @@ -2660,6 +2661,8 @@ def __init__(self, fname_in, fname_out, freader, analog_audio = 0, digital_audio self.doDOD = doDOD + self.badfields = None + self.fieldinfo = [] self.leadIn = False @@ -2799,6 +2802,10 @@ def readfield(self, initphase = False): redo = False while done == False: + if redo: + # Only allow one redo, no matter what + done = True + self.fieldloc = self.fdoffset f, offset = self.decodefield(initphase = initphase) @@ -2846,6 +2853,12 @@ def readfield(self, initphase = False): self.fdoffset -= offset else: done = True + else: + # Probably jumping ahead - delete the previous field so + # TBC computations aren't thrown off + if self.curfield is not None and self.badfields is None: + self.badfields = (self.curfield, f) + self.curfield = None self.curfield = f diff --git a/lddecode/plot_utils.py b/lddecode/plot_utils.py index d316bda3a..d3b52c374 100644 --- a/lddecode/plot_utils.py +++ b/lddecode/plot_utils.py @@ -230,6 +230,13 @@ def draw_raw_field(self, channel = 'demod'): return draw_raw_bwimage(cooked, self.inlinelen, len(self.linelocs)-2, vscale=4) +def draw_really_raw_field(self, channel = 'demod'): + # Draws the pre-TBC field. Useful for determining if there's a skip (i.e. issue #509) + cooked = self.hz_to_output(self.data['video'][channel]) + cooked = cooked[:(len(cooked)//self.inlinelen)*self.inlinelen] + + return draw_raw_bwimage(cooked, self.inlinelen, (len(cooked)//self.inlinelen), vscale=4) + def plotline(field, line, usecs = 63.5, linelocs = None): ls = field.lineslice(line, 0, usecs, linelocs) plt.plot(field.data['video']['demod'][ls])