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
10 changes: 7 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
//"args": ["--auv_name", "dorado", "--mission", "2025.316.02", "-v", "1"],
//"args": ["-v", "1", "--log_file", "pontus/missionlogs/2025/20250604_20250616/20250608T020852/202506080209_202506081934.nc4"],
//"args": ["-v", "1", "--log_file", "ahi/missionlogs/2025/20250414_20250418/20250414T205440/202504142054_202504150400.nc4"],
"args": ["--auv_name", "dorado", "--mission", "2022.201.00", "-v", "1"],
//"args": ["--auv_name", "dorado", "--mission", "2022.201.00", "-v", "1"],
"args": ["--auv_name", "dorado", "--mission", "2006.338.11", "-v", "1"],
},
{
"name": "5.0 - archive.py",
Expand All @@ -232,7 +233,8 @@
//"args": ["-v", "1", "--auv_name", "dorado", "--mission", "2023.192.01", "--local"],
//"args": ["-v", "2", "--auv_name", "dorado", "--mission", "2016.270.00"],
//"args": ["-v", "1", "--auv_name", "dorado", "--mission", "2022.201.00"],
"args": ["-v", "1", "--log_file", "pontus/missionlogs/2024/20240715_20240725/20240723T023501/202407230235_202407232319.nc4"],
//"args": ["-v", "1", "--log_file", "pontus/missionlogs/2024/20240715_20240725/20240723T023501/202407230235_202407232319.nc4"],
"args": ["-v", "1", "--auv_name", "dorado", "--mission", "2006.338.11"],
},
{
"name": "7.0 - email.py",
Expand Down Expand Up @@ -344,7 +346,9 @@
// 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" ],
// File "/src/data/calibrate.py", line 698, in global_metadata f"{self.nudge_total_minutes:.1f} minutes nudged toward GPS fixes."
"args": ["-v", "1", "--mission", "2003.191.00", "--noinput", "--no_cleanup" ],
//"args": ["-v", "1", "--mission", "2003.191.00", "--noinput", "--no_cleanup" ],
// File "/src/data/resample.py", line 736, IndexError: index -1 is out of bounds for axis 0 with size 0
"args": ["-v", "1", "--mission", "2006.338.11", "--noinput", "--no_cleanup" ],

},
{
Expand Down
19 changes: 16 additions & 3 deletions src/data/create_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,14 @@ def _grid_dims(self) -> tuple:
# distnav = cumsum(sqrt(dxFix.^2 + dyFix.^2)); % in m
# dists = distnav / 1000; % in km

utm_zone = int(31 + (self.ds.cf["longitude"].mean() // 6))
try:
utm_zone = int(31 + (self.ds.cf["longitude"].mean() // 6))
except ValueError:
self.logger.warning(
"Cannot compute mean longitude for UTM zone calculation, "
"longitude data may be empty or contain NaNs",
)
return None, None, None
MAX_LONGITUDE_VALUES = 400
n_subsample = 200 if len(self.ds.cf["longitude"].to_numpy()) > MAX_LONGITUDE_VALUES else 1
lon_sub_intrp = np.interp(
Expand Down Expand Up @@ -1139,7 +1146,9 @@ def plot_2column(self) -> str: # noqa: C901, PLR0912, PLR0915
self._open_ds()

idist, iz, distnav = self._grid_dims()
scfac = max(idist) / max(iz) # noqa: F841
if idist is None or iz is None or distnav is None:
self.logger.warning("Skipping plot_2column due to missing gridding dimensions")
return None

fig, ax = plt.subplots(nrows=5, ncols=2, figsize=(18, 10))
plt.subplots_adjust(hspace=0.15, wspace=0.01, left=0.05, right=1.01, top=0.96, bottom=0.06)
Expand Down Expand Up @@ -1242,7 +1251,7 @@ def plot_2column(self) -> str: # noqa: C901, PLR0912, PLR0915
self.logger.info("Saved 2column plot to %s", output_file)
return str(output_file)

def plot_biolume(self) -> str:
def plot_biolume(self) -> str: # noqa: C901
"""Create bioluminescence plot showing raw signal and proxy variables"""
# Skip plotting in pytest environment - too many prerequisites for CI
if "pytest" in sys.modules:
Expand All @@ -1258,6 +1267,10 @@ def plot_biolume(self) -> str:
return None

idist, iz, distnav = self._grid_dims()
if idist is None or iz is None or distnav is None:
self.logger.warning("Skipping plot_biolume due to missing gridding dimensions")
return None

profile_bottoms = self._profile_bottoms(distnav)

# Create figure with subplots for biolume variables
Expand Down
11 changes: 11 additions & 0 deletions src/data/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def _build_global_metadata(self) -> None:
# Skip dynamic metadata during testing to ensure reproducible results
if "pytest" in sys.modules:
return {}
if self.resampled_nc.time.size == 0:
self.logger.warning(
"No time data available to build global metadata",
)
return {}

# Try to get actual host name, fall back to container name
actual_hostname = os.getenv("HOST_NAME", gethostname())
repo = git.Repo(search_parent_directories=True)
Expand Down Expand Up @@ -724,6 +730,11 @@ def _find_lat_lon_variables(self) -> tuple[str, str]:
return lat_var, lon_var

def add_profile(self, depth_threshold: float) -> None:
if len(self.resampled_nc["depth"]) == 0:
self.logger.warning(
"No depth data available to compute profile numbers",
)
return
# Find depth vertices value using scipy's find_peaks algorithm
options = {"prominence": 10, "width": 30}
peaks_pos, _ = signal.find_peaks(self.resampled_nc["depth"], **options)
Expand Down