diff --git a/Framework/MDAlgorithms/src/MDWSDescription.cpp b/Framework/MDAlgorithms/src/MDWSDescription.cpp index 6203fcab08221f707a431c33de2787bbc412dc93..5b6801aa10ab68e9072f6b72ec8e804052bc6add 100644 --- a/Framework/MDAlgorithms/src/MDWSDescription.cpp +++ b/Framework/MDAlgorithms/src/MDWSDescription.cpp @@ -355,29 +355,18 @@ void MDWSDescription::fillAddProperties( size_t nDimPropNames = dimPropertyNames.size(); if (AddCoord.size() != nDimPropNames) AddCoord.resize(nDimPropNames); + const auto &runObj = inWS2D->run(); for (size_t i = 0; i < nDimPropNames; i++) { - // HACK: A METHOD, Which converts TSP into value, correspondent to time - // scale of matrix workspace has to be developed and deployed! - Kernel::Property *pProperty = - (inWS2D->run().getProperty(dimPropertyNames[i])); - Kernel::TimeSeriesProperty<double> *run_property = - dynamic_cast<Kernel::TimeSeriesProperty<double> *>(pProperty); - if (run_property) { - AddCoord[i] = coord_t(run_property->firstValue()); - } else { - // e.g Ei can be a property and dimension - Kernel::PropertyWithValue<double> *proc_property = - dynamic_cast<Kernel::PropertyWithValue<double> *>(pProperty); - if (!proc_property) { - std::string ERR = - " Can not interpret property, used as dimension.\n Property: " + - dimPropertyNames[i] + - " is neither a time series (run) property " - "nor a property with value<double>"; - throw(std::invalid_argument(ERR)); - } - AddCoord[i] = coord_t(*(proc_property)); + try { + const double value = runObj.getLogAsSingleValue( + dimPropertyNames[i], Mantid::Kernel::Math::TimeAveragedMean); + AddCoord[i] = static_cast<coord_t>(value); + } catch (std::invalid_argument &) { + std::string ERR = + " Can not interpret property, used as dimension.\n Property: " + + dimPropertyNames[i] + " cannot be converted into a double."; + throw(std::invalid_argument(ERR)); } } } diff --git a/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h b/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h index c57a700d6f3fd517b5005d42ea80c5dec231185e..fed9171f0709cd504c774c3b6878d4d8d9334c1b 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h @@ -193,9 +193,8 @@ public: TS_ASSERT_THROWS_NOTHING(alg.execute();); TS_ASSERT(alg.isExecuted()); // Check the results - - TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), "0.12187,9.99"); - TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), "0.126745,9.99"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), "0.12187,7.69667"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), "0.126745,7.69667"); // Remove workspace from the data service. Mantid::API::AnalysisDataService::Instance().remove(WSName); } @@ -249,6 +248,8 @@ private: Mantid::Geometry::OrientedLattice latt(2, 3, 4, 90, 90, 90); ws->mutableSample().setOrientedLattice(&latt); + // time average value of this is the simple average + // of the first three values = 7.69667 Mantid::Kernel::TimeSeriesProperty<double> *p = new Mantid::Kernel::TimeSeriesProperty<double>("doubleProp"); TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:00", 9.99)); diff --git a/docs/source/release/v3.14.0/framework.rst b/docs/source/release/v3.14.0/framework.rst index 935a994d705f8ef67d9bc17d377006bf4d26ff88..4b91ecc32b2cfc684fc246b66120c1945f736083 100644 --- a/docs/source/release/v3.14.0/framework.rst +++ b/docs/source/release/v3.14.0/framework.rst @@ -82,6 +82,7 @@ Bugfixes - Fixed a crash in :ref:`MaskDetectors <algm-MaskDetectors>` when a non-existent component was given in ``ComponentList``. - History for algorithms that took groups sometimes would get incorrect history causing history to be incomplete, so now full group history is saved for all items belonging to the group. - Fixed a bug in `SetGoniometer <algm-SetGoniometer>` where it would use the mean log value rather than the time series average value for goniometer angles. +- `ConvertToMD <algm-ConvertToMD>` now uses the time-average value for logs when using them as ``OtherDimensions`` Python