From 23d5104669bbe1a67bd29d15b38053bd6243f34f Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Thu, 18 Dec 2025 21:03:59 -0800 Subject: [PATCH] Use .get() to get comment in case it's not there. --- .vscode/launch.json | 4 +++- src/data/resample.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fe7f859..b15d6af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -296,7 +296,7 @@ //"args": ["-v", "1", "--last_n_days", "30", "--start_year", "2022", "--end_year", "2022", "--resample", "--noinput"] //"args": ["-v", "1", "--last_n_days", "30", "--start_year", "2022", "--end_year", "2022", "--archive", "--noinput"] //"args": ["-v", "1", "--start_year", "2021", "--end_year", "2022", "--noinput"] - "args": ["-v", "1", "--mission", "2022.201.00", "--clobber", "--noinput", "--no_cleanup"] + //"args": ["-v", "1", "--mission", "2022.201.00", "--clobber", "--noinput", "--no_cleanup"] //"args": ["-v", "1", "--mission", "2009.084.00", "--clobber", "--noinput"] //"args": ["-v", "1", "--mission", "2022.243.00", "--calibrate", "--clobber", "--noinput"] //"args": ["-v", "1", "--start_year", "2004", "--end_year", "2004", "--start_yd", "168", "--use_portal", "--clobber", "--noinput"] @@ -341,6 +341,8 @@ //"args": ["-v", "1", "--mission", "2023.192.01", "--noinput", "--no_cleanup"], //"args": ["-v", "1", "--mission", "2010.151.04", "--noinput", "--no_cleanup", "--clobber"], //"args": ["-v", "1", "--mission", "2025.316.02", "--noinput", "--no_cleanup", "--add_seconds", "619315200"], + // File "/src/data/resample.py", line 587, in save_coordinates f"{self.ds[f'{pitch_corrected_instr}_depth'].attrs['comment']}" + "args": ["-v", "1", "--mission", "2003.164.02", "--noinput", "--no_cleanup" ], }, { diff --git a/src/data/resample.py b/src/data/resample.py index 3de0c4a..e3e3034 100755 --- a/src/data/resample.py +++ b/src/data/resample.py @@ -584,7 +584,7 @@ def save_coordinates( # noqa: PLR0913 self.resampled_nc["depth"].attrs["long_name"] = "Depth" self.resampled_nc["depth"].attrs["standard_name"] = "depth" self.resampled_nc["depth"].attrs["comment"] = ( - f"{self.ds[f'{pitch_corrected_instr}_depth'].attrs['comment']}" + f"{self.ds[f'{pitch_corrected_instr}_depth'].attrs.get('comment', '')}" f" mean sampled at {self.freq} intervals following" f" {self.mf_width} point median filter." )