Skip to content

Commit

Permalink
bug fixes for too short profiles and duplicated profile samples
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Aug 8, 2018
1 parent c5e773c commit 6ae3c7a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion hyo/soundspeed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

__version__ = '2018.1.43'
__version__ = '2018.1.44'
__doc__ = "Sound Speed"
__author__ = '[email protected]; [email protected]; [email protected]; ' \
'[email protected]'
Expand Down
5 changes: 5 additions & 0 deletions hyo/soundspeed/profile/ray_tracing/diff_tracedprofiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def calc_diff(self):

# logger.debug("end z: %s/%s" % (new_z[-1], old_z[-1]))

if (len(new_t) == 0) or (len(old_t) == 0):
self.new_rays.append(np.array([list(), list(), list()]))
self.old_rays.append(np.array([list(), list(), list()]))
return

new_is_longer = False
min_time = new_t[-1]
if new_t[-1] > old_t[-1]:
Expand Down
34 changes: 24 additions & 10 deletions hyo/soundspeed/profile/ray_tracing/tracedprofile.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ cdef class TracedProfile:
break

# remove extension value (if any)
if (depths[-1] - depths[-2]) > 1000:
logger.info("removed latest extension depth: %s" % depths[-1])
del depths[-1]
if len(depths) > 3:
if (depths[-1] - depths[-2]) > 1000:
logger.info("removed latest extension depth: %s" % depths[-1])
del depths[-1]

logger.info("profile timestamp: %s" % ssp.meta.utc_time)
logger.debug("valid samples: %d" % (len(depths)), )
Expand Down Expand Up @@ -90,7 +91,8 @@ cdef class TracedProfile:

if dz == 0: # if (dc == 0) and (dy == 0):

logger.warning("skipping duplicated point: #%d" % idx)
# logger.debug("duplicated point: #%d" % idx)
beta.append(beta[idx]) # beta does not change
continue

# gradient = dc/dy
Expand Down Expand Up @@ -137,15 +139,27 @@ cdef class TracedProfile:
# logger.debug("x:\n%s" % total_x)
# logger.debug("t:\n%s" % total_t)

harm_mean = (total_z[-1] - total_z[0]) / (total_t[-1] - total_t[0])
if len(depths) > 1:
harm_mean = (total_z[-1] - total_z[0]) / (total_t[-1] - total_t[0])
elif len(depths) == 1:
harm_mean = depths[0]
else:
raise RuntimeError("invalid profile with zero valid depth values")
self.harmonic_means.append(harm_mean)

# interpolate between 0 and 5000 meters with decimetric resolution
interp_z = numpy.linspace(0, 5000, num=25001, endpoint=True)
fx = interp1d(total_z, total_x, kind='cubic', bounds_error=False, fill_value=-1)
interp_x = fx(interp_z)
ft = interp1d(total_z, total_t, kind='cubic', bounds_error=False, fill_value=-1)
interp_t = ft(interp_z)
if len(depths) > 1:
interp_z = numpy.linspace(0, 5000, num=25001, endpoint=True)
fx = interp1d(total_z, total_x, kind='cubic', bounds_error=False, fill_value=-1)
interp_x = fx(interp_z)
ft = interp1d(total_z, total_t, kind='cubic', bounds_error=False, fill_value=-1)
interp_t = ft(interp_z)

elif len(depths) == 1:
interp_z = total_z
interp_x = total_x
interp_t = total_t

self.rays.append(numpy.array([interp_t, interp_x, interp_z]))

logger.debug("rays: %d (%d samples per-ray)" % (len(self.rays), len(self.rays[0][0])))
Expand Down
2 changes: 1 addition & 1 deletion hyo/soundspeedmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

__version__ = '2018.1.43'
__version__ = '2018.1.44'
__doc__ = "Sound Speed Manager"
__author__ = '[email protected]; [email protected]; [email protected]; ' \
'[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion hyo/soundspeedsettings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

__version__ = '2018.1.43'
__version__ = '2018.1.44'
__doc__ = "Sound Speed Settings"
__author__ = '[email protected]; [email protected]; [email protected]; ' \
'[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def txt_read(*paths):
setup_args = dict()

setup_args['name'] = 'hyo.soundspeed'
setup_args['version'] = '2018.1.43'
setup_args['version'] = '2018.1.44'
setup_args['url'] = 'https://bitbucket.org/ccomjhc/hyo_soundspeed/'
setup_args['license'] = 'LGPLv2.1 or CCOM-UNH Industrial Associate license'
setup_args['author'] = 'Giuseppe Masetti(UNH,CCOM); Barry Gallagher(NOAA,OCS); ' \
Expand Down

0 comments on commit 6ae3c7a

Please sign in to comment.