-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version of module for computing times in different units/time…
…zones
- Loading branch information
1 parent
579159a
commit b4e5bc2
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Routines for Deriving Time-related Data | ||
""" | ||
|
||
from datetime import datetime, timedelta | ||
import numpy as np | ||
import pytz | ||
|
||
def compute_arrival_times(parameters: dict, time0: float = 0.) -> list: | ||
""" | ||
Computes arrival times on a specified timescale. | ||
Parameters | ||
---------- | ||
parameters : dict | ||
A dictionary that contains all burst-parameter data. | ||
time0 : float, optional | ||
A reference time against which the per-parameter arrival times are measured, | ||
assumed to be in units of Unix time (i.e., seconds). | ||
Returns | ||
------- | ||
""" | ||
|
||
|
||
|
||
# extract data. | ||
arrival_times = parameters["arrival_time"] | ||
arrival_times_converted = [] | ||
dm = parameters["dm"][0] | ||
|
||
# construct datetime object. | ||
for current_timestamp in arrival_times: | ||
dt_arrival = timedelta(seconds=current_timestamp) | ||
dt_arrival += datetime.fromtimestamp(time0, tz=pytz.utc) | ||
arrival_times_converted += [dt_arrival.strftime("%Y-%m-%d %H:%M:%S.%f")] | ||
|
||
return arrival_times_converted |