Skip to content

Commit

Permalink
Merge pull request #169 from jklymak/fix-maxgap
Browse files Browse the repository at this point in the history
FIX: bad maxgap default
  • Loading branch information
jklymak authored Jun 1, 2024
2 parents 6c36973 + 5ea2202 commit b2a31ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pyglider/seaexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ def _remove_fill_values(df, fill_value=9999):


def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw',
profile_filt_time=100, profile_min_time=300, maxgap=300, interpolate=False, fnamesuffix=''):
profile_filt_time=100, profile_min_time=300,
maxgap=10, interpolate=False, fnamesuffix=''):
"""
A little different than above, for the 4-file version of the data set.
"""
Expand Down Expand Up @@ -390,7 +391,9 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw',
val = np.interp(time_timebase.astype(float), time_var.astype(float), var_non_nan)

# interpolate only over those gaps that are smaller than 'maxgap'
tg_ind = utils.find_gaps(time_var.astype(float),time_timebase.astype(float),maxgap)
# apparently maxgap is to be in somethng like seconds, and this data is in ms. Certainly
# the default of 0.3 s was not intended. Changing default to 10 s:
tg_ind = utils.find_gaps(time_var.astype(float), time_timebase.astype(float), maxgap*1000)
val[tg_ind] = np.nan
else:
val = val[indctd]
Expand Down
4 changes: 3 additions & 1 deletion pyglider/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ def gappy_fill_vertical(data):
data[:, j][ind[0]:ind[-1]] = np.interp(int, ind, data[ind, j])
return data


def find_gaps(sample_time, timebase, maxgap):
"""
Return an index into *timebase* where True are times in gaps of *sample_time* larger
Expand All @@ -590,10 +591,11 @@ def find_gaps(sample_time, timebase, maxgap):

# get the indices of timebase that are too large and account for the
# degenerate case when a timebase point falls directly on a sample time.
index = ~np.logical_or((ddt <= maxgap),(np.isin(timebase,sample_time)))
index = ~np.logical_or((ddt <= maxgap), (np.isin(timebase,sample_time)))

return index


def _parse_gliderxml_pos(fname):
"""
DEPRECATED: use slocum.parse_gliderState instead
Expand Down

0 comments on commit b2a31ae

Please sign in to comment.