Skip to content

Commit

Permalink
Get start/stop times from coarse time (GPS seconds) instead of embedd…
Browse files Browse the repository at this point in the history
…ed time column.
  • Loading branch information
winstonolson committed May 24, 2022
1 parent 86eec00 commit 3edab3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
*egg-info*
/tmp
.DS_Store
21 changes: 16 additions & 5 deletions get_bad_start_stop_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

from argparse import RawTextHelpFormatter

from ait.core import dmc


def get_utc_time_from_gps(gps_time):
# Convert gps_time in seconds to a timestamp in utc
d = dmc.GPS_Epoch + datetime.timedelta(seconds=gps_time)
offset = dmc.LeapSeconds.get_GPS_offset_for_date(d)
utc_time = d - datetime.timedelta(seconds=offset)
return utc_time


def main():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -35,17 +45,18 @@ def main():

index = None
for i, header in enumerate(headers):
if header == "Timestamp : Embedded GMT":
# LADP06MD2378W is the header for the coarse time (in GPS seconds)
if header == "LADP06MD2378W":
index = i
break

if index is None:
raise RuntimeError("Unable to find embedded GMT column in data")
raise RuntimeError("Unable to find coarse time column (LADP06MD2378W) in data")

timestamps = [datetime.datetime.strptime(row[index], "%Y:%j:%H:%M:%S") for row in rows]
gps_times = [row[index] for row in rows]

start_time = min(timestamps)
stop_time = max(timestamps)
start_time = get_utc_time_from_gps(min(gps_times))
stop_time = get_utc_time_from_gps(max(gps_times))

output = {
"start_time": start_time.strftime("%Y-%m-%dT%H:%M:%S"),
Expand Down

0 comments on commit 3edab3c

Please sign in to comment.