Skip to content
Snippets Groups Projects
Commit a65f01b8 authored by Russell Taylor's avatar Russell Taylor
Browse files

Merge remote branch 'origin/feature/6999_improve_generateeventsfilter'

parents 6ed110a3 a2c37bbd
No related merge requests found
...@@ -91,8 +91,8 @@ namespace Algorithms ...@@ -91,8 +91,8 @@ namespace Algorithms
void processSingleValueFilter(double minvalue, double maxvalue, void processSingleValueFilter(double minvalue, double maxvalue,
bool filterincrease, bool filterdecrease); bool filterincrease, bool filterdecrease);
void processMultipleValueFilters(double minvalue, double maxvalue, void processMultipleValueFilters(double minvalue, double valueinterval, double maxvalue,
bool filterincrease, bool filterdecrease); bool filterincrease, bool filterdecrease);
void makeFilterByValue(Kernel::TimeSplitterType& split, double min, double max, double TimeTolerance, bool centre, void makeFilterByValue(Kernel::TimeSplitterType& split, double min, double max, double TimeTolerance, bool centre,
bool filterIncrease, bool filterDecrease, Kernel::DateAndTime startTime, Kernel::DateAndTime stopTime, bool filterIncrease, bool filterDecrease, Kernel::DateAndTime startTime, Kernel::DateAndTime stopTime,
......
...@@ -67,6 +67,7 @@ and thus the first splitter will start from the first log time. ...@@ -67,6 +67,7 @@ and thus the first splitter will start from the first log time.
#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceProperty.h" #include "MantidAPI/WorkspaceProperty.h"
#include "MantidAPI/Column.h" #include "MantidAPI/Column.h"
#include "MantidKernel/VisibleWhenProperty.h"
using namespace Mantid; using namespace Mantid;
using namespace Mantid::Kernel; using namespace Mantid::Kernel;
...@@ -127,8 +128,10 @@ namespace Algorithms ...@@ -127,8 +128,10 @@ namespace Algorithms
"Events at or after this time are filtered out."); "Events at or after this time are filtered out.");
// Split by time (only) in steps // Split by time (only) in steps
declareProperty("TimeInterval", -1.0, declareProperty("TimeInterval", EMPTY_DBL(),
"Length of the time splices if filtered in time only."); "Length of the time splices if filtered in time only.");
setPropertySettings("TimeInterval",
new VisibleWhenProperty("LogName", IS_EQUAL_TO, ""));
std::vector<std::string> timeoptions; std::vector<std::string> timeoptions;
timeoptions.push_back("Seconds"); timeoptions.push_back("Seconds");
...@@ -145,12 +148,18 @@ namespace Algorithms ...@@ -145,12 +148,18 @@ namespace Algorithms
"For example, the pulse charge is recorded in 'ProtonCharge'."); "For example, the pulse charge is recorded in 'ProtonCharge'.");
declareProperty("MinimumLogValue", EMPTY_DBL(), "Minimum log value for which to keep events."); declareProperty("MinimumLogValue", EMPTY_DBL(), "Minimum log value for which to keep events.");
setPropertySettings("MinimumLogValue",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
declareProperty("MaximumLogValue", EMPTY_DBL(), "Maximum log value for which to keep events."); declareProperty("MaximumLogValue", EMPTY_DBL(), "Maximum log value for which to keep events.");
setPropertySettings("MaximumLogValue",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
declareProperty("LogValueInterval", EMPTY_DBL(), declareProperty("LogValueInterval", EMPTY_DBL(),
"Delta of log value to be sliced into from min log value and max log value.\n" "Delta of log value to be sliced into from min log value and max log value.\n"
"If not given, then only value "); "If not given, then only value ");
setPropertySettings("LogValueInterval",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
std::vector<std::string> filteroptions; std::vector<std::string> filteroptions;
filteroptions.push_back("Both"); filteroptions.push_back("Both");
...@@ -159,10 +168,14 @@ namespace Algorithms ...@@ -159,10 +168,14 @@ namespace Algorithms
declareProperty("FilterLogValueByChangingDirection", "Both", declareProperty("FilterLogValueByChangingDirection", "Both",
boost::make_shared<Kernel::StringListValidator>(filteroptions), boost::make_shared<Kernel::StringListValidator>(filteroptions),
"d(log value)/dt can be positive and negative. They can be put to different splitters."); "d(log value)/dt can be positive and negative. They can be put to different splitters.");
setPropertySettings("FilterLogValueByChangingDirection",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
declareProperty("TimeTolerance", 0.0, declareProperty("TimeTolerance", 0.0,
"Tolerance in time for the event times to keep. " "Tolerance in time for the event times to keep. "
"It is used in the case to filter by single value."); "It is used in the case to filter by single value.");
setPropertySettings("TimeTolerance",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
vector<string> logboundoptions; vector<string> logboundoptions;
logboundoptions.push_back("Centre"); logboundoptions.push_back("Centre");
...@@ -171,12 +184,13 @@ namespace Algorithms ...@@ -171,12 +184,13 @@ namespace Algorithms
auto logvalidator = boost::make_shared<StringListValidator>(logboundoptions); auto logvalidator = boost::make_shared<StringListValidator>(logboundoptions);
declareProperty("LogBoundary", "Centre", logvalidator, declareProperty("LogBoundary", "Centre", logvalidator,
"How to treat log values as being measured in the centre of time."); "How to treat log values as being measured in the centre of time.");
setPropertySettings("LogBoundary",
new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
declareProperty("LogValueTolerance", EMPTY_DBL(), declareProperty("LogValueTolerance", EMPTY_DBL(),
"Tolerance of the log value to be included in filter. It is used in the case to filter by multiple values."); "Tolerance of the log value to be included in filter. It is used in the case to filter by multiple values.");
setPropertySettings("LogValueTolerance",
declareProperty("LogValueTimeSections", 1, new VisibleWhenProperty("LogName", IS_NOT_EQUAL_TO, ""));
"In one log value interval, it can be further divided into sections in even time slice.");
// Output workspaces' title and name // Output workspaces' title and name
declareProperty("TitleOfSplitters", "", declareProperty("TitleOfSplitters", "",
...@@ -421,20 +435,26 @@ namespace Algorithms ...@@ -421,20 +435,26 @@ namespace Algorithms
{ {
double timeinterval = this->getProperty("TimeInterval"); double timeinterval = this->getProperty("TimeInterval");
bool singleslot = false;
if (timeinterval == EMPTY_DBL()) singleslot = true;
// Progress // Progress
int64_t totaltime = m_stopTime.totalNanoseconds()-m_startTime.totalNanoseconds(); int64_t totaltime = m_stopTime.totalNanoseconds()-m_startTime.totalNanoseconds();
int64_t timeslot = 0;
if (timeinterval <= 0.0) if (singleslot)
{ {
int wsindex = 0; int wsindex = 0;
// Default and thus just one interval // Default and thus just one interval
std::stringstream ss; std::stringstream ss;
ss << "Time Interval From " << m_startTime << " to " << m_stopTime; ss << "Time Interval From " << m_startTime << " to " << m_stopTime;
addNewTimeFilterSplitter(m_startTime, m_stopTime, wsindex, ss.str()); addNewTimeFilterSplitter(m_startTime, m_stopTime, wsindex, ss.str());
} }
else else
{ {
int64_t timeslot = 0;
// Explicitly N time intervals // Explicitly N time intervals
int64_t deltatime_ns = static_cast<int64_t>(timeinterval*m_timeUnitConvertFactorToNS); int64_t deltatime_ns = static_cast<int64_t>(timeinterval*m_timeUnitConvertFactorToNS);
...@@ -571,7 +591,7 @@ namespace Algorithms ...@@ -571,7 +591,7 @@ namespace Algorithms
else else
{ {
// Generate filters for a series of log value // Generate filters for a series of log value
processMultipleValueFilters(minvalue, maxvalue, filterIncrease, filterDecrease); processMultipleValueFilters(minvalue, deltaValue, maxvalue, filterIncrease, filterDecrease);
} }
} }
else else
...@@ -676,16 +696,16 @@ namespace Algorithms ...@@ -676,16 +696,16 @@ namespace Algorithms
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
/** Generate filters from multiple values /** Generate filters from multiple values
* @param minvalue :: minimum value of the allowed log value; * @param minvalue :: minimum value of the allowed log value;
* @param valueinterval :: step of the log value for a series of filter
* @param maxvalue :: maximum value of the allowed log value; * @param maxvalue :: maximum value of the allowed log value;
* @param filterincrease :: if true, log value in the increasing curve should be included; * @param filterincrease :: if true, log value in the increasing curve should be included;
* @param filterdecrease :: if true, log value in the decreasing curve should be included; * @param filterdecrease :: if true, log value in the decreasing curve should be included;
*/ */
void GenerateEventsFilter::processMultipleValueFilters(double minvalue, double maxvalue, void GenerateEventsFilter::processMultipleValueFilters(double minvalue, double valueinterval, double maxvalue,
bool filterincrease, bool filterincrease,
bool filterdecrease) bool filterdecrease)
{ {
// Read more input // Read more input
double valueinterval = this->getProperty("LogValueInterval");
if (valueinterval <= 0) if (valueinterval <= 0)
throw std::invalid_argument("Multiple values filter must have LogValueInterval larger than ZERO."); throw std::invalid_argument("Multiple values filter must have LogValueInterval larger than ZERO.");
double valuetolerance = this->getProperty("LogValueTolerance"); double valuetolerance = this->getProperty("LogValueTolerance");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment