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
12 changes: 6 additions & 6 deletions src/data/lrauv_deployment_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ def _update_index_html(
content = index_path.read_text()
all_hrefs = set(re.findall(r'href="([^"#][^"]*\.html)"', content))
group_names = dict(re.findall(r'<h2 id="([^"]+)">([^<]+)</h2>', content))
# Drop hrefs whose filename has a prefix before the group name (old auv_name_ style).
all_hrefs = {
h for h in all_hrefs if "/" not in h or Path(h).name.startswith(h.split("/")[0])
}
# clobber=True drops only this deployment's existing entries so they are rebuilt;
# other deployments' entries are always preserved.
known_hrefs = (
Expand Down Expand Up @@ -867,13 +871,10 @@ def _provenance_link_html(self, html_path: Path, nc_files: list[str], nt: str) -
def _other_plots_line(
self,
nt: str,
sibling_html_paths: list[Path] | None,
other_png_paths: list[str] | None,
) -> str:
"""Return an HTML paragraph linking to sibling deployment plots, or empty string."""
if sibling_html_paths:
links = [f'<a href="{p.name}" {nt}>{p.stem}.png</a>' for p in sibling_html_paths]
elif other_png_paths:
if other_png_paths:
links = [
f'<a href="{Path(p).with_suffix(".html").name}" {nt}>{Path(p).name}</a>'
for p in other_png_paths
Expand All @@ -897,7 +898,6 @@ def _write_per_png_html( # noqa: C901, PLR0913
png_file_path: Path | None = None,
other_png_paths: list[str] | None = None,
nc_durations: dict[str, int] | None = None,
sibling_html_paths: list[Path] | None = None,
) -> None:
"""Write a plain HTML page for one deployment PNG.

Expand Down Expand Up @@ -975,7 +975,7 @@ def _write_per_png_html( # noqa: C901, PLR0913
" </table>\n"
)

other_plots_line = self._other_plots_line(nt, sibling_html_paths, other_png_paths)
other_plots_line = self._other_plots_line(nt, other_png_paths)

stoqs_line = ""
if stoqs_url:
Expand Down
12 changes: 5 additions & 7 deletions src/data/process_lrauv_sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ def _make_products(
output_dir = out_paths[0].parent.parent # YYYYMM directory
ds, month_files = _concat_month_files(output_dir)

monthly_png = output_dir / f"{args.auv_name}_{output_dir.name}_sbd_{FREQ}_2column_cmocean.png"
monthly_png = output_dir / f"{output_dir.name}_sbd_{FREQ}_2column_cmocean.png"
if monthly_png.exists() and not args.clobber:
newest_nc = max(p.stat().st_mtime for p in month_files)
if newest_nc <= monthly_png.stat().st_mtime:
logger.info("Monthly plots up to date for %s — skipping", output_dir.name)
return

plot_stem = f"{args.auv_name}_{output_dir.name}_sbd"
plot_stem = f"{output_dir.name}_sbd"
cp = CreateProducts(
auv_name=args.auv_name,
mission=mission,
Expand Down Expand Up @@ -309,10 +309,7 @@ def _make_products(
nc_durations[url] = int(
(times[-1] - times[0]).astype("timedelta64[m]").astype(int)
)
html_paths = [
png_path.with_name(f"{png_path.stem.removeprefix(f'{args.auv_name}_')}.html")
for png_path in png_paths
]
html_paths = [p.with_suffix(".html") for p in png_paths]
for png_path, html_path in zip(png_paths, html_paths, strict=True):
dp._write_per_png_html(
html_path=html_path,
Expand All @@ -323,14 +320,15 @@ def _make_products(
nc_files=nc_file_strs,
auv_name=args.auv_name,
png_file_path=png_path,
sibling_html_paths=[p for p in html_paths if p != html_path],
other_png_paths=[str(p) for p in png_paths if p != png_path],
nc_durations=nc_durations,
)

dp._update_index_html(
output_dir,
html_paths,
deployment_name=f"{args.auv_name} {output_dir.name}",
clobber=True,
)


Expand Down
Loading