Skip to content

Commit

Permalink
Added check for all times being the same. refs #6760
Browse files Browse the repository at this point in the history
If the total duration of the differences of the log values
is 0.0 then just use the first log value.
  • Loading branch information
stuartcampbell committed Mar 22, 2013
1 parent 8024211 commit 866f882
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ namespace Mantid

if ( m_extractSingleValueAs.compare("mean" ) == 0 )
{
logData->eliminateDuplicates();
extractedValue = timeMean(logData);
}
else if(bUsingStandardStatistics)
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/Kernel/src/LogParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ namespace Mantid
*/
double timeMean(const Kernel::Property* p)
{
Kernel::TimeSeriesProperty<double>* dp = dynamic_cast<Kernel::TimeSeriesProperty<double>*>(p);
const Kernel::TimeSeriesProperty<double>* dp = dynamic_cast<const Kernel::TimeSeriesProperty<double>*>(p);
if (!dp)
{
throw std::runtime_error("Property of a wrong type. Cannot be cast to a TimeSeriesProperty<double>.");
Expand All @@ -370,7 +370,6 @@ namespace Mantid
}
double res = 0.;
Kernel::time_duration total(0,0,0,0);

size_t dp_size = dp->size();
for(size_t i=0;i<dp_size;i++)
{
Expand All @@ -382,6 +381,9 @@ namespace Mantid

double total_seconds = Kernel::DateAndTime::secondsFromDuration(total);

// If all the time stamps were the same, just return the first value.
if (total_seconds == 0.0 ) res = dp->nthValue(1);

if (total_seconds > 0) res /= total_seconds;

return res;
Expand Down

0 comments on commit 866f882

Please sign in to comment.