Skip to content
Snippets Groups Projects
Commit 2d1b0444 authored by Bruce Flynn's avatar Bruce Flynn
Browse files

add filter for orphans to make rdrgen happy

parent 168c8fbf
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,47 @@ def iter_pkts(l0_files):
yield pkt
def filter_group_orphans(s):
"""
Filter out any packets in a group that do not fall withing the expected
sequence id series and expected packets per group.
This is useful for input RDR packet streams received from direct braodcast
that may have sub-ideal packet sequences that RDR generation does not play
well with.
"""
seqnums = {}
viirs_apids = set(ViirsScienceApidInfo.apids)
for p in iter(s):
if p.apid in viirs_apids:
group_size = ViirsScienceApidInfo.get_packets_per_scan(p.apid)
# Not groupped
if group_size == 1:
yield p
continue
# Start of new group
if p.is_first():
seqnums[p.apid] = p.seqid
yield p
continue
# If not in seqnums we must not have seen a first packet for this
# APID so it must be hanging, drop it.
if p.apid not in seqnums:
continue
# Packet does not have sequence number expected to be part of this
# group, must be an orphan, drop it.
# Ok to assume VIIRS here because it's the only one using groups.
if not ViirsGroupedPacketTimeTracker.check_sequence_number(
p.seqid, seqnums[p.apid], group_size
):
continue
yield p
else:
yield p
def packets_to_rdrs(sat, l0_files, **kwargs):
return build_rdr(sat, iter_pkts(l0_files), **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment