Skip to content
Snippets Groups Projects
Commit 28239b72 authored by tomrink's avatar tomrink
Browse files

minor

parent f2445e82
No related branches found
No related tags found
No related merge requests found
......@@ -32,17 +32,29 @@ def moon_phase(dt_obj_s, phs_deg=50):
return (phase.degrees > phs_deg) & (phase.degrees < 360-phs_deg)
def make_times(dt_str, num_days):
# dt_str_0: start datetime string in format YYYY-MM-DD_HH:MM
# num_steps with increment of days, hours, minutes or seconds
# return num_steps+1 lists of datetime strings and timestamps for the times eries
def make_times(dt_str_0, num_steps, days=None, hours=None, minutes=None, seconds=None):
if days is not None:
inc = 86400*days
elif hours is not None:
inc = 3600*hours
elif minutes is not None:
inc = 60*minutes
else:
inc = seconds
dt_obj_s = []
ts_s = []
dto_0 = datetime.datetime.strptime(dt_str, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc)
dto_0 = datetime.datetime.strptime(dt_str_0, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc)
ts_0 = dto_0.timestamp()
dt_obj_s.append(dto_0)
ts_s.append(ts_0)
dto_last = dto_0
for k in range(num_days):
dt_obj = dto_last + datetime.timedelta(days=1)
for k in range(num_steps):
dt_obj = dto_last + datetime.timedelta(seconds=inc)
dt_obj_s.append(dt_obj)
ts_s.append(dt_obj.timestamp())
dto_last = dt_obj
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment