Skip to content

Commit

Permalink
Weights based purely on depth for statistics calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
eriffon committed Sep 26, 2023
1 parent 8cbd57b commit 347dc51
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hyo2/soundspeed/profile/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def weighted_arithmetic_std(cls, values, weights):
return math.sqrt(var)

def weighted_harmonic_std(self):
w = self.calc_weights(self.proc.speed[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
avg = self.weighted_harmonic_mean()
var = np.average((self.proc.speed[self.proc_valid] - avg) ** 2, weights=w)
return math.sqrt(var)
Expand Down Expand Up @@ -215,17 +215,17 @@ def proc_depth_median(self):

@property
def proc_speed_median(self):
w = self.calc_weights(self.proc.speed[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return self.weighted_median(self.proc.speed[self.proc_valid], w)

@property
def proc_temp_median(self):
w = self.calc_weights(self.proc.temp[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return self.weighted_median(self.proc.temp[self.proc_valid], w)

@property
def proc_sal_median(self):
w = self.calc_weights(self.proc.sal[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return self.weighted_median(self.proc.sal[self.proc_valid], w)

@property
Expand All @@ -239,12 +239,12 @@ def proc_speed_mean(self):

@property
def proc_temp_mean(self):
w = self.calc_weights(self.proc.temp[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return np.average(self.proc.temp[self.proc_valid], weights=w)

@property
def proc_sal_mean(self):
w = self.calc_weights(self.proc.sal[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return np.average(self.proc.sal[self.proc_valid], weights=w)

@property
Expand All @@ -258,13 +258,14 @@ def proc_speed_std(self):

@property
def proc_temp_std(self):
w = self.calc_weights(self.proc.temp[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return self.weighted_arithmetic_std(self.proc.temp[self.proc_valid], w)

@property
def proc_sal_std(self):
w = self.calc_weights(self.proc.sal[self.proc_valid])
w = self.calc_weights(self.proc.depth[self.proc_valid])
return self.weighted_arithmetic_std(self.proc.sal[self.proc_valid], w)
return 0.0

def _calc_water_salinity_threshold(self):
"""Determine salinity threshold from min/max values to help determine where instrument entered water"""
Expand Down

0 comments on commit 347dc51

Please sign in to comment.