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

Merge branch 'master' into develop

Conflicts:
	setup.py
parents 68e99241 2a78625f
No related branches found
No related tags found
No related merge requests found
......@@ -47,15 +47,15 @@ def main():
util.configure_logging(args)
def pdsfilename(product):
return 'P157{}{:%y%j%H%M%S}001.PDX'.format(product, args.created)
return 'P157{}XT{:%y%j%H%M%S}001.PDS'.format(product, args.created)
def remove_files(files):
[os.remove(f) for f in files]
science_products = {
'RNSCA-RVIRS': '0826VIIRSSCIENCEAT',
'RCRIS-RNSCA': '1289CRISSCIENCEAAT',
'RATMS-RNSCA': '0515ATMSSCIENCEAAT'}
'RNSCA-RVIRS': '0826VIIRSSCIENCE',
'RCRIS-RNSCA': '1289CRISSCIENCEA',
'RATMS-RNSCA': '0515ATMSSCIENCEA'}
file_type = os.path.basename(args.rdr[0]).split('_')[0]
LOG.info('File type %s', file_type)
......@@ -76,7 +76,7 @@ def main():
if args.ancillary:
for apid in (0, 8, 11):
inputs = sorted(glob.glob('*.anc{:d}.pkts'.format(apid)))
product = '{:04d}AAAAAAAAAAAAA'.format(apid)
product = '{:04d}AAAAAAAAAAA'.format(apid)
pdsname = pdsfilename(product)
LOG.info("merging apid %d to %s", apid, pdsname)
streams = [stream.jpss_packet_stream(open(f, 'rb')) for f in inputs]
......
......@@ -152,7 +152,7 @@ def _generate_packet_datasets(group):
dsnames = group.keys()
for name in _sorted_packet_dataset_names(dsnames):
ds = group[name]
yield np.array(ds)
yield name, np.array(ds)
def _find_science_group(fobj):
......@@ -164,7 +164,10 @@ def _find_science_group(fobj):
def _rdrs_for_packet_dataset(group):
if group:
for buf in _generate_packet_datasets(group):
for name, buf in _generate_packet_datasets(group):
if buf.shape[0] < c.sizeof(StaticHeader):
LOG.warn('Not enough bytes for %s static header', name)
continue
header = StaticHeader.from_buffer(buf)
apids = _read_apid_list(header, buf)
yield CommonRdr(buf, header, list(apids))
......@@ -222,21 +225,21 @@ def write_rdr_datasets(filepath, science=True, ancillary=True, skipfill=False):
rdrs = rdr_datasets(filepath)
if science:
dest = open('{}.science.pkts'.format(rdrname), 'wb')
for idx, rdr in enumerate(rdrs['science']):
LOG.debug(
'writing science gran %d %s-%s-%s',
idx, rdr.header.satellite, rdr.header.sensor, rdr.header.type_id)
_write_packets(rdr.packets(), dest, skipfill)
with open('{}.science.pkts'.format(rdrname), 'wb') as dest:
for idx, rdr in enumerate(rdrs['science']):
LOG.debug(
'writing science gran %d %s-%s-%s',
idx, rdr.header.satellite, rdr.header.sensor, rdr.header.type_id)
_write_packets(rdr.packets(), dest, skipfill)
if ancillary:
for idx, rdr in enumerate(rdrs['ancillary']):
packets = {a.value: rdr.packets_for_apid(a.value)
for a in rdr.apids}
for apid, packets in packets.items():
dest = open('{}.anc{}.pkts'.format(rdrname, apid), 'wb')
LOG.debug(
'writing ancillary gran %d %s-%s-%s %d',
idx, rdr.header.satellite, rdr.header.sensor,
rdr.header.type_id, apid.value)
_write_packets(packets, dest)
with open('{}.anc{}.pkts'.format(rdrname, apid), 'wb') as dest:
_write_packets(packets, dest)
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