Skip to content

Commit

Permalink
fix: update sound prediction function
Browse files Browse the repository at this point in the history
  • Loading branch information
RDWimmers committed Nov 14, 2023
1 parent efac2ff commit c2fb915
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/pyvibracore/results/sound_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@
def _sound_prediction(
power: float, k2: float, period: float, levels: List[float]
) -> NDArray:
distance = np.arange(1e-5, 150, step=0.2)
distance = np.arange(1e-5, 500, step=0.2)
noise = (
power
- (-10 * np.log(period / 12))
- (20 * np.log(distance) + 0.005 * distance + 9.1)
- (-10 * np.log10(period / 12))
- (20 * np.log10(distance) + 0.005 * distance + 9.1)
+ k2
)

f = interpolate.interp1d(noise, distance, kind="cubic")
return f(levels)
# interpolate and predict
f = interpolate.interp1d(
noise, distance, kind="cubic", assume_sorted=False, fill_value="extrapolate"
)
space = f(levels)

# raise warning
if any([item > 500 for item in space]):
logging.warning(
"One or more distances exceeds the 500 meter mark. "
"Please note that this methode extrapolate the values from this point."
)

return space


def map_sound(
Expand Down

0 comments on commit c2fb915

Please sign in to comment.