Skip to content

Commit 59c001b

Browse files
authored
Merge pull request #149 from MBARIMike/main
Add lrauv_deployment_plots.py to create overall deployment plots
2 parents dc66bef + 8314b4e commit 59c001b

12 files changed

Lines changed: 1928 additions & 65 deletions

‎.vscode/launch.json‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,27 @@
467467
// Test --update_ssds_provenance with a short log_file
468468
//"args": ["-v", "1", "--log_file", "ahi/missionlogs/2025/20250128_20250131/20250131T051404/202501310514_202501310535.nc4", "--update_ssds_provenance"]
469469
// Test ahi mission that has Backseat Planktivore data with --update_ssds_provenance
470-
"args": ["-v", "1", "--log_file", "ahi/missionlogs/2025/20250414_20250418/20250415T040019/202504150400_202504152346.nc4", "--update_ssds_provenance"]
470+
//"args": ["-v", "1", "--log_file", "ahi/missionlogs/2025/20250414_20250418/20250415T040019/202504150400_202504152346.nc4", "--update_ssds_provenance"]
471+
// Make per log file .html files to test with lrauv_deployment_plots and --update_ssds_provenance
472+
"args": ["-v", "1", "--auv_name", "ahi", "--start", "20251022T000000", "--end", "20251024T000000", "--update_ssds_provenance", "--clobber"]
473+
},
474+
{
475+
"name": "lrauv_deployment_plots",
476+
"type": "debugpy",
477+
"request": "launch",
478+
"program": "${workspaceFolder}/src/data/lrauv_deployment_plots.py",
479+
"console": "integratedTerminal",
480+
// ahi planktivore deployment April 2025
481+
//"args": ["-v", "1", "--dlist", "ahi/missionlogs/2025/20250414_20250418.dlist"]
482+
// tethys CANON September 2012 (classic test case)
483+
//"args": ["-v", "1", "--dlist", "tethys/missionlogs/2012/20120908_20120920.dlist"]
484+
// ahi planktivore deployment April 2025 add --update_ssds_provenance
485+
//"args": ["-v", "1", "--dlist", "ahi/missionlogs/2025/20250414_20250418.dlist", "--update_ssds_provenance"]
486+
// Test time range of DeploymentPlots with ahi planktivore deployment April 2025
487+
//"args": ["-v", "1", "--auv_name", "ahi", "--start", "20251001", "--end", "20251231", "--update_ssds_provenance", "--force"]
488+
// Test web page building with a short deployment
489+
//"args": ["-v", "1", "--dlist", "ahi/missionlogs/2025/20251022_20251024.dlist", "--update_ssds_provenance"]
490+
"args": ["-v", "1", "--last_n_days", "10", "--update_ssds_provenance", "--force"]
471491
},
472492

473493
]

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies = [
1212
"cmocean>=4.0.3",
1313
"coards>=1.0.5",
1414
"contextily>=1.7.0",
15+
"dask>=2024.1.0",
1516
"datashader>=0.18.1",
1617
"defusedxml>=0.7.1",
1718
"gitpython>=3.1.44",
@@ -20,6 +21,7 @@ dependencies = [
2021
"ipympl>=0.9.7",
2122
"jupyter>=1.1.1",
2223
"jupyter-bokeh>=4.0.5",
24+
"lzstring>=1.0.4",
2325
"netcdf4>=1.7.2",
2426
"numpy>=2.2.6",
2527
"pandas>=2.2.0",

‎src/data/archive.py‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,58 @@ def copy_to_LRAUV(self, log_file: str, freq: str = FREQ) -> None: # noqa: C901,
294294
src_file.name,
295295
)
296296

297+
def copy_lrauv_deployment(self, deployment_dir: Path, plot_name_stem: str) -> None:
298+
"""Copy LRAUV deployment plots and HTML index to the LRAUV archive volume.
299+
300+
Mirrors *deployment_dir* under ``/Volumes/LRAUV``, creating the
301+
destination directory if needed. Copies:
302+
- all ``{plot_name_stem}_*.png`` deployment plot files
303+
- the ``{plot_name_stem}.html`` index file
304+
305+
Args:
306+
deployment_dir: Local directory that contains the generated files
307+
(e.g. ``BASE_LRAUV_PATH/vehicle/missionlogs/YYYY/dlist_dir/``).
308+
plot_name_stem: Stem used to name the plots and HTML file.
309+
"""
310+
try:
311+
rel = deployment_dir.relative_to(BASE_LRAUV_PATH)
312+
except ValueError:
313+
self.logger.warning(
314+
"deployment_dir %s is not under BASE_LRAUV_PATH %s; skipping archive",
315+
deployment_dir,
316+
BASE_LRAUV_PATH,
317+
)
318+
return
319+
dst_dir = Path(LRAUV_VOL) / rel
320+
try:
321+
dst_dir.stat()
322+
except FileNotFoundError:
323+
self.logger.warning("%s not found; is %s mounted?", dst_dir, LRAUV_VOL)
324+
return
325+
dst_dir.mkdir(parents=True, exist_ok=True)
326+
candidates = list(deployment_dir.glob(f"{plot_name_stem}_*.png"))
327+
candidates.append(deployment_dir / f"{plot_name_stem}.html")
328+
candidates.extend(deployment_dir.glob(f"{plot_name_stem}_*.html"))
329+
for src_file in candidates:
330+
if not src_file.exists():
331+
self.logger.debug("Source file not found, skipping: %s", src_file)
332+
continue
333+
dst_file = dst_dir / src_file.name
334+
if self.clobber:
335+
if dst_file.exists():
336+
self.logger.info("Removing %s", dst_file)
337+
dst_file.unlink()
338+
shutil.copyfile(src_file, dst_file)
339+
self.logger.info("copyfile %s %s done.", src_file.name, dst_dir)
340+
elif dst_file.exists():
341+
self.logger.info(
342+
"%-60s exists, but is not being archived because --clobber is not specified.",
343+
src_file.name,
344+
)
345+
else:
346+
shutil.copyfile(src_file, dst_file)
347+
self.logger.info("copyfile %s %s done.", src_file.name, dst_dir)
348+
297349
def process_command_line(self):
298350
"""Process command line arguments using shared parser infrastructure."""
299351
# Use shared parser with archive-specific additions

0 commit comments

Comments
 (0)