Skip to content

Commit

Permalink
Trim filtered table to original time range in TabOpLowPassFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbianco committed Nov 16, 2024
1 parent 2300a90 commit 9edc0bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions OpenSim/Simulation/TableProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ class OSIMSIMULATION_API TabOpLowPassFilter : public TableOperator {
"Expected cutoff frequency to be positive, but got {}.",
get_cutoff_frequency());

const auto& times = table.getIndependentColumn();
double initialTime = times.front();
double finalTime = times.back();
TableUtilities::filterLowpass(
table, get_cutoff_frequency(), true);
table.trim(initialTime, finalTime);
}
}
};
Expand Down
10 changes: 10 additions & 0 deletions OpenSim/Simulation/Test/testTableProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ TEST_CASE("TableProcessor") {
}
}
}

TEST_CASE("TabOpLowPassFilter retains original time range") {
TimeSeriesTable table(std::vector<double>{1, 2, 3, 4, 5, 6},
SimTK::Test::randMatrix(6, 2), std::vector<std::string>{"a", "b"});
TableProcessor proc = TableProcessor(table) | TabOpLowPassFilter(6);
TimeSeriesTable out = proc.process();
CHECK(out.getNumRows() == 6);
CHECK(out.getIndependentColumn().front() == 1);
CHECK(out.getIndependentColumn().back() == 6);
}

0 comments on commit 9edc0bf

Please sign in to comment.