Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@
// No GPS data for a log_file that has an ESP Sample
//"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250920T070029/202509200700_202509201900.nc4", "--no_cleanup"]
// Has nighttime data for proxys to be computed
"args": ["-v", "1", "--log_file", "pontus/missionlogs/2024/20240725_20240729/20240729T023020/202407290230_202407291556.nc4", "--no_cleanup"]
//"args": ["-v", "1", "--log_file", "pontus/missionlogs/2024/20240725_20240729/20240729T023020/202407290230_202407291556.nc4", "--no_cleanup"]
// Testing for adding crontab entries for process_lrauv
"args": ["-v", "1", "--last_n_days", "30", "--no_cleanup"]
},

]
Expand Down
43 changes: 41 additions & 2 deletions src/data/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class data are: download_process and calibrate, while for LRAUV class data
import subprocess
import sys
import time
from datetime import UTC, datetime
from datetime import UTC, datetime, timedelta
from getpass import getuser
from pathlib import Path
from socket import gethostname
Expand Down Expand Up @@ -1068,8 +1068,47 @@ def process_log_files(self) -> None:
self.process_log_file(log_file)
except (InvalidCalFile, InvalidCombinedFile) as e:
self.logger.warning("%s", e)
elif self.config.get("last_n_days"):
# Process log files from the last N days
end_dt = datetime.now(tz=UTC)
start_dt = end_dt - timedelta(days=self.config["last_n_days"])

# Format datetimes as YYYYMMDDTHHMMSS
start_str = start_dt.strftime("%Y%m%dT%H%M%S")
end_str = end_dt.strftime("%Y%m%dT%H%M%S")

self.logger.info(
"Processing log files from the last %d days (%s to %s)",
self.config["last_n_days"],
start_str,
end_str,
)

log_files = self.log_file_list(start_str, end_str, self.config.get("auv_name"))
if not log_files:
self.logger.warning(
"No log files found in the last %d days",
self.config["last_n_days"],
)
return

self.logger.info(
"Processing %d log files from the last %d days",
len(log_files),
self.config["last_n_days"],
)
for log_file in log_files:
# Extract AUV name from path
self.auv_name = log_file.split("/")[0].lower()
self.logger.info("Processing log file: %s", log_file)
try:
self.process_log_file(log_file)
except (InvalidCalFile, InvalidCombinedFile) as e:
self.logger.warning("%s", e)
else:
self.logger.error("Must provide either --log_file or both --start and --end arguments")
self.logger.error(
"Must provide either --log_file, both --start and --end, or --last_n_days arguments"
)
return

def process_command_line(self):
Expand Down