From 28239b72c1b1ec144929a6883d3bc90407530b81 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Sun, 8 Aug 2021 22:13:20 -0500
Subject: [PATCH] minor

---
 modules/icing/moon_phase.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/modules/icing/moon_phase.py b/modules/icing/moon_phase.py
index 7d1e2c99..d5e2c069 100644
--- a/modules/icing/moon_phase.py
+++ b/modules/icing/moon_phase.py
@@ -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
-- 
GitLab