Skip to content
Snippets Groups Projects
Commit 1e6f47b4 authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

fixed empty-series estimation bug

parent fdd12209
No related branches found
No related tags found
No related merge requests found
......@@ -202,6 +202,8 @@ def flagSoilMoistureByPrecipitationEvents(data, flags, field, flagger, prec_refe
# additionally drop the nan values that result from any preceeding upsampling of the
# measurements:
dataseries = dataseries.dropna()
if dataseries.empty:
return (data, flags)
# estimate moisture sampling frequencie (the original series sampling rate may not match data-input sample rate):
moist_rate = estimateSamplingRate(dataseries.index)
# resample dataseries to its original sampling rate
......@@ -217,6 +219,8 @@ def flagSoilMoistureByPrecipitationEvents(data, flags, field, flagger, prec_refe
flagger.isFlagged(ref_flags, flag=flagger.flags.unflagged())
refseries = refseries[ref_use.values]
refseries = refseries.dropna()
if refseries.empty:
return (data,flags)
prec_rate = estimateSamplingRate(refseries.index)
refseries.resample(prec_rate).asfreq()
......
......@@ -109,6 +109,9 @@ def estimateSamplingRate(index):
:param index: A DatetimeIndex or array like Datetime listing, of wich you want the sampling rate to be
estimated.
"""
if index.empty:
return pd.tseries.frequencies.to_offset('0s')
scnds_series = (pd.Series(index).diff().dt.total_seconds()).dropna()
max_scnds = scnds_series.max()
min_scnds = scnds_series.min()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment