Skip to content

Commit

Permalink
Add docs and return type annotations as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
lsetiawan committed Apr 6, 2023
1 parent 766c131 commit 418eb5d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/seagap/harmonic_mean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import math
from typing import Union

import numba
import numpy as np
Expand All @@ -10,15 +9,30 @@
def _compute_hm(
dd: np.ndarray,
sv: np.ndarray,
start_depth: Union[int, float],
end_depth: Union[int, float],
start_depth: float,
end_depth: float,
start_index: int,
):
) -> float:
"""
Computes harmonic mean.
It's a direct translation from the original Fortran code found in
src/cal_sv_harmonic_mean/get_sv_harmonic_mean.F called
subroutine `sv_harmon_mean`
Parameters
----------
dd : np.ndarray
Depth values array dd[n]
sv : np.ndarray
Sound speed values array sv[n]
start_depth : float
The start depth for calculation
end_depth : float
The end depth for calculation
start_index : int
The start index for the first value
computed by start depth
"""
# TODO: Find a way to vectorize this computation

Expand Down Expand Up @@ -84,8 +98,8 @@ def _compute_hm(


def sv_harmonic_mean(
svdf: pd.DataFrame, start_depth: Union[int, float], end_depth: Union[int, float]
):
svdf: pd.DataFrame, start_depth: float, end_depth: float
) -> float:
"""
Computes harmonic mean from a sound profile
containing depth (dd) and sound speed (sv)
Expand Down

0 comments on commit 418eb5d

Please sign in to comment.