diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index 683faf8..b8c0d9c 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -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'Original .nc4' f"
" - f'Resampled .nc' + f'{nc_label}' ) stoqs_label = "STOQS" diff --git a/src/data/process_lrauv_sbd.py b/src/data/process_lrauv_sbd.py index 152fe78..dbe2b42 100755 --- a/src/data/process_lrauv_sbd.py +++ b/src/data/process_lrauv_sbd.py @@ -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) @@ -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: @@ -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")