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
3 changes: 2 additions & 1 deletion src/data/lrauv_deployment_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,11 @@ def _write_per_png_html( # noqa: C901, PLR0913
dap_links = []
for nc_url in nc_urls:
nc4_url = re.sub(rf"_{FREQ}\.nc$", ".nc4", nc_url)
nc_label = "Interpolated .nc" if "/realtime/" in nc_url else "Resampled .nc"
dap_links.append(
f'<a href="{nc4_url}.html" {nt}>Original .nc4</a>'
f"<br>"
f'<a href="{nc_url}.html" {nt}>Resampled .nc</a>'
f'<a href="{nc_url}.html" {nt}>{nc_label}</a>'
)

stoqs_label = "STOQS"
Expand Down
15 changes: 14 additions & 1 deletion src/data/process_lrauv_sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

import xarray as xr
from common_args import ALL_LRAUV_NAMES
from nc42netcdfs import BASE_LRAUV_PATH
from resample import LRAUV_OPENDAP_BASE
from sbd2netcdf import FREQ, SbdExtract

_LOG_LEVELS = (logging.WARN, logging.INFO, logging.DEBUG)
Expand All @@ -48,6 +50,17 @@
logger.addHandler(_handler)


def _to_opendap_url(path: Path, vehicle_dir: str) -> str:
"""Convert a local shore_1S.nc path to its OPeNDAP URL."""
for local_base in (Path(vehicle_dir), BASE_LRAUV_PATH):
try:
rel = path.relative_to(local_base)
return LRAUV_OPENDAP_BASE.rstrip("/") + "/" + str(rel)
except ValueError:
continue
return str(path)


def _parse_dt(s: str) -> datetime:
for fmt in ("%Y%m%dT%H%M%S", "%Y%m%d"):
try:
Expand Down Expand Up @@ -288,7 +301,7 @@ def _make_products(
month_year = pd.to_datetime(ds.cf["time"].to_numpy()[0]).strftime("%B %Y")
html_title = f"Interpolated realtime SBD data for {args.auv_name} in {month_year}"

nc_file_strs = [str(p) for p in month_files]
nc_file_strs = [_to_opendap_url(p, args.vehicle_dir) for p in month_files]
html_paths = []
for png_path in png_paths:
html_path = png_path.with_suffix(".html")
Expand Down
Loading