From 2ee9fb26aaa5e575cecb85050818e880c22d5252 Mon Sep 17 00:00:00 2001
From: nickb <nickb@ssec.wisc.edu>
Date: Fri, 29 Jan 2021 18:34:54 +0000
Subject: [PATCH] fix the two-files-per-minute issue. follows Eric's fix to the
 example make_GLM_grids.py script:

https://github.com/deeplycloudy/glmtools/commit/caa7d5af4a27060c56258c9bf73fa6a13891b0e1
---
 gridded_glm/libexec/_minute_gridder.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gridded_glm/libexec/_minute_gridder.py b/gridded_glm/libexec/_minute_gridder.py
index 9430159..4b47090 100644
--- a/gridded_glm/libexec/_minute_gridder.py
+++ b/gridded_glm/libexec/_minute_gridder.py
@@ -5,7 +5,7 @@ parse_desc = """Grid the past X minutes of GLM flash data, given a single input
 """
 
 import numpy as np
-from datetime import datetime
+from datetime import datetime, timedelta
 import os
 import sys
 import tempfile
@@ -111,7 +111,16 @@ def get_start_end(filenames, start_time=None, end_time=None):
     filename_starts = [info[3] for info in filename_infos]
     filename_ends = [info[4] for info in filename_infos]
     start_time = min(filename_starts)
-    end_time = max(filename_ends)
+
+    # Used to use max(filename_ends), but on 27 Oct 2020, the filename
+    # ends started to report the time of the last event in the file,
+    # causing a slight leakage (usually less than a second) into the
+    # next minute. This caused two minutes of grids to be produced for every
+    # three twenty second files passed to this script.
+    # Instead, we now assume every LCFA file is 20 s long, beginning with
+    # the start time. No doubt in the future we will see filenames that no
+    # longer start on an even minute boundary.
+    end_time = max(filename_starts) + timedelta(0, 20)
 
     if start_time is None or end_time is None:
         raise ValueError("Could not determine start/end time")
-- 
GitLab