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

merge: fix for incorrect VIIRS apid order

Add option to CLI tool to specify VIIRS APID order. **NOT TESTED
parent 57353045
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@ from datetime import datetime
from edosl0util.cli import util
from edosl0util import merge, stream
VIIRS_APID_ORDER = [826, 821] + range(800, 826)
def main():
parser = util.default_parser()
......@@ -15,14 +17,22 @@ def main():
help=('Truncate to the interval given as coma separated timestamps of '
'the format YYYY-MM-DD HH:MM:SS. The begin time is inclusive, the '
'end time is exclusive.'))
parser.add_argument(
'-a', '--apid-order', choices=['viirs', 'numerical'], default='numerical',
help=('Packets will be sorted by time and the named order provided. '
'"viirs" will sort packets in APID order as expectet by the VIIRS '
'L1 software. "numerical" will simply sort APIDs in numerical '
'order'))
parser.add_argument('pds', nargs='+')
args = parser.parse_args()
util.configure_logging(args)
apid_order = {'viirs': VIIRS_APID_ORDER, 'numerical': None}[args.apid_order]
streams = [stream.jpss_packet_stream(io.open(f, 'rb')) for f in args.pds]
merge.merge(
streams, output=io.open(args.output, 'wb'), trunc_to=args.trunc_to)
streams, output=io.open(args.output, 'wb'),
trunc_to=args.trunc_to, apid_order=apid_order)
if __name__ == '__main__':
......
......@@ -86,7 +86,7 @@ def read_packet_index(stream):
def _sort_by_time_apid(index, order=None):
if order:
index = sorted(index, key=lambda p: order.index(p.apid))
index = sorted(index, key=lambda p: order.index(p.apid) if p.apid in order else -1)
else:
index = sorted(index, key=lambda p: p.apid)
return sorted(index, key=lambda p: p.stamp)
......
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