Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Interpolate to fill in holes in infererence input #246

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
MNT: Do nan interpolation step per-segment, not whole file
  • Loading branch information
scottclowe committed Jan 29, 2022
commit 38998d79967bf84fc318884d58b907c0e06e128d
15 changes: 7 additions & 8 deletions echofilter/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,14 +845,6 @@ def run_inference(
print(msg)
raise

n_nans = np.isnan(signals).sum()
if n_nans > 0:
if verbose >= 2:
print(
" Interpolating to remove {} missing Sv values".format(n_nans)
)
signals = fillholes2d(signals)

try:
output = inference_transect(
model,
Expand Down Expand Up @@ -1287,6 +1279,13 @@ def inference_transect(
maybe_tqdm = lambda x: x
outputs = []
for segment in maybe_tqdm(segments):
# Try to remove any NaNs in the raw input with using 2d interpolation
n_nans = np.isnan(segment["signals"]).sum()
if n_nans > 0:
if verbose >= 1:
print(" Interpolating to fill in {} missing Sv values".format(n_nans))
segment["signals"] = fillholes2d(segment["signals"])

# Preprocessing transform
transform = torchvision.transforms.Compose(
[
Expand Down