Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SIPS
EdosL0Util
Commits
baa7fbb7
Commit
baa7fbb7
authored
9 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
Fix few small bugs.
Fixes issue
#1
.
parent
0579b00b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
edosl0util/merge.py
+2
-4
2 additions, 4 deletions
edosl0util/merge.py
edosl0util/split.py
+7
-4
7 additions, 4 deletions
edosl0util/split.py
edosl0util/stream.py
+10
-6
10 additions, 6 deletions
edosl0util/stream.py
with
19 additions
and
14 deletions
edosl0util/merge.py
+
2
−
4
View file @
baa7fbb7
...
...
@@ -42,6 +42,7 @@ def merge(streams, output=sys.stdout):
LOG
.
debug
(
"
seeking to %s, %s
"
,
last_stamp
,
last_apid
)
stream
.
seek
(
last_stamp
,
last_apid
)
# until `next` causes StopIteration
while
True
:
packets
=
deque
()
...
...
@@ -69,9 +70,6 @@ def merge(streams, output=sys.stdout):
LOG
.
debug
(
"
invalid group, switching streams:%s
"
,
group
)
break
if
not
packets
:
continue
# first packet always has a stamp because it's either standalone or
# part of a valid group
last_stamp
=
packets
[
0
].
stamp
...
...
@@ -90,5 +88,5 @@ def merge(streams, output=sys.stdout):
def
merge_files
(
filepaths
,
destpath
):
streams
=
(
PacketStream
(
open
(
f
))
for
f
in
filepaths
)
streams
=
[
PacketStream
(
open
(
f
))
for
f
in
filepaths
]
merge
(
streams
,
output
=
open
(
destpath
,
'
wb
'
))
This diff is collapsed.
Click to expand it.
edosl0util/split.py
+
7
−
4
View file @
baa7fbb7
...
...
@@ -43,10 +43,13 @@ def split_stream(fobj, minutes):
def
_replace_pdsname_stamp
(
filename
,
stamp
):
# P1570769AAAAAAAAAAAAAS15208032721000.PDS
pat
=
'
{}{}{}
'
.
format
(
filename
[:
22
],
'
%y%j%H%M%S
'
,
filename
[
-
7
:])
# P1570769AAAAAAAAAAAAAS15208032721001.PDS
#
# NOTE: It seems that EDOS uses the file_id column for fractional seconds.
# We just zero this out since the bucket should be on even seconds.
pat
=
'
{}{}0{}
'
.
format
(
filename
[:
22
],
'
%y%j%H%M%S
'
,
filename
[
-
6
:])
return
stamp
.
strftime
(
pat
)
...
...
This diff is collapsed.
Click to expand it.
edosl0util/stream.py
+
10
−
6
View file @
baa7fbb7
...
...
@@ -4,8 +4,6 @@ from collections import deque
from
edos.ccsds
import
(
c
,
PrimaryHeader
,
JpssFirstSecondaryHeader
,
JpssSecondaryHeader
,
GROUP_FIRST
,
GROUP_CONTINUING
,
GROUP_LAST
,
...
...
@@ -99,7 +97,7 @@ class PacketStream(object):
self
.
_header_lookup
=
header_lookup
def
__str__
(
self
):
return
'
<PacketStream pos=%d %s>
'
%
(
self
.
tell
(),
self
.
_input
)
return
'
<PacketStream pos=%d %s>
'
%
(
self
.
_input
.
tell
(),
self
.
_input
)
def
__iter__
(
self
):
return
self
...
...
@@ -125,7 +123,7 @@ class PacketStream(object):
"""
# return any items on the seek cache before reading more
if
len
(
self
.
_seek_cache
):
return
self
.
_seek_cache
.
pop
()
return
self
.
_seek_cache
.
pop
left
()
buf
=
self
.
_read
(
c
.
sizeof
(
PrimaryHeader
))
data
=
buf
...
...
@@ -164,16 +162,22 @@ class PacketStream(object):
:raises: StopIteration if the end of the stream is reached before the
criteria can be met.
"""
# seek past partial groups
packet
=
self
.
next
()
while
not
packet
.
stamp
:
packet
=
self
.
next
()
# seek to first packet > `stamp`
current_stamp
=
packet
.
stamp
while
current_stamp
<
stamp
:
while
current_stamp
<
=
stamp
:
packet
=
self
.
next
()
current_stamp
=
packet
.
stamp
or
current_stamp
# put back so next packet is the first packet > `stamp`
self
.
push_back
(
packet
)
if
apid
is
not
None
:
packet
=
self
.
next
()
while
packet
.
apid
!=
apid
:
packet
=
self
.
next
()
self
.
push_back
(
packet
)
...
...
@@ -198,4 +202,4 @@ def _cmp_by_first_pkt(filea, fileb):
def
make_streams
(
filepaths
):
filepaths
.
sort
(
_cmp_by_first_pkt
)
return
[
PacketStream
(
io
.
open
(
f
,
'
rb
'
))
for
f
in
filepaths
]
return
[
PacketStream
(
open
(
f
,
'
rb
'
))
for
f
in
filepaths
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment