Skip to content

Commit

Permalink
Merge pull request #1446 from dwcaress/caress-tmp
Browse files Browse the repository at this point in the history
Fix support for formats MBF_SBSIOSWB and MBF_EM710RAW
  • Loading branch information
dwcaress authored Mar 22, 2024
2 parents 317037f + d79c403 commit b0fe03b
Show file tree
Hide file tree
Showing 11 changed files with 709 additions and 682 deletions.
836 changes: 429 additions & 407 deletions ChangeLog.html

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ or beta, are equally accessible as tarballs through the Github interface.
### MB-System Version 5.8 Releases and Release Notes:
---

- Version 5.8.1beta09 March 22, 2024
- Version 5.8.1beta08 March 10, 2024
- Version 5.8.1beta07 February 24, 2024
- Version 5.8.1beta04 February 16, 2024
Expand All @@ -33,6 +34,27 @@ or beta, are equally accessible as tarballs through the Github interface.

---

#### 5.8.1beta09 (March 22, 2024)

Format 16 (MBF_SBSIOSWB): Fixed bug that became evident when processing old Scripps
SeaBeam Classic data in format 16 on a MacOs Sonoma machine. This turned out to be
a poorly formed preprocessor macro for rounding floating point values in code dating
from 1992.

Formats 58 (MBF_EM710RAW) and 59 (MBF_EM710MBA): Fixed bug in which some bathymetry
edits were applied to the wrong pings. Third generation Kongsberg multibeams produce
two cross profiles with each ping cycle, but represent these as two separate pings
with the same ping time. MB-System distinguishes between pings using the timestamps
rather than ping numbers (because not all sonars produce ping numbers), so pings
with the same timestamp confuse the beam flag handling code. The solution is to add
a small amount of time to the timestamp of the second ping in each pair. The bug was
that the amount of time added by mbpreprocess was 33 microseconds, but the datagrams
in Kongsberg *.all files specify timestamps only to the millisecond level, and so
the added time was not large enough to be recorded differently in the output files.

Mbgrid: Improved output to shell so that it shows the min max values from each
contributing input file whether verbose is specified or not.

#### 5.8.1beta08 (March 10, 2024)

Mbm_grdplot: Added colortable 10, which runs from blue to red and can be used for
Expand Down
8 changes: 4 additions & 4 deletions src/mbaux/mb_truecont.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ int mb_tcontour(int verbose, struct swath *data, int *error) {

else {
const double ratio = data->level_list[i] / data->tick_int;
if (fabs(ROUND(ratio) - ratio) < 0.005 * data->contour_int)
if (fabs(round(ratio) - ratio) < 0.005 * data->contour_int)
data->tick_list[i] = 1;
else
data->tick_list[i] = 0;
Expand All @@ -988,7 +988,7 @@ int mb_tcontour(int verbose, struct swath *data, int *error) {
data->label_list[i] = 0;
else {
const double ratio = data->level_list[i] / data->label_int;
if (fabs(ROUND(ratio) - ratio) < 0.005 * data->contour_int)
if (fabs(round(ratio) - ratio) < 0.005 * data->contour_int)
data->label_list[i] = 1;
else
data->label_list[i] = 0;
Expand Down Expand Up @@ -1529,7 +1529,7 @@ int mb_ocontour(int verbose, struct swath *data, int *error) {
data->tick_list[i] = 0;
else {
const double ratio = data->level_list[i] / data->tick_int;
if (fabs(ROUND(ratio) - ratio) < 0.005 * data->contour_int)
if (fabs(round(ratio) - ratio) < 0.005 * data->contour_int)
data->tick_list[i] = 1;
else
data->tick_list[i] = 0;
Expand All @@ -1538,7 +1538,7 @@ int mb_ocontour(int verbose, struct swath *data, int *error) {
data->label_list[i] = 0;
else {
const double ratio = data->level_list[i] / data->label_int;
if (fabs(ROUND(ratio) - ratio) < 0.005 * data->contour_int)
if (fabs(round(ratio) - ratio) < 0.005 * data->contour_int)
data->label_list[i] = 1;
else
data->label_list[i] = 0;
Expand Down
7 changes: 2 additions & 5 deletions src/mbio/mb_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include <stdint.h>

/* Define version and date for this release */
#define MB_VERSION "5.8.1beta08"
#define MB_VERSION_DATE "10 March 2024"
#define MB_VERSION "5.8.1beta09"
#define MB_VERSION_DATE "22 March 2024"

/* CMake supports current OS's and so there is only one form of RPC and XDR and no mb_config.h file */
#ifdef CMAKE_BUILD_SYSTEM
Expand Down Expand Up @@ -255,9 +255,6 @@ typedef enum {
#ifndef MAX
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#endif
#ifndef ROUND
#define ROUND(X) X < 0.0 ? ceil(X - 0.5) : floor(X + 0.5)
#endif

/* NaN defines */
#ifdef NO_IEEE
Expand Down
57 changes: 28 additions & 29 deletions src/mbio/mbr_em710raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ int mbr_em710raw_rd_height(int verbose, void *mbio_ptr, int swap, struct mbsys_s
#endif
}

if (verbose >= 5) {
if (verbose >= 0) {
fprintf(stderr, "\ndbg5 Values read in MBIO function <%s>\n", __func__);
fprintf(stderr, "dbg5 type: %d\n", store->type);
fprintf(stderr, "dbg5 sonar: %d\n", store->sonar);
Expand Down Expand Up @@ -4600,7 +4600,6 @@ store->pings[store->ping_index].png_ss_count);
int mbr_rt_em710raw(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
int time_i[7];
double ntime_d, ptime_d, atime_d, btime_d;
double bath_time_d, ss_time_d;
double rawspeed, pheading;
double plon, plat, pspeed, roll, pitch, heave;
double att_time_d[MBSYS_SIMRAD3_MAXATTITUDE];
Expand Down Expand Up @@ -4802,36 +4801,36 @@ int mbr_rt_em710raw(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
match for survey data - we can have bath without
sidescan but not sidescan without bath */
else if (status == MB_SUCCESS && store->kind == MB_DATA_DATA) {
/* get times of bath and sidescan records */
time_i[0] = ping->png_date / 10000;
time_i[1] = (ping->png_date % 10000) / 100;
time_i[2] = ping->png_date % 100;
time_i[3] = ping->png_msec / 3600000;
time_i[4] = (ping->png_msec % 3600000) / 60000;
time_i[5] = (ping->png_msec % 60000) / 1000;
time_i[6] = (ping->png_msec % 1000) * 1000;
mb_get_time(verbose, time_i, &bath_time_d);
time_i[0] = ping->png_ss_date / 10000;
time_i[1] = (ping->png_ss_date % 10000) / 100;
time_i[2] = ping->png_ss_date % 100;
time_i[3] = ping->png_ss_msec / 3600000;
time_i[4] = (ping->png_ss_msec % 3600000) / 60000;
time_i[5] = (ping->png_ss_msec % 60000) / 1000;
time_i[6] = (ping->png_ss_msec % 1000) * 1000;
mb_get_time(verbose, time_i, &ss_time_d);

/* check for time match - if bath newer than
sidescan then zero sidescan, if sidescan
newer than bath then set error, if ok then
check that beam ids are the same */

/* make sure bathymetry, raw beam and snippet records have the same timestamp */
if (ping->png_count == ping->png_raw_count && (ping->png_date != ping->png_raw_date || ping->png_msec != ping->png_raw_msec)) {
ping->png_raw_date = ping->png_date;
ping->png_raw_msec = ping->png_msec;
}
if (ping->png_count == ping->png_ss_count && (ping->png_date != ping->png_ss_date || ping->png_msec != ping->png_ss_msec)) {
ping->png_ss_date = ping->png_date;
ping->png_ss_msec = ping->png_msec;
}

/* check for ping count match - if not
then zero sidescan, if ok then
check that beam numbers are the same */
if (ping->png_ss_date == 0 || ping->png_nbeams_ss == 0) {
status = mbsys_simrad3_zero_ss(verbose, store_ptr, error);
}
else if (fabs(bath_time_d - ss_time_d) > 0.002) {
if (verbose > 0)
fprintf(stderr, "%s: %4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%6.6d Sidescan zeroed, bathtime:%f != sstime:%f\n",
__func__, time_i[0], time_i[1], time_i[2], time_i[3], time_i[4], time_i[5], time_i[6], bath_time_d,
ss_time_d);
else if (ping->png_count != ping->png_ss_count) {
if (verbose > 0) {
time_i[0] = ping->png_date / 10000;
time_i[1] = (ping->png_date % 10000) / 100;
time_i[2] = ping->png_date % 100;
time_i[3] = ping->png_msec / 3600000;
time_i[4] = (ping->png_msec % 3600000) / 60000;
time_i[5] = (ping->png_msec % 60000) / 1000;
time_i[6] = (ping->png_msec % 1000) * 1000;
fprintf(stderr, "%s: %4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%6.6d Sidescan zeroed, png_count:%d != png_ss_count:%d\n",
__func__, time_i[0], time_i[1], time_i[2], time_i[3], time_i[4], time_i[5], time_i[6],
ping->png_count, ping->png_ss_count);
}
status = mbsys_simrad3_zero_ss(verbose, store_ptr, error);
}
else {
Expand Down
14 changes: 7 additions & 7 deletions src/mbio/mbr_sbsioswb.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ int mbr_rt_sbsioswb(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
if (status == MB_FAILURE && *error == MB_ERROR_UNINTELLIGIBLE) {
/* read rest of record into dummy */
for (int i = 0; i < data->sensor_size; i++) {
size_t read_len = 0;
size_t read_len = 0;
if ((read_len = fread(dummy, 1, 1, mb_io_ptr->mbfp)) != (size_t) 1) {
status = MB_FAILURE;
*error = MB_ERROR_EOF;
Expand All @@ -385,7 +385,7 @@ int mbr_rt_sbsioswb(int verbose, void *mbio_ptr, void *store_ptr, int *error) {

/* read sensor record from file */
if (status == MB_SUCCESS && data->sensor_size > 0) {
size_t read_len = 0;
size_t read_len = 0;
if ((read_len = fread(sensorptr, 1, data->sensor_size, mb_io_ptr->mbfp)) == (size_t) data->sensor_size) {
mb_io_ptr->file_bytes += read_len;
status = MB_SUCCESS;
Expand Down Expand Up @@ -523,10 +523,10 @@ int mbr_rt_sbsioswb(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
if (lon < 0.0)
lon = lon + 360.0;
store->lon2u = (unsigned short)60.0 * lon;
store->lon2b = (unsigned short)ROUND(600000.0 * (lon - store->lon2u / 60.0));
store->lon2b = (unsigned short)round(600000.0 * (lon - store->lon2u / 60.0));
lat = 0.0000001 * data->lat + 90.0;
store->lat2u = (unsigned short)60.0 * lat;
store->lat2b = (unsigned short)ROUND(600000.0 * (lat - store->lat2u / 60.0));
store->lat2b = (unsigned short)round(600000.0 * (lat - store->lat2u / 60.0));

/* time stamp */
store->year = data->year;
Expand All @@ -535,8 +535,8 @@ int mbr_rt_sbsioswb(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
store->sec = 0.01 * data->sec;

/* heading */
store->sbhdg = (data->heading < (short)0) ? (unsigned short)ROUND(((int)data->heading + 3600) * 18.204444444)
: (unsigned short)ROUND(data->heading * 18.204444444);
store->sbhdg = (data->heading < (short)0) ? (unsigned short)round(((int)data->heading + 3600) * 18.204444444)
: (unsigned short)round(data->heading * 18.204444444);

/* depths and distances */
id = data->beams_bath - 1;
Expand Down Expand Up @@ -685,7 +685,7 @@ int mbr_wt_sbsioswb(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
data->sec = 100 * store->sec;

/* heading */
data->heading = (short)ROUND(((int)store->sbhdg) * 0.054931641625);
data->heading = (short)round(((int)store->sbhdg) * 0.054931641625);

/* additional values */
data->eclipse_time = store->sbtim;
Expand Down
4 changes: 0 additions & 4 deletions src/mbio/mbsys_sb.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ int mbsys_sb_extract(int verbose, void *mbio_ptr, void *store_ptr, int *kind, in
double *navlat, double *speed, double *heading, int *nbath, int *namp, int *nss, char *beamflag,
double *bath, double *amp, double *bathacrosstrack, double *bathalongtrack, double *ss,
double *ssacrosstrack, double *ssalongtrack, char *comment, int *error) {
(void)amp; // Unused arg
(void)ss; // Unused arg
(void)ssacrosstrack; // Unused arg
(void)ssalongtrack; // Unused arg
if (verbose >= 2) {
fprintf(stderr, "\ndbg2 MBIO function <%s> called\n", __func__);
fprintf(stderr, "dbg2 Input arguments:\n");
Expand Down
Loading

0 comments on commit b0fe03b

Please sign in to comment.