Skip to content

Commit cbe307f

Browse files
authored
Merge pull request #195 from MBARIMike/main
Add more detail to the log message for rejected time values.
2 parents 956000e + f716054 commit cbe307f

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎.vscode/launch.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@
487487
// Test having a better y-max that puts data instead of white space at the bottom
488488
//"args": ["-v", "1", "--log_file", "ahi/missionlogs/2026/20260406_20260412/20260410T010521/202604100105_202604100800.nc4"]
489489
// Test processing only new data - as we would do in production with a cron job
490-
"args": ["-v", "1", "--last_n_days", "14"]
490+
//"args": ["-v", "1", "--last_n_days", "14"]
491+
// Test improving out of range log message for Planktivore deployment in April 2026 - Ahi 47 CFE
492+
"args": ["-v", "1", "--log_file", "ahi/missionlogs/2026/20260406_20260412/20260410T080016/202604100800_202604111036.nc4", "--clobber"]
491493
},
492494
{
493495
"name": "process_lrauv_sbd",

‎src/data/nc42netcdfs.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,14 +806,35 @@ def _filter_valid_time_indices(self, time_data) -> list[int]:
806806

807807
if outliers_found > 0:
808808
non_finite = np.sum(~is_finite)
809-
out_of_range = np.sum(~is_in_range & is_finite)
809+
out_of_range_mask = ~is_in_range & is_finite
810+
out_of_range = np.sum(out_of_range_mask)
810811

812+
win_start = datetime.fromtimestamp(MIN_UNIX_TIME, tz=UTC).strftime("%Y-%m-%dT%H:%MZ")
813+
win_end = datetime.fromtimestamp(MAX_UNIX_TIME, tz=UTC).strftime("%Y-%m-%dT%H:%MZ")
811814
self.logger.info(
812815
"Pre-filtered %d invalid time values: %d non-finite, %d out-of-range",
813816
outliers_found,
814817
non_finite,
815818
out_of_range,
816819
)
820+
self.logger.info(" Valid window : [%s ──── %s]", win_start, win_end)
821+
if out_of_range:
822+
bad = time_array[out_of_range_mask]
823+
bad_start = datetime.fromtimestamp(bad.min(), tz=UTC).strftime("%Y-%m-%dT%H:%MZ")
824+
bad_end = datetime.fromtimestamp(bad.max(), tz=UTC).strftime("%Y-%m-%dT%H:%MZ")
825+
before = np.sum(bad < MIN_UNIX_TIME)
826+
after = np.sum(bad > MAX_UNIX_TIME)
827+
parts = []
828+
if before:
829+
parts.append(f"{before} before")
830+
if after:
831+
parts.append(f"{after} after")
832+
self.logger.info(
833+
" Rejected : [%s ──── %s] (%s window)",
834+
bad_start,
835+
bad_end,
836+
", ".join(parts),
837+
)
817838

818839
return valid_indices
819840

0 commit comments

Comments
 (0)