Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
2ed7a264
Commit
2ed7a264
authored
8 months ago
by
Sam Kagan
Browse files
Options
Downloads
Patches
Plain Diff
Added MJD converter
parent
8e3ead95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cli/executables/pexable/deliver/delivery/__init__.py
+16
-0
16 additions, 0 deletions
apps/cli/executables/pexable/deliver/delivery/__init__.py
apps/cli/executables/pexable/deliver/delivery/finder.py
+2
-5
2 additions, 5 deletions
apps/cli/executables/pexable/deliver/delivery/finder.py
with
18 additions
and
5 deletions
apps/cli/executables/pexable/deliver/delivery/__init__.py
+
16
−
0
View file @
2ed7a264
...
...
@@ -19,3 +19,19 @@
Workspaces data delivery module
"""
__version__
=
"
2.8.5.dev1
"
from
datetime
import
datetime
def
convert_datetime_to_mjd
(
timestamp
:
datetime
)
->
float
:
"""
Convert UTC datetime to MJD
Sources:
- https://www.celestialprogramming.com/julian.html for JD
- https://core2.gsfc.nasa.gov/time/a for MJD
"""
secs_since_posix_epoch
=
timestamp
.
timestamp
()
SECS_IN_DAY
=
86400
SECS_FROM_JD_TO_POSIX_EPOCHS
=
2440587.5
JD_TO_MJD
=
2400000.5
return
(
secs_since_posix_epoch
/
SECS_IN_DAY
)
+
SECS_FROM_JD_TO_POSIX_EPOCHS
-
JD_TO_MJD
This diff is collapsed.
Click to expand it.
apps/cli/executables/pexable/deliver/delivery/finder.py
+
2
−
5
View file @
2ed7a264
...
...
@@ -27,6 +27,7 @@ import re
from
typing
import
Iterator
,
List
import
pendulum
from
delivery
import
convert_datetime_to_mjd
from
pendulum.datetime
import
DateTime
from
.products
import
ArchiveProduct
,
ProductMetadata
,
RestoreProduct
,
SpooledProduct
...
...
@@ -136,7 +137,7 @@ class RestoreProductFinder(ProductFinder):
start_timestamp_match
=
re
.
match
(
r
"
^casa-(?P<timestamp>[0-9]+-[0-9]+).log$
"
,
casa_log_name
)
assert
start_timestamp_match
start_timestamp
=
pendulum
.
from_format
(
start_timestamp_match
.
group
(
"
timestamp
"
),
"
YYYYMMDD-HHmmss
"
)
start_mjd
=
dat
e_to_mjd
(
start_timestamp
)
start_mjd
=
convert_datetim
e_to_mjd
(
start_timestamp
)
return
ProductMetadata
(
project_metadata
[
"
telescope
"
],
project_metadata
[
"
project_code
"
],
"
restored_cms
"
,
None
,
None
,
str
(
start_mjd
)
)
...
...
@@ -147,7 +148,3 @@ class RestoreProductFinder(ProductFinder):
def
find_products
(
self
)
->
Iterator
[
SpooledProduct
]:
yield
RestoreProduct
(
self
.
dir
,
self
.
_metadata
)
def
date_to_mjd
(
timestamp
:
DateTime
)
->
float
:
return
0
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