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

fix: Too many open files for converting lots of spacecraft data

parent c5f240b1
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,6 @@ __copyright__ = "Copyright (C) 2015 University of Wisconsin SSEC. All rights res
import os
import glob
import logging
import tempfile
from datetime import datetime, timedelta
from edosl0util import stream, merge, jpssrdr
......@@ -95,7 +94,8 @@ def spacecraft(satellite, rdrs, start, end):
for apid in (0, 8, 11):
# alphanumeric sorting to bootstrap final sort
inputs = sorted(glob.glob('*.ancillary{}.pkts'.format(apid)))
streams = [stream.jpss_packet_stream(open(f, 'rb')) for f in inputs]
files = [open(f, 'rb') for f in inputs]
streams = [stream.jpss_packet_stream(f) for f in files]
product = 'P{}{:04d}'.format(scid, apid)
pdsname = pdsfilename(product, start)
......@@ -103,6 +103,9 @@ def spacecraft(satellite, rdrs, start, end):
with open(pdsname, 'wb') as dest:
merge.merge(streams, output=dest, trunc_to=[start, end])
# lots of files so make sure they're closed
[f.close() for f in files]
def main():
# XXX: This currently uses standard CCSDS packet merging that does not have
......@@ -192,7 +195,7 @@ def main():
util.configure_logging(args)
pdsname = args.func(args)
args.func(args)
if not args.leave_pkts:
remove_files(glob.glob('*.pkts'))
......
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