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
e3d36a81
Commit
e3d36a81
authored
7 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
don't use astroy when parsing packets
parent
f5753592
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
edosl0util/timecode.py
+7
-8
7 additions, 8 deletions
edosl0util/timecode.py
setup.py
+2
-1
2 additions, 1 deletion
setup.py
tests/test_timecode.py
+0
-29
0 additions, 29 deletions
tests/test_timecode.py
with
9 additions
and
38 deletions
edosl0util/timecode.py
+
7
−
8
View file @
e3d36a81
# encoding: utf-8
# encoding: utf-8
from
datetime
import
timedelta
,
datetime
__copyright__
=
"
Copyright (C) 2015 University of Wisconsin SSEC. All rights reserved.
"
__copyright__
=
"
Copyright (C) 2015 University of Wisconsin SSEC. All rights reserved.
"
from
astropy.time
import
Time
,
TimeDelta
from
astropy.time
import
Time
,
TimeDelta
IET_EPOCH
=
Time
(
'
1958-01-01
'
,
scale
=
'
tai
'
)
UNIX_EPOCH
=
Time
(
'
1970-01-01
'
,
scale
=
'
utc
'
)
def
unixtime
(
dt
):
def
unixtime
(
dt
):
"""
"""
Datetime to Unix timestamp.
Datetime to Unix timestamp.
"""
"""
return
(
dt
-
UNIX_EPOCH
).
total_seconds
()
return
(
dt
-
datetime
(
1970
,
1
,
1
)
).
total_seconds
()
def
cds_to_dt
(
days
,
millis
,
microseconds
):
def
cds_to_dt
(
days
,
millis
,
microseconds
):
"""
"""
CCSDS Day Segmented timecode to UTC datetime.
CCSDS Day Segmented timecode to UTC datetime.
"""
"""
iet
=
cds_to_iet
(
days
,
millis
,
microseconds
)
return
datetime
(
1970
,
1
,
1
)
+
timedelta
(
days
=
days
,
microseconds
=
1e6
*
millis
+
microseconds
)
return
(
IET_EPOCH
+
TimeDelta
(
iet
,
format
=
'
sec
'
)).
utc
.
datetime
def
cds_to_iet
(
days
,
ms
,
us
):
def
cds_to_iet
(
days
,
ms
,
us
):
"""
"""
CCSDS Day Segmented timecode parts to IET
CCSDS Day Segmented timecode parts to IET
(microseconds)
"""
"""
iet_epoch
=
Time
(
'
1958-01-01
'
,
scale
=
'
tai
'
)
ccsds_epoch
=
Time
(
'
1958-01-01
'
,
scale
=
'
tai
'
)
ccsds_epoch
=
Time
(
'
1958-01-01
'
,
scale
=
'
tai
'
)
day
=
Time
(
ccsds_epoch
.
jd
+
days
,
scale
=
'
utc
'
,
format
=
'
jd
'
)
-
IET_EPOCH
day
=
Time
(
ccsds_epoch
.
jd
+
days
,
scale
=
'
utc
'
,
format
=
'
jd
'
)
-
iet_epoch
return
int
(
day
.
sec
*
1e6
+
ms
*
1e3
+
us
)
return
int
(
day
.
sec
*
1e6
+
ms
*
1e3
+
us
)
This diff is collapsed.
Click to expand it.
setup.py
+
2
−
1
View file @
e3d36a81
...
@@ -13,8 +13,9 @@ setup(
...
@@ -13,8 +13,9 @@ setup(
'
setuptools_scm
'
'
setuptools_scm
'
],
],
install_requires
=
[
install_requires
=
[
'
h5py
'
,
'
astropy
'
,
'
astropy
'
,
'
attrs
'
,
'
h5py
'
,
],
],
extras_require
=
{
extras_require
=
{
'
testing
'
:
[
'
testing
'
:
[
...
...
This diff is collapsed.
Click to expand it.
tests/test_timecode.py
deleted
100644 → 0
+
0
−
29
View file @
f5753592
from
datetime
import
datetime
,
timedelta
from
edosl0util
import
timecode
def
test_unixtime
():
assert
timecode
.
unixtime
(
timecode
.
UNIX_EPOCH
)
==
0
def
test_cds_to_timestamp
():
epoch
=
0
secs
=
timecode
.
cds_to_timestamp
(
0
,
0
,
0
,
epoch
)
assert
secs
==
0
secs
=
timecode
.
cds_to_timestamp
(
0
,
0
,
999
,
epoch
)
assert
secs
==
0.000999
secs
=
timecode
.
cds_to_timestamp
(
1
,
1
,
999
,
epoch
)
assert
secs
==
86400.001999
def
test_cds_stamp
():
epoch
=
timecode
.
UNIX_EPOCH
assert
timecode
.
cds_stamp
(
0
,
0
,
0
,
epoch
)
==
timecode
.
UNIX_EPOCH
assert
timecode
.
cds_stamp
(
0
,
0
,
999
,
epoch
)
==
datetime
(
1970
,
1
,
1
,
0
,
0
,
0
,
999
)
assert
timecode
.
cds_stamp
(
1
,
1
,
999
,
epoch
)
==
datetime
(
1970
,
1
,
2
,
0
,
0
,
0
,
1999
)
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