From 23a427606482e78ed2ee410863f4f35c88b1539e Mon Sep 17 00:00:00 2001 From: Carson Sears Date: Wed, 12 Apr 2023 13:37:10 -0400 Subject: [PATCH] Remove old functions that are no longer used --- Framework/API/inc/MantidAPI/Algorithm.h | 5 - Framework/API/inc/MantidAPI/LogManager.h | 2 - Framework/API/inc/MantidAPI/Run.h | 3 - Framework/API/src/LogManager.cpp | 35 ------ Framework/API/src/Run.cpp | 24 ---- Framework/DataObjects/src/TimeSplitter.cpp | 2 +- .../inc/MantidKernel/IPropertyManager.h | 3 - .../inc/MantidKernel/ITimeSeriesProperty.h | 3 +- .../Kernel/inc/MantidKernel/PropertyManager.h | 1 - .../inc/MantidKernel/PropertyManagerOwner.h | 5 - .../inc/MantidKernel/TimeSeriesProperty.h | 4 - Framework/Kernel/src/PropertyManager.cpp | 39 ------ Framework/Kernel/src/TimeSeriesProperty.cpp | 118 +----------------- .../Kernel/test/TimeSeriesPropertyTest.h | 79 ------------ 14 files changed, 3 insertions(+), 320 deletions(-) diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index 71a8aa6f4f49..cb7b91701d90 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -362,11 +362,6 @@ class MANTID_API_DLL Algorithm : public IAlgorithm { /// The argument is the property name. Default - do nothing. void afterPropertySet(const std::string &) override; - void splitByTime(std::vector & /*splitter*/, - std::vector /* outputs*/) const override { - throw(std::runtime_error("Not yet implmented")); - } - void filterByProperty(const Kernel::TimeSeriesProperty & /*filter*/, const std::vector & /* excludedFromFiltering */) override { throw(std::runtime_error("Not yet implmented")); diff --git a/Framework/API/inc/MantidAPI/LogManager.h b/Framework/API/inc/MantidAPI/LogManager.h index 3d03d5c7ae33..1d179af9b0c6 100644 --- a/Framework/API/inc/MantidAPI/LogManager.h +++ b/Framework/API/inc/MantidAPI/LogManager.h @@ -68,8 +68,6 @@ class MANTID_API_DLL LogManager { /// Filter the logs by time virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop); - /// Split the logs based on the given intervals - virtual void splitByTime(Kernel::SplittingIntervalVec &splitter, std::vector outputs) const; /// Filter the run by the given boolean log void filterByLog(const Kernel::TimeSeriesProperty &filter, const std::vector &excludedFromFiltering = std::vector()); diff --git a/Framework/API/inc/MantidAPI/Run.h b/Framework/API/inc/MantidAPI/Run.h index 8aee6e5d3c6c..b54698ca4ce9 100644 --- a/Framework/API/inc/MantidAPI/Run.h +++ b/Framework/API/inc/MantidAPI/Run.h @@ -53,9 +53,6 @@ class MANTID_API_DLL Run : public LogManager { /// Filter the logs by time void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop) override; - /// Split the logs based on the given intervals - void splitByTime(Kernel::SplittingIntervalVec &splitter, std::vector outputs) const override; - void setTimeROI(const Kernel::TimeROI &timeroi) override; /// Return an approximate memory size for the object in bytes diff --git a/Framework/API/src/LogManager.cpp b/Framework/API/src/LogManager.cpp index 98c24055af00..9e4d3f7f313f 100644 --- a/Framework/API/src/LogManager.cpp +++ b/Framework/API/src/LogManager.cpp @@ -194,41 +194,6 @@ void LogManager::filterByTime(const Types::Core::DateAndTime start, const Types: this->setTimeROI(TimeROI(start, stop)); } -//----------------------------------------------------------------------------------------------- -/** - * Split a run by time (splits the TimeSeriesProperties contained). - * - * - * @param splitter :: SplittingIntervalVec with the intervals and destinations. - * @param outputs :: Vector of output runs. - */ -void LogManager::splitByTime(SplittingIntervalVec &splitter, std::vector outputs) const { - // Make a vector of managers for the splitter. Fun! - const size_t n = outputs.size(); - std::vector output_managers(outputs.size(), nullptr); - for (size_t i = 0; i < n; i++) { - if (outputs[i]) { - output_managers[i] = outputs[i]->m_manager.get(); - } - } - - // Now that will do the split down here. - m_manager->splitByTime(splitter, output_managers); - - // endow each LogManager with the TimeROI constructed from the corresponding splitter - // it is implicit that the running index of vector outputs is the destination index in the splitter - const std::map roiMap = timeROIsFromSplitters(splitter); - if (!roiMap.empty()) { - for (size_t i = 0; i < n; i++) { - if (outputs[i]) { - int destinationIndex = static_cast(i); - const Kernel::TimeROI &roi = roiMap.at(destinationIndex); - outputs[i]->setTimeROI(roi); - } - } - } -} - //----------------------------------------------------------------------------------------------- /** * Filter the run by the given boolean log. It replaces all time diff --git a/Framework/API/src/Run.cpp b/Framework/API/src/Run.cpp index c23e84f4a817..4e77b50d897a 100644 --- a/Framework/API/src/Run.cpp +++ b/Framework/API/src/Run.cpp @@ -226,30 +226,6 @@ Run &Run::operator+=(const Run &rhs) { return *this; } -//----------------------------------------------------------------------------------------------- -/** - * Split a run by time (splits the TimeSeriesProperties contained). - * - * Total proton charge will get re-integrated after filtering. - * - * @param splitter :: SplittingIntervalVec with the intervals and destinations. - * @param outputs :: Vector of output runs. - */ -void Run::splitByTime(SplittingIntervalVec &splitter, std::vector outputs) const { - - // std::vector outputsBase(outputs.begin(),outputs.end()); - LogManager::splitByTime(splitter, outputs); - - // Re-integrate proton charge of all outputs - for (auto output : outputs) { - if (output) { - auto run = dynamic_cast(output); - if (run) - run->integrateProtonCharge(); - } - } -} - // this overrides the one from LogManager so the proton charge can be recalculated void Run::setTimeROI(const Kernel::TimeROI &timeroi) { LogManager::setTimeROI(timeroi); diff --git a/Framework/DataObjects/src/TimeSplitter.cpp b/Framework/DataObjects/src/TimeSplitter.cpp index 9850220a26b3..b83f47e6c2fb 100644 --- a/Framework/DataObjects/src/TimeSplitter.cpp +++ b/Framework/DataObjects/src/TimeSplitter.cpp @@ -310,7 +310,7 @@ void TimeSplitter::splitEventList(const EventList &events, std::map getPropertiesInGroup(const std::string &group) const; - virtual void splitByTime(std::vector & /*splitter*/, - std::vector /* outputs*/) const = 0; - virtual void filterByProperty(const TimeSeriesProperty & /*filter*/, const std::vector & /* excludedFromFiltering */) = 0; diff --git a/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h b/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h index b1f135a3640f..ba78fcf47154 100644 --- a/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h +++ b/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h @@ -46,8 +46,7 @@ class ITimeSeriesProperty { virtual Property *cloneWithTimeShift(const double timeShift) const = 0; virtual void filterByTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &stop) = 0; - virtual void splitByTime(const std::vector &splitter, std::vector outputs, - bool isProtonCharge = true) const = 0; + /// Return the time series's times as a vector virtual std::vector timesAsVector() const = 0; /** Returns the calculated time weighted average value. diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManager.h b/Framework/Kernel/inc/MantidKernel/PropertyManager.h index d5ce12439b6e..843f42f25bb4 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManager.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManager.h @@ -54,7 +54,6 @@ class MANTID_KERNEL_DLL PropertyManager : virtual public IPropertyManager { PropertyManager &operator=(const PropertyManager &); PropertyManager &operator+=(const PropertyManager &rhs); - void splitByTime(std::vector &splitter, std::vector outputs) const override; void filterByProperty(const TimeSeriesProperty &filter, const std::vector &excludedFromFiltering = std::vector()) override; diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h index fc2a18ce6bde..ba911ab4d002 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h @@ -96,11 +96,6 @@ class MANTID_KERNEL_DLL PropertyManagerOwner : virtual public IPropertyManager { /// The argument is the property name. Default - do nothing. void afterPropertySet(const std::string &) override; - void splitByTime(std::vector & /*splitter*/, - std::vector /* outputs*/) const override { - throw(std::runtime_error("Not yet implmented")); - } - void filterByProperty(const TimeSeriesProperty & /*filter*/, const std::vector & /* excludedFromFiltering */) override { throw(std::runtime_error("Not yet implmented")); diff --git a/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h b/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h index 16792347df6f..9d089fba61c6 100644 --- a/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h +++ b/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h @@ -185,10 +185,6 @@ template class DLLExport TimeSeriesProperty : public Property, p /// Filter by a range of times void filterByTimes(const TimeROI &timeroi); - /// Split out a time series property by time intervals. - void splitByTime(const std::vector &splitter, std::vector outputs, - bool isPeriodic) const override; - /// New split method void splitByTimeVector(const std::vector &splitter_time_vec, const std::vector &target_vec, const std::vector &outputs); diff --git a/Framework/Kernel/src/PropertyManager.cpp b/Framework/Kernel/src/PropertyManager.cpp index 01dea7652b37..c9f9e24fea24 100644 --- a/Framework/Kernel/src/PropertyManager.cpp +++ b/Framework/Kernel/src/PropertyManager.cpp @@ -126,45 +126,6 @@ PropertyManager &PropertyManager::operator+=(const PropertyManager &rhs) { return *this; } -//----------------------------------------------------------------------------------------------- -/** - * Split a run by time (splits the TimeSeriesProperties contained). - * - * Total proton charge will get re-integrated after filtering. - * - * @param splitter :: SplittingIntervalVec with the intervals and destinations. - * @param outputs :: Vector of output runs. - */ -void PropertyManager::splitByTime(std::vector &splitter, - std::vector outputs) const { - size_t n = outputs.size(); - - // Iterate through all properties - PropertyMap::const_iterator it; - for (it = this->m_properties.begin(); it != this->m_properties.end(); ++it) { - // Filter out the property - Property *prop = it->second.get(); - - // Make a vector of the output properties contained in the other property - // managers. - // NULL if it was not found. - std::vector output_properties; - for (size_t i = 0; i < n; i++) { - if (outputs[i]) - output_properties.emplace_back(outputs[i]->getPointerToPropertyOrNull(prop->name())); - else - output_properties.emplace_back(nullptr); - } - - // Now the property does the splitting. - bool isProtonCharge = prop->name() == "proton_charge"; - if (auto timeSeriesProperty = dynamic_cast(prop)) { - timeSeriesProperty->splitByTime(splitter, output_properties, isProtonCharge); - } - - } // for each property -} - //----------------------------------------------------------------------------------------------- /** * Filter the managed properties by the given boolean property mask. It replaces diff --git a/Framework/Kernel/src/TimeSeriesProperty.cpp b/Framework/Kernel/src/TimeSeriesProperty.cpp index 9e88d4510ecf..0fb4f5558ac8 100644 --- a/Framework/Kernel/src/TimeSeriesProperty.cpp +++ b/Framework/Kernel/src/TimeSeriesProperty.cpp @@ -356,7 +356,7 @@ template void TimeSeriesProperty::filterByTimes(const Time /* Check */ if (tstartindex < 0 || tstopindex >= int(m_values.size())) { - g_log.warning() << "Memory Leak In SplitbyTime!\n"; + g_log.warning() << "Memory Leak In FilterByTimes!\n"; } if (tstartindex == tstopindex) { @@ -381,122 +381,6 @@ template void TimeSeriesProperty::filterByTimes(const Time m_size = static_cast(m_values.size()); } -/** - * Split this time series property by time intervals to multiple time series - * property according to number of distinct splitters' indexes, such as 0 and 1 - * - * NOTE: If the input TSP has a single value, it is assumed to be a constant - * and so is not split, but simply copied to all output. - * - * @param splitter :: a SplittingIntervalVec object containing the list of intervals - * and destinations. - * @param outputs :: A vector of output TimeSeriesProperty - * pointers of the same type. - * @param isPeriodic :: whether the log (this TSP) is periodic. For example - * proton-charge is periodic log. - */ -template -void TimeSeriesProperty::splitByTime(const std::vector &splitter, - std::vector outputs, bool isPeriodic) const { - // 0. Sort if necessary - sortIfNecessary(); - - if (outputs.empty()) - return; - - std::vector *> outputs_tsp; - - size_t numOutputs = outputs.size(); - // 1. Clear the outputs before you start - for (size_t i = 0; i < numOutputs; i++) { - auto *myOutput = dynamic_cast *>(outputs[i]); - if (myOutput) { - outputs_tsp.emplace_back(myOutput); - if (this->m_values.size() == 1) { - // Special case for TSP with a single entry = just copy. - myOutput->m_values = this->m_values; - myOutput->m_size = 1; - } else { - myOutput->m_values.clear(); - myOutput->m_size = 0; - } - } else { - outputs_tsp.emplace_back(nullptr); - } - } - - // 2. Special case for TSP with a single entry = just copy. - if (this->m_values.size() == 1) - return; - - // 3. We will be iterating through all the entries in the the map/vector - size_t i_property = 0; - - // And at the same time, iterate through the splitter - auto itspl = splitter.begin(); - - size_t counter = 0; - g_log.debug() << "[DB] Number of time series entries = " << m_values.size() - << ", Number of splitters = " << splitter.size() << "\n"; - while (itspl != splitter.end() && i_property < m_values.size()) { - // Get the splitting interval times and destination - DateAndTime start = itspl->start(); - DateAndTime stop = itspl->stop(); - - int output_index = itspl->index(); - // output workspace index is out of range. go to the next splitter - if (output_index < 0 || output_index >= static_cast(numOutputs)) - continue; - - TimeSeriesProperty *myOutput = outputs_tsp[output_index]; - // skip if the input property is of wrong type - if (!myOutput) { - ++itspl; - ++counter; - continue; - } - - // Skip the events before the start of the time - while (i_property < m_values.size() && m_values[i_property].time() < start) - ++i_property; - - if (i_property == m_values.size()) { - // i_property is out of the range. Then use the last entry - myOutput->addValue(m_values[i_property - 1].time(), m_values[i_property - 1].value()); - break; - } - - // The current entry is within an interval. Record them until out - if (m_values[i_property].time() > start && i_property > 0 && !isPeriodic) { - // Record the previous oneif this property is not exactly on start time - // and this entry is not recorded - size_t i_prev = i_property - 1; - if (myOutput->size() == 0 || m_values[i_prev].time() != myOutput->lastTime()) - myOutput->addValue(m_values[i_prev].time(), m_values[i_prev].value()); - } - - // Loop through all the entries until out. - while (i_property < m_values.size() && m_values[i_property].time() < stop) { - - // Copy the log out to the output - myOutput->addValue(m_values[i_property].time(), m_values[i_property].value()); - ++i_property; - } - - // Go to the next interval - ++itspl; - ++counter; - } // Looping through entries in the splitter vector - - // Make sure all entries have the correct size recorded in m_size. - for (std::size_t i = 0; i < numOutputs; i++) { - auto *myOutput = dynamic_cast *>(outputs[i]); - if (myOutput) { - myOutput->m_size = myOutput->realSize(); - } - } -} - /// Split this TimeSeriresProperty by a vector of time with N entries, /// and by the wsIndex workspace index defined by inputWorkspaceIndicies /// Requirements: diff --git a/Framework/Kernel/test/TimeSeriesPropertyTest.h b/Framework/Kernel/test/TimeSeriesPropertyTest.h index 4671d2709cb8..5da77aba8e1e 100644 --- a/Framework/Kernel/test/TimeSeriesPropertyTest.h +++ b/Framework/Kernel/test/TimeSeriesPropertyTest.h @@ -755,85 +755,6 @@ class TimeSeriesPropertyTest : public CxxTest::TestSuite { TS_ASSERT_THROWS(sProp->timeAverageValueAndStdDev(), const Exception::NotImplementedError &); } - //---------------------------------------------------------------------------- - void test_splitByTime_and_getTotalValue() { - TimeSeriesProperty *log = createIntegerTSP(12); - // Make the outputs - std::vector outputs; - for (std::size_t i = 0; i < 5; i++) { - TimeSeriesProperty *newlog = new TimeSeriesProperty("MyIntLog"); - outputs.emplace_back(newlog); - } - - // Make a splitter - DateAndTime start, stop; - SplittingIntervalVec splitter; - start = DateAndTime("2007-11-30T16:17:10"); - stop = DateAndTime("2007-11-30T16:17:40"); - splitter.emplace_back(SplittingInterval(start, stop, 0)); - - start = DateAndTime("2007-11-30T16:17:55"); - stop = DateAndTime("2007-11-30T16:17:56"); - splitter.emplace_back(SplittingInterval(start, stop, 1)); - - start = DateAndTime("2007-11-30T16:17:56"); - stop = DateAndTime("2007-11-30T16:18:01"); - splitter.emplace_back(SplittingInterval(start, stop, 2)); // just one entry - - start = DateAndTime("2007-11-30T16:18:09"); - stop = DateAndTime("2007-11-30T16:18:21"); - splitter.emplace_back(SplittingInterval(start, stop, 3)); - - start = DateAndTime("2007-11-30T16:18:45"); - stop = DateAndTime("2007-11-30T16:22:50"); - splitter.emplace_back(SplittingInterval(start, stop, 4)); - - log->splitByTime(splitter, outputs, false); - - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[0])->realSize(), 3); - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[1])->realSize(), 1); - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[2])->realSize(), 2); - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[3])->realSize(), 3); - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[4])->realSize(), 2); - - delete log; - delete outputs[0]; - delete outputs[1]; - delete outputs[2]; - delete outputs[3]; - delete outputs[4]; - } - - //---------------------------------------------------------------------------- - void test_splitByTime_withOverlap() { - TimeSeriesProperty *log = createIntegerTSP(12); - - // Make the outputs - std::vector outputs; - for (std::size_t i = 0; i < 1; i++) { - TimeSeriesProperty *newlog = new TimeSeriesProperty("MyIntLog"); - outputs.emplace_back(newlog); - } - - // Make a splitter - DateAndTime start, stop; - SplittingIntervalVec splitter; - start = DateAndTime("2007-11-30T16:17:10"); - stop = DateAndTime("2007-11-30T16:17:40"); - splitter.emplace_back(SplittingInterval(start, stop, 0)); - - start = DateAndTime("2007-11-30T16:17:35"); - stop = DateAndTime("2007-11-30T16:17:59"); - splitter.emplace_back(SplittingInterval(start, stop, 0)); - - log->splitByTime(splitter, outputs, false); - - TS_ASSERT_EQUALS(dynamic_cast *>(outputs[0])->realSize(), 5); - - delete log; - delete outputs[0]; - } - //---------------------------------------------------------------------------- /** * otuput 0 has entries: 3