Skip to content

Commit

Permalink
tsEvaRunningMeanTrend: series filling logics moved to tsEvaFillSeries
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Mentaschi authored and Lorenzo Mentaschi committed Jun 16, 2016
1 parent 3e7a704 commit 6282602
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
13 changes: 13 additions & 0 deletions tsEvaFillSeries.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function [ filledTimeStamps, filledSeries, dt ] = tsEvaFillSeries( timeStamps, series )
indxs = ~isnan(series);
timeStamps = timeStamps(indxs);
series = series(indxs);

mint = min(timeStamps);
maxt = max(timeStamps);
dt = min(diff(timeStamps));
filledTimeStamps = (mint:dt:maxt)';
filledSeries = interp1(timeStamps, series, filledTimeStamps, 'nearest');
filledSeries = tsRemoveConstantSubseries(filledSeries, 4);
end

14 changes: 2 additions & 12 deletions tsEvaRunningMeanTrend.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
function [ trendSeries, filledTimeStamps, filledSeries, nRunMn ] = tsEvaRunningMeanTrend( timeStamps, series, timeWindow)
indxs = ~isnan(series);
timeStamps = timeStamps(indxs);
series = series(indxs);

mint = min(timeStamps);
maxt = max(timeStamps);
mindt = min(diff(timeStamps));
filledTimeStamps = (mint:mindt:maxt)';
filledSeries = interp1(timeStamps, series, filledTimeStamps, 'nearest');
filledSeries = tsRemoveConstantSubseries(filledSeries, 4);

nRunMn = ceil(timeWindow/mindt);
[ filledTimeStamps, filledSeries, dt ] = tsEvaFillSeries( timeStamps, series );
nRunMn = ceil(timeWindow/dt);
trendSeries = tsEvaNanRunningMean(filledSeries, nRunMn);
trendSeries = tsEvaNanRunningMean(trendSeries, ceil(nRunMn/2));
end
Expand Down

0 comments on commit 6282602

Please sign in to comment.