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
25 changes: 16 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//"args": ["--auv_name", "i2map", "--mission", "2020.055.01", "--noinput", "--local", "-v", "2", "--clobber"]
//"args": ["--auv_name", "Dorado389", "--mission", "2020.245.00", "--noinput", "-v", "2", "--portal", "http://stoqs.mbari.org:8080/auvdata/v1", "--clobber"]
//"args": ["--auv_name", "Dorado389", "--mission", "2020.245.00", "--noinput", "-v"]
//"args": ["--auv_name", "Dorado389", "--mission", "2017.297.00", "--local", "-v", "2"]
"args": ["--auv_name", "dorado", "--mission", "2017.297.00", "-v", "2", "--vehicle_dir", "/Volumes/AUVCTD/missionlogs"]
//"args": ["--auv_name", "Dorado389", "--start", "20190701", "--end", "20191230", "-v", "2"]
//"args": ["--auv_name", "i2map", "--mission", "2021.062.01", "--noinput", "-v", "1"]
//"args": ["--auv_name", "dorado", "--mission", "2021.109.00", "--noinput", "-v"]
Expand All @@ -26,7 +26,7 @@
//"args": ["--auv_name", "dorado", "--mission", "2010.265.00", "--noinput", "-v"]
//"args": ["--auv_name", "dorado", "--mission", "2023.324.00", "--noinput", "-v", "--vehicle_dir", "/Volumes/AUVCTD/missionlogs"]
// Mission suffering from GPS Rollover bug. Add 1024 * 7 * 24 * 3600 = 619315200 seconds
"args": ["--auv_name", "dorado", "--mission", "2025.316.02", "--noinput", "-v", "--vehicle_dir", "/Volumes/AUVCTD/missionlogs", "--add_seconds", "619315200" ]
//"args": ["--auv_name", "dorado", "--mission", "2025.316.02", "--noinput", "-v", "--vehicle_dir", "/Volumes/AUVCTD/missionlogs", "--add_seconds", "619315200" ]
},
{
"name": "1.1 - lopcToNetCDF",
Expand Down Expand Up @@ -84,7 +84,7 @@
//"args": ["--auv_name", "dorado", "--mission", "2010.181.00", "--plot", "first1000", "-v", "1"]
// OverflowError: time values outside range of 64 bit signed integers in calibrate.py:413
//"args": ["--auv_name", "dorado", "--mission", "2017.304.00", "--plot", "first1000", "-v", "1"]
//"args": ["--auv_name", "dorado", "--mission", "2017.297.00", "-v", "1"]
"args": ["--auv_name", "dorado", "--mission", "2017.297.00", "-v", "1"]
//"args": ["--auv_name", "i2map", "--mission", "2022.094.01", "-v", "2"]
//"args": ["--auv_name", "i2map", "--mission", "2018.025.00", "-v", "2"]
//"args": ["--auv_name", "dorado", "--mission", "2017.248.01", "-v", "1"]
Expand All @@ -102,7 +102,7 @@
//"args": ["--auv_name", "dorado", "--mission", "2018.079.00", "-v", "1"]
//"args": ["--auv_name", "i2map", "--mission", "2018.348.01", "-v", "2"]
//"args": ["--auv_name", "dorado", "--mission", "2023.324.00", "-v", "1", "--plot", "first10000"]
"args": ["--auv_name", "dorado", "--mission", "2022.201.00", "-v", "1", "--plot", "first10000"]
//"args": ["--auv_name", "dorado", "--mission", "2022.201.00", "-v", "1", "--plot", "first10000"]
},
{
"name": "2.1 - Test hs2_proc.py (its unit tests)",
Expand All @@ -120,7 +120,8 @@
"console": "integratedTerminal",
"justMyCode": false,
//"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250909_20250915/20250914T080941/202509140809_202509150109.nc4"]
"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4"]
"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4", "--plot"]
//"args": ["-v", "1", "--log_file", "tethys/missionlogs/2012/20120908_20120920/20120909T010636/201209090106_201209091521.nc4", "--plot"]
},
{
"name": "3.0 - align.py",
Expand Down Expand Up @@ -300,7 +301,7 @@
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--start_year", "2007", "--end_year", "2007", "--create_products", "--num_cores", "1", "--archive_only_products"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--start_year", "2007", "--end_year", "2007", "--start_yd", "171", "--end_yd", "171", "--num_cores", "1", "--create_products", "--archive_only_products"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2008.261.01", "--create_products", "--archive", "--archive_only_products"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--start_year", "2011", "--end_year", "2011", "--start_yd", "158", "--end_yd", "164", "--num_cores", "1"]
"args": ["-v", "1", "--noinput", "--no_cleanup", "--start_year", "2011", "--end_year", "2011", "--start_yd", "158", "--end_yd", "164", "--num_cores", "1"]
//"args": ["-v", "1", "--noinput", "--start_year", "2016", "--end_year", "2016", "--start_yd", "270", "--end_yd", "270", "--num_cores", "1", "--create_products", "--archive", "--archive_only_products"]
//"args": ["-v", "1", "--noinput", "--num_cores", "1", "--mission", "2023.285.01"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2018.079.00"]
Expand All @@ -314,7 +315,7 @@
//"args": ["-v", "2", "--mission", "2004.029.03", "--noinput", "--no_cleanup"],
//"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"],
//"args": ["-v", "1", "--mission", "2025.316.02", "--noinput", "--no_cleanup", "--add_seconds", "619315200"],

},
{
Expand All @@ -335,8 +336,14 @@
//"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", "--clobber"]
//"args": ["-v", "1", "--auv_name", "tethys", "--start", "20120901", "--end", "20121101", "--noinput"]
//"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250916_20250922/20250916T230652/202509162306_202509180305.nc4", "--no_cleanup", "--clobber"]
// Has different universals time coodinates for longitude/latitude and depth
"args": ["-v", "1", "--auv_name", "tethys", "--start", "20120901T000000", "--end", "20121101T000000", "--noinput", "--no_cleanup"]
// Conflicting sizes for nudged_time and data
//"args": ["-v", "1", "--log_file", "tethys/missionlogs/2012/20120908_20120920/20120917T025522/201209170255_201209171110.nc4", "--no_cleanup"
//"args": ["-v", "1", "--auv_name", "brizo", "--start", "20250915T000000", "--end", "20250917T000000", "--noinput", "--num_cores", "1", "--no_cleanup"]
// No nudged latitude and longitude variables
//"args": ["-v", "1", "--log_file", "brizo/missionlogs/2025/20250909_20250915/20250915T015535/202509150155_202509151602.nc4", "--no_cleanup"]
},

]
Expand Down
29 changes: 21 additions & 8 deletions src/data/AUV.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def nudge_positions( # noqa: C901, PLR0912, PLR0913, PLR0915
auv_name: str = "",
mission: str = "",
max_sec_diff_at_end: int = 10,
log_file: str = "",
create_plots: bool = False, # noqa: FBT001, FBT002
) -> tuple[xr.DataArray, xr.DataArray, int, float]:
"""
Expand Down Expand Up @@ -115,6 +116,7 @@ def nudge_positions( # noqa: C901, PLR0912, PLR0913, PLR0915
MIN_SEGMENT_LENGTH = 10
seg_count = 0
seg_minsum = 0
error_message = ""
for i in range(len(lat_fix) - 1):
# Segment of dead reckoned (under water) positions, each surrounded by GPS fixes
segi = np.where(
Expand Down Expand Up @@ -169,16 +171,23 @@ def nudge_positions( # noqa: C901, PLR0912, PLR0913, PLR0915
end_lon_diff,
end_lat_diff,
)
logger.info(
"Fix this error by calling _range_qc_combined_nc() in "
"_navigation_process() and/or _gps_process() for %s %s",
auv_name,
mission,
)
if log_file:
logger.info(
"Fix this error by calling _range_qc_combined_nc() in "
"_navigation_process() and/or _gps_process() for %s",
log_file,
)
logger.info("Run to get a plot: combine.py -v 1 --plot --log_file %s", log_file)
elif auv_name and mission:
logger.info(
"Fix this error by calling _range_qc_combined_nc() in "
"_navigation_process() and/or _gps_process() for %s %s",
auv_name,
mission,
)
error_message = (
f"abs(end_lon_diff) ({end_lon_diff}) > 1 or abs(end_lat_diff) ({end_lat_diff}) > 1"
)
raise ValueError(error_message)
if abs(end_sec_diff) > max_sec_diff_at_end:
logger.warning(
"abs(end_sec_diff) (%s) > max_sec_diff_at_end (%s)",
Expand Down Expand Up @@ -276,12 +285,16 @@ def nudge_positions( # noqa: C901, PLR0912, PLR0913, PLR0915
name="latitude",
)

# Optional plotting code
# Optional plotting code - raise error after opportunity to plot
if create_plots:
_create_nudge_plots(
lat, lon, lat_fix, lon_fix, lat_nudged, lon_nudged, auv_name, mission, logger
)

if error_message:
logger.error("Nudge positions error: %s", error_message)
raise ValueError(error_message)

return lon_nudged, lat_nudged, segment_count, segment_minsum


Expand Down
Loading