diff --git a/.vscode/launch.json b/.vscode/launch.json index 64c6b5d0..48d7a853 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -334,7 +334,8 @@ //"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250909_20250915/20250914T080941/202509140809_202509150109.nc4"] //"args": ["-v", "2", "--log_file", "brizo/missionlogs/2025/20250909_20250915/20250914T080941/202509140809_202509150109.nc4", "--clobber"] //"args": ["-v", "2", "--log_file", "brizo/missionlogs/2025/20250909_20250915/20250914T080941/202509140809_202509150109.nc4", "--clobber", "--no_cleanup"] - "args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4", "--no_cleanup"] + //"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4", "--no_cleanup"] + "args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4", "--no_cleanup", "--clobber"] //"args": ["-v", "1", "--auv_name", "tethys", "--start", "20120901", "--end", "20121101", "--noinput"] }, diff --git a/src/data/AUV.py b/src/data/AUV.py index 8dd913e1..cffa6fe8 100755 --- a/src/data/AUV.py +++ b/src/data/AUV.py @@ -256,7 +256,7 @@ def nudge_positions( # noqa: C901, PLR0912, PLR0913, PLR0915 seg_min = float(lat.cf["T"].data[segi][-1] - lat.cf["T"].data[segi][0]) / 1.0e9 / 60 logger.info( - f"{seg_count + 1:4d}: {'-':>12} {'-':>12} {'-':>12} {len(segi):-9d} {seg_min:9.2f} {'-':>14} {'-':>14}", # noqa: E501, G004 + f"{seg_count + 1:5d}: {'-':>12} {'-':>12} {'-':>12} {len(segi):-9d} {seg_min:9.2f} {'-':>14} {'-':>14}", # noqa: E501, G004 ) segment_count = seg_count segment_minsum = seg_minsum diff --git a/src/data/archive.py b/src/data/archive.py index 2352d5bf..0593923a 100755 --- a/src/data/archive.py +++ b/src/data/archive.py @@ -172,7 +172,7 @@ def copy_to_AUVTCD(self, nc_file_base: Path, freq: str = FREQ) -> None: # noqa: def copy_to_M3(self, resampled_nc_file: str) -> None: pass - def copy_to_LRAUV(self, log_file: str, freq: str = FREQ) -> None: + def copy_to_LRAUV(self, log_file: str, freq: str = FREQ) -> None: # noqa: C901, PLR0912 "Copy the intermediate and resampled netCDF file(s) to the archive LRAUV location" src_dir = Path(BASE_LRAUV_PATH, Path(log_file).parent) dst_dir = Path(LRAUV_VOL, Path(log_file).parent) @@ -196,7 +196,7 @@ def copy_to_LRAUV(self, log_file: str, freq: str = FREQ) -> None: "%-75s exists, but is not being archived because --clobber is not specified.", src_file.name, ) - for ftype in (f"{freq}.nc", "cal.nc", "align.nc"): + for ftype in (f"{freq}.nc", "combined.nc", "align.nc"): src_file = Path(src_dir, f"{Path(log_file).stem}_{ftype}") dst_file = Path(dst_dir, src_file.name) if self.args.clobber: @@ -211,6 +211,19 @@ def copy_to_LRAUV(self, log_file: str, freq: str = FREQ) -> None: "%-36s exists, but is not being archived because --clobber is not specified.", # noqa: E501 src_file.name, ) + # Copy the processing.log file last so that we get everything + src_file = Path(src_dir, f"{Path(log_file).stem}_{LOG_NAME}") + dst_file = Path(dst_dir, src_file.name) + if src_file.exists(): + if self.args.clobber: + self.logger.info("copyfile %s %s", src_file, dst_dir) + shutil.copyfile(src_file, dst_file) + self.logger.info("copyfile %s %s done.", src_file, dst_dir) + else: + self.logger.info( + "%26s exists, but is not being archived because --clobber is not specified.", # noqa: E501 + src_file.name, + ) def process_command_line(self): parser = argparse.ArgumentParser( diff --git a/src/data/process.py b/src/data/process.py index cc0a190f..949b366f 100755 --- a/src/data/process.py +++ b/src/data/process.py @@ -785,7 +785,7 @@ def process_log_file(self, log_file: str) -> None: netcdfs_dir = Path(BASE_LRAUV_PATH, Path(log_file).parent) Path(netcdfs_dir).mkdir(parents=True, exist_ok=True) self.log_handler = logging.FileHandler( - Path(BASE_LRAUV_PATH, f"{log_file}_extract.log"), mode="w+" + Path(netcdfs_dir, f"{Path(log_file).stem}_processing.log"), mode="w+" ) self.log_handler.setLevel(self._log_levels[self.args.verbose]) self.log_handler.setFormatter(AUV_NetCDF._formatter) diff --git a/src/data/resample.py b/src/data/resample.py index 53bbd39c..bf1b9623 100755 --- a/src/data/resample.py +++ b/src/data/resample.py @@ -78,6 +78,17 @@ def _build_global_metadata(self) -> None: ) gitcommit = "" iso_now = datetime.now(tz=UTC).isoformat().split(".")[0] + "Z" + + # Ensure that only the latitude and longitude variables have + # standard_name attributes equal to "latitude" and "longitude" so that + # the .cf[] accessor works correctly + for var in self.resampled_nc.data_vars: + if self.resampled_nc[var].attrs.get("standard_name") in ["latitude", "longitude"]: + if var in {"latitude", "longitude"}: + continue + self.logger.info("Removing standard_name attribute from variable %s", var) + del self.resampled_nc[var].attrs["standard_name"] + # Common dynamic attributes for all auv platforms self.metadata["time_coverage_start"] = str(min(self.resampled_nc.time.values)) self.metadata["time_coverage_end"] = str(max(self.resampled_nc.time.values)) @@ -1050,7 +1061,7 @@ def resample_variable( # noqa: PLR0913 .resample(freq.lower()) .mean() ) - self.df_r[variable].loc[instr_data.index] = instr_data + self.df_r.loc[instr_data.index, variable] = instr_data else: self.df_r[variable] = ( self.df_o[f"{variable}_mf"]