Skip to content

Commit

Permalink
New TimeSeriesProperty constructor. Use TimeROI intersection.
Browse files Browse the repository at this point in the history
  • Loading branch information
bolotovskyr committed May 1, 2023
1 parent f56aaef commit dd4a484
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
3 changes: 0 additions & 3 deletions Framework/API/inc/MantidAPI/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class MANTID_API_DLL LogManager {
/// Copy properties from another LogManager; filter copied time series properties according to TimeROI
void copyAndFilterProperties(const LogManager &other, const Kernel::TimeROI &timeROI);

/// Copy properties from another LogManager; optionally filter copied time series properties according to this TimeROI
void copyProperties(const LogManager &other, const bool filterByTimeROI = false);

/// 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
27 changes: 10 additions & 17 deletions Framework/API/src/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ void LogManager::filterByTime(const Types::Core::DateAndTime start, const Types:
* @param timeROI :: a series of time regions used to determine which time series values should be included in the copy.
*/
LogManager *LogManager::cloneInTimeROI(const Kernel::TimeROI &timeROI) {
LogManager *logMgr = new LogManager();
logMgr->m_manager = std::unique_ptr<PropertyManager>(m_manager->cloneInTimeROI(timeROI));
logMgr->m_timeroi = std::make_unique<Kernel::TimeROI>(timeROI);
return logMgr;
LogManager *newMgr = new LogManager();
newMgr->m_manager = std::unique_ptr<PropertyManager>(m_manager->cloneInTimeROI(timeROI));

// This LogManager object may have filtered some data previously, in which case it would be holding the TimeROI used.
// Therefore, the cloned object's TimeROI should be an intersection of the input TimeROI with the one being held.
TimeROI outputTimeROI(timeROI);
outputTimeROI.update_or_replace_intersection(*m_timeroi);
newMgr->m_timeroi = std::make_unique<Kernel::TimeROI>(outputTimeROI);

return newMgr;
}

/**
Expand All @@ -219,19 +225,6 @@ void LogManager::copyAndFilterProperties(const LogManager &other, const Kernel::
this->clearSingleValueCache();
}

/**
* Copy properties from another LogManager object. Optionally filter time series properties by this object's TimeROI.
* @param other :: another LogManager object.
* @param filterByTimeROI :: a flag indicating whether to filter copied time series properties by TimeROI.
*/
void LogManager::copyProperties(const LogManager &other, const bool filterByTimeROI) {
if (filterByTimeROI) {
this->m_manager = std::unique_ptr<PropertyManager>(other.m_manager->cloneInTimeROI(*m_timeroi));
this->clearSingleValueCache();
} else
this->operator=(other);
}

/**
* For time series properties, remove time values outside of TimeROI regions, each defined as [roi_start,roi_stop).
* However, keep the values immediately before and after each ROI region, if available.
Expand Down
6 changes: 6 additions & 0 deletions Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ template <typename TYPE> class DLLExport TimeSeriesProperty : public Property, p

/// Virtual destructor
~TimeSeriesProperty() override;

private:
/// Construct a TimeSeriesProperty object with the base class data only
TimeSeriesProperty(const Property *const p);

public:
/// "Virtual" copy constructor
TimeSeriesProperty<TYPE> *clone() const override;

Expand Down
22 changes: 9 additions & 13 deletions Framework/Kernel/src/TimeSeriesProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,22 @@ template <typename TYPE> TimeSeriesProperty<TYPE> *TimeSeriesProperty<TYPE>::clo
return new TimeSeriesProperty<TYPE>(*this);
}

/**
* Construct a TimeSeriesProperty object with the base class data only, no time series data.
* @param p :: a pointer to a base class object.
*/
template <typename TYPE>
TimeSeriesProperty<TYPE>::TimeSeriesProperty(const Property *const p)
: Property(*p), m_values(), m_size(), m_propSortedFlag() {}

/**
* Create a partial copy of this object according to a TimeROI. The partially cloned object
* should include all time values enclosed by the ROI regions, each defined as [roi_start,roi_end),
* plus the values immediately before and after an ROI region, if available.
* @param timeROI :: a series of time regions used to determine which values should be included in the copy.
*/
template <typename TYPE> Property *TimeSeriesProperty<TYPE>::cloneInTimeROI(const TimeROI &timeROI) const {
TimeSeriesProperty<TYPE> *filteredTS = new TimeSeriesProperty<TYPE>(this->name());
filteredTS->setDocumentation(this->documentation());
filteredTS->setUnits(this->units());
filteredTS->setRemember(this->remember());
filteredTS->setAutoTrim(this->autoTrim());

// TODO: copy these class members
// filteredTS->m_typeinfo = this->m_typeInfo;
// filteredTS->setDirection(this->direction());
// filteredTS->setGroup(this->getGroup());
// if (this->m_settings)
// filteredTS->m_settings.reset(this->m_settings->clone);

auto filteredTS = new TimeSeriesProperty<TYPE>(this);
createFilteredData(timeROI, filteredTS->m_values);
filteredTS->m_size = static_cast<int>(filteredTS->m_values.size());
return filteredTS;
Expand Down

0 comments on commit dd4a484

Please # to comment.