Skip to content

Commit

Permalink
Remove old functions that are no longer used
Browse files Browse the repository at this point in the history
  • Loading branch information
searscr committed Apr 12, 2023
1 parent 9f71354 commit 3cdda2c
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 320 deletions.
5 changes: 0 additions & 5 deletions Framework/API/inc/MantidAPI/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Kernel::SplittingInterval> & /*splitter*/,
std::vector<Kernel::PropertyManager *> /* outputs*/) const override {
throw(std::runtime_error("Not yet implmented"));
}

void filterByProperty(const Kernel::TimeSeriesProperty<bool> & /*filter*/, const std::vector<std::string> &
/* excludedFromFiltering */) override {
throw(std::runtime_error("Not yet implmented"));
Expand Down
2 changes: 0 additions & 2 deletions Framework/API/inc/MantidAPI/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogManager *> outputs) const;
/// Filter the run by the given boolean log
void filterByLog(const Kernel::TimeSeriesProperty<bool> &filter,
const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>());
Expand Down
3 changes: 0 additions & 3 deletions Framework/API/inc/MantidAPI/Run.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogManager *> outputs) const override;

void setTimeROI(const Kernel::TimeROI &timeroi) override;

/// Return an approximate memory size for the object in bytes
Expand Down
35 changes: 0 additions & 35 deletions Framework/API/src/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogManager *> outputs) const {
// Make a vector of managers for the splitter. Fun!
const size_t n = outputs.size();
std::vector<PropertyManager *> 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<int, Kernel::TimeROI> roiMap = timeROIsFromSplitters(splitter);
if (!roiMap.empty()) {
for (size_t i = 0; i < n; i++) {
if (outputs[i]) {
int destinationIndex = static_cast<int>(i);
const Kernel::TimeROI &roi = roiMap.at(destinationIndex);
outputs[i]->setTimeROI(roi);
}
}
}
}

//-----------------------------------------------------------------------------------------------
/**
* Filter the run by the given boolean log. It replaces all time
Expand Down
24 changes: 0 additions & 24 deletions Framework/API/src/Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogManager *> outputs) const {

// std::vector<LogManager *> 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<Run *>(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);
Expand Down
2 changes: 1 addition & 1 deletion Framework/DataObjects/src/TimeSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void TimeSplitter::splitEventList(const EventList &events, std::map<int, EventLi
bool tofCorrect, double factor, double shift) const {

if (events.getEventType() == EventType::WEIGHTED_NOTIME)
throw std::invalid_argument("EventList::splitByTime() called on an EventList "
throw std::invalid_argument("EventList::splitEventList() called on an EventList "
"that no longer has time information.");

// Initialize the detector ID's and event type of the destination event lists
Expand Down
3 changes: 0 additions & 3 deletions Framework/Kernel/inc/MantidKernel/IPropertyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ class MANTID_KERNEL_DLL IPropertyManager {
/// Get the list of managed properties in a given group.
std::vector<Property *> getPropertiesInGroup(const std::string &group) const;

virtual void splitByTime(std::vector<SplittingInterval> & /*splitter*/,
std::vector<PropertyManager *> /* outputs*/) const = 0;

virtual void filterByProperty(const TimeSeriesProperty<bool> & /*filter*/, const std::vector<std::string> &
/* excludedFromFiltering */) = 0;

Expand Down
3 changes: 1 addition & 2 deletions Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SplittingInterval> &splitter, std::vector<Property *> outputs,
bool isProtonCharge = true) const = 0;

/// Return the time series's times as a vector<DateAndTime>
virtual std::vector<Types::Core::DateAndTime> timesAsVector() const = 0;
/** Returns the calculated time weighted average value.
Expand Down
1 change: 0 additions & 1 deletion Framework/Kernel/inc/MantidKernel/PropertyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SplittingInterval> &splitter, std::vector<PropertyManager *> outputs) const override;
void filterByProperty(const TimeSeriesProperty<bool> &filter,
const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>()) override;

Expand Down
5 changes: 0 additions & 5 deletions Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SplittingInterval> & /*splitter*/,
std::vector<PropertyManager *> /* outputs*/) const override {
throw(std::runtime_error("Not yet implmented"));
}

void filterByProperty(const TimeSeriesProperty<bool> & /*filter*/, const std::vector<std::string> &
/* excludedFromFiltering */) override {
throw(std::runtime_error("Not yet implmented"));
Expand Down
4 changes: 0 additions & 4 deletions Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ template <typename TYPE> 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<SplittingInterval> &splitter, std::vector<Property *> outputs,
bool isPeriodic) const override;

/// New split method
void splitByTimeVector(const std::vector<Types::Core::DateAndTime> &splitter_time_vec,
const std::vector<int> &target_vec, const std::vector<TimeSeriesProperty *> &outputs);
Expand Down
39 changes: 0 additions & 39 deletions Framework/Kernel/src/PropertyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SplittingInterval> &splitter,
std::vector<PropertyManager *> 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<Property *> 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<ITimeSeriesProperty *>(prop)) {
timeSeriesProperty->splitByTime(splitter, output_properties, isProtonCharge);
}

} // for each property
}

//-----------------------------------------------------------------------------------------------
/**
* Filter the managed properties by the given boolean property mask. It replaces
Expand Down
118 changes: 1 addition & 117 deletions Framework/Kernel/src/TimeSeriesProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::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) {
Expand All @@ -381,122 +381,6 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::filterByTimes(const Time
m_size = static_cast<int>(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 <typename TYPE>
void TimeSeriesProperty<TYPE>::splitByTime(const std::vector<SplittingInterval> &splitter,
std::vector<Property *> outputs, bool isPeriodic) const {
// 0. Sort if necessary
sortIfNecessary();

if (outputs.empty())
return;

std::vector<TimeSeriesProperty<TYPE> *> 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<TimeSeriesProperty<TYPE> *>(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<int>(numOutputs))
continue;

TimeSeriesProperty<TYPE> *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<TimeSeriesProperty<TYPE> *>(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:
Expand Down
Loading

0 comments on commit 3cdda2c

Please # to comment.