Mantid
Loading...
Searching...
No Matches
LogManager.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
14#include "MantidNexus/NexusFile.h"
15
16namespace Mantid::API {
17
18using namespace Kernel;
19using namespace Types::Core;
20
21namespace {
23Logger g_log("LogManager");
24
25const std::string START_TIME_NAME("start_time");
26const std::string END_TIME_NAME("end_time");
27
29template <typename T> bool convertSingleValue(const Property *property, double &value) {
30 if (auto log = dynamic_cast<const PropertyWithValue<T> *>(property)) {
31 value = static_cast<double>(*log);
32 return true;
33 } else {
34 return false;
35 }
36}
37
38bool convertSingleValueToDouble(const Property *property, double &value) {
39 // Order these with double and int first, and less likely options later.
40 // The first one to succeed short-circuits and the value is returned.
41 // If all fail, returns false.
42 return convertSingleValue<double>(property, value) || convertSingleValue<int32_t>(property, value) ||
43 convertSingleValue<int64_t>(property, value) || convertSingleValue<uint32_t>(property, value) ||
44 convertSingleValue<uint64_t>(property, value) || convertSingleValue<float>(property, value);
45}
46
48template <typename T>
49bool convertTimeSeriesToDouble(const Property *property, double &value, const Math::StatisticType &function,
50 const Kernel::TimeROI *timeRoi = nullptr) {
51 if (const auto *log = dynamic_cast<const ITimeSeriesProperty *>(property)) {
52 value = log->extractStatistic(function, timeRoi);
53 return true;
54 } else {
55 return false;
56 }
57}
58
60template <typename T>
61bool convertPropertyToDouble(const Property *property, double &value, const Math::StatisticType &function,
62 const Kernel::TimeROI *timeRoi = nullptr) {
63 return convertSingleValue<T>(property, value) || convertTimeSeriesToDouble<T>(property, value, function, timeRoi);
64}
65
67bool convertPropertyToDouble(const Property *property, double &value, const Math::StatisticType &function,
68 const Kernel::TimeROI *timeRoi = nullptr) {
69 // Order these with double and int first, and less likely options later.
70 // The first one to succeed short-circuits and the value is returned.
71 // If all fail, returns false.
72 return convertPropertyToDouble<double>(property, value, function, timeRoi) ||
73 convertPropertyToDouble<int32_t>(property, value, function, timeRoi) ||
74 convertPropertyToDouble<int64_t>(property, value, function, timeRoi) ||
75 convertPropertyToDouble<uint32_t>(property, value, function, timeRoi) ||
76 convertPropertyToDouble<uint64_t>(property, value, function, timeRoi) ||
77 convertPropertyToDouble<float>(property, value, function, timeRoi);
78}
79} // namespace
80
83const std::string LogManager::PROTON_CHARGE_LOG_NAME = "gd_prtn_chrg";
85
86//----------------------------------------------------------------------
87// Public member functions
88//----------------------------------------------------------------------
89
91 : m_manager(std::make_unique<Kernel::PropertyManager>()), m_timeroi(std::make_unique<Kernel::TimeROI>()),
92 m_singleValueCache(
93 std::make_unique<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>>()) {}
94
96 : m_manager(std::make_unique<Kernel::PropertyManager>(*other.m_manager)),
97 m_timeroi(std::make_unique<Kernel::TimeROI>(*other.m_timeroi)),
98 m_singleValueCache(std::make_unique<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>>(
99 *other.m_singleValueCache)) {}
100
101// Defined as default in source for forward declaration with std::unique_ptr.
102LogManager::~LogManager() = default;
103
105 *m_manager = *other.m_manager;
106 *m_timeroi = *other.m_timeroi;
107 m_singleValueCache = std::make_unique<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>>(
108 *other.m_singleValueCache);
109 return *this;
110}
111
117void LogManager::setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end) {
118 this->addProperty<std::string>(START_TIME_NAME, start.toISO8601String(), true);
119 this->addProperty<std::string>(END_TIME_NAME, end.toISO8601String(), true);
120}
121
130const Types::Core::DateAndTime LogManager::startTime() const {
131 if (hasProperty(START_TIME_NAME)) {
132 try {
133 DateAndTime start_time(getProperty(START_TIME_NAME)->value());
134 if (start_time != DateAndTime::GPS_EPOCH) {
135 return start_time;
136 }
137 } catch (std::invalid_argument &) { /*Swallow and move on*/
138 }
139 }
140
141 const std::string run_start_prop("run_start");
142 if (hasProperty(run_start_prop)) {
143 try {
144 DateAndTime start_time(getProperty(run_start_prop)->value());
145 if (start_time != DateAndTime::GPS_EPOCH) {
146 return start_time;
147 }
148 } catch (std::invalid_argument &) { /*Swallow and move on*/
149 }
150 }
151
152 std::string errorMsg{"No valid start time has been set for this run."};
153 if (hasValidProtonChargeLog(errorMsg))
154 return getFirstPulseTime();
155
156 throw std::runtime_error(errorMsg);
157}
158
166const Types::Core::DateAndTime LogManager::endTime() const {
167 if (hasProperty(END_TIME_NAME)) {
168 try {
169 return DateAndTime(getProperty(END_TIME_NAME)->value());
170 } catch (std::invalid_argument &) { /*Swallow and move on*/
171 }
172 }
173
174 const std::string run_end_prop("run_end");
175 if (hasProperty(run_end_prop)) {
176 try {
177 return DateAndTime(getProperty(run_end_prop)->value());
178 } catch (std::invalid_argument &) { /*Swallow and move on*/
179 }
180 }
181
182 std::string errorMsg{"No valid end time has been set for this run."};
183 if (hasValidProtonChargeLog(errorMsg))
184 return getLastPulseTime();
185
186 throw std::runtime_error(errorMsg);
187}
188
190 std::string temp;
191 return hasProperty(START_TIME_NAME) || hasProperty("run_start") || hasValidProtonChargeLog(temp);
192}
193
195 std::string temp;
196 return hasProperty(END_TIME_NAME) || hasProperty("run_end") || hasValidProtonChargeLog(temp);
197}
198
205const DateAndTime LogManager::getFirstPulseTime() const {
206 const TimeSeriesProperty<double> *log =
207 getTimeSeriesProperty<double>("proton_charge"); // guaranteed to be a valid pointer, if the call succeeds
208 if (log->realSize() == 0)
209 throw std::runtime_error("First pulse time is not available. Log \"proton_charge\" is empty.");
210
211 // NOTE, this method has been migrated from MatrixWorkspace class, where it had a comment:
212 // "Pulse times before 1991 (up to 100) are skipped. This is to avoid
213 // a DAS bug at SNS around Mar 2011 where the first pulse time is Jan 1, 1990."
214 // There was no explanation why 100 was picked as the maximum number of times to skip.
215 // In the refactored algorithm below we keep 100 as is.
216 const DateAndTime reference("1991-01-01T00:00:00");
217 const std::vector<DateAndTime> &times = log->timesAsVector();
218 const size_t maxSkip{100};
219 const size_t maxIndex = std::min(static_cast<size_t>(log->realSize()), maxSkip);
220 const auto it = std::find_if(times.cbegin(), times.cbegin() + maxIndex,
221 [&reference](const auto &time) { return time >= reference; });
222 if (it != times.cbegin() + maxIndex) {
223 return *it;
224 }
225 return times[maxIndex - 1];
226}
227
234const DateAndTime LogManager::getLastPulseTime() const {
235 const TimeSeriesProperty<double> *log =
236 getTimeSeriesProperty<double>("proton_charge"); // guaranteed to be a valid pointer, if the call succeeds
237 if (log->realSize() == 0)
238 throw std::runtime_error("Last pulse time is not available. Log \"proton_charge\" is empty.");
239 return log->lastTime();
240}
241
248 const std::string log_name{"proton_charge"};
249 if (!hasProperty(log_name)) {
250 error += " Log " + log_name + " is not found.";
251 return false;
252 }
253
254 Kernel::Property *prop = getProperty(log_name);
256 if (!(log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(prop))) {
257 error += " Log " + log_name + " is not a time series of floating-point values.";
258 return false;
259 }
260
261 if (log->realSize() == 0) {
262 error += " Log " + log_name + " is empty.";
263 return false;
264 }
265
266 return true;
267}
268
269//-----------------------------------------------------------------------------------------------
277void LogManager::filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop) {
278 this->setTimeROI(TimeROI(start, stop));
280}
281
290 LogManager *newMgr = new LogManager();
291 newMgr->m_manager = std::unique_ptr<PropertyManager>(m_manager->cloneInTimeROI(timeROI));
292
293 // This LogManager object may have filtered out some data previously, in which case it would be holding the TimeROI
294 // used. Therefore, the cloned object's TimeROI should be an intersection of the input TimeROI with the one being
295 // held.
296 TimeROI outputTimeROI(timeROI);
298 newMgr->m_timeroi = std::make_unique<Kernel::TimeROI>(outputTimeROI);
299
300 return newMgr;
301}
302
309 this->m_manager = std::unique_ptr<PropertyManager>(other.m_manager->cloneInTimeROI(timeROI));
310 this->setTimeROI(timeROI);
311 this->clearSingleValueCache();
312}
313
320 m_manager->removeDataOutsideTimeROI(*m_timeroi);
321 this->clearSingleValueCache();
322}
323
324//----------------------------------------------------------------------------------------------
332void LogManager::filterByLog(Mantid::Kernel::LogFilter *filter, const std::vector<std::string> &excludedFromFiltering) {
333 // This will invalidate the cache
334 this->clearSingleValueCache();
335 m_manager->filterByProperty(filter, excludedFromFiltering);
336}
337
338//-----------------------------------------------------------------------------------------------
347void LogManager::addProperty(std::unique_ptr<Kernel::Property> prop, bool overwrite) {
348 // Make an exception for the proton charge
349 // and overwrite its value as we don't want to store the proton charge in two
350 // separate locations
351 // Similar we don't want more than one run_title
352 std::string name = prop->name();
353 if (hasProperty(name) && (overwrite || prop->name() == PROTON_CHARGE_LOG_NAME || prop->name() == "run_title")) {
355 }
356 m_manager->declareProperty(std::move(prop), "");
357}
358
359//-----------------------------------------------------------------------------------------------
365bool LogManager::hasProperty(const std::string &name) const { return m_manager->existsProperty(name); }
366
367//-----------------------------------------------------------------------------------------------
374void LogManager::removeProperty(const std::string &name, bool delProperty) {
375 // Remove any cached entries for this log. Need to make this more general
376 for (unsigned int stat = 0; stat < 7; ++stat) {
377 m_singleValueCache->removeCache(std::make_pair(name, static_cast<Math::StatisticType>(stat)));
378 }
379 m_manager->removeProperty(name, delProperty);
380}
381
386const std::vector<Kernel::Property *> &LogManager::getProperties() const { return m_manager->getProperties(); }
387
388//-----------------------------------------------------------------------------------------------
392 size_t total{m_timeroi->getMemorySize()};
393
394 for (const auto &p : m_manager->getProperties()) {
395 if (p) {
396 // cppcheck-suppress useStlAlgorithm
397 total += p->getMemorySize() + sizeof(Property *); // cppcheck-suppress useStlAlgorithm
398 }
399 }
400
401 return total;
402}
403
411template <typename T> Kernel::TimeSeriesProperty<T> *LogManager::getTimeSeriesProperty(const std::string &name) const {
413 if (auto *tsp = dynamic_cast<Kernel::TimeSeriesProperty<T> *>(prop)) {
414 return tsp;
415 } else {
416 throw std::invalid_argument("LogManager::getTimeSeriesProperty - '" + name + "' is not a TimeSeriesProperty");
417 }
418}
419
425double LogManager::getTimeAveragedStd(const std::string &name) const {
427}
428
434double LogManager::getTimeAveragedValue(const std::string &name) const { return getStatistics(name).time_mean; }
435
445 const Kernel::Property *prop = getProperty(name);
446
447 // statistics from a TimeSeriesProperty object
448 if (auto *timeSeriesProp = dynamic_cast<const Kernel::ITimeSeriesProperty *>(prop))
449 return timeSeriesProp->getStatistics(m_timeroi.get());
450
451 // statistics from a PropertyWithValue object
452 double value;
453 if (Mantid::API::convertSingleValueToDouble(prop, value))
455
456 // return values set to NAN, signaling no statistics can be obtained
458 invalid.setAllToNan();
459 return invalid;
460}
461
468template <typename HeldType> HeldType LogManager::getPropertyValueAsType(const std::string &name) const {
470 if (auto *valueProp = dynamic_cast<Kernel::PropertyWithValue<HeldType> *>(prop)) {
471 return (*valueProp)();
472 } else {
473 throw std::invalid_argument("Run::getPropertyValueAsType - '" + name + "' is not of the requested type");
474 }
475}
476
485double LogManager::getPropertyAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic) const {
486 double singleValue(0.0);
487 const auto key = std::make_pair(name, statistic);
488 if (!m_singleValueCache->getCache(key, singleValue)) {
489 const Property *log = getProperty(name);
490 const TimeROI &filter = this->getTimeROI();
491 if (!convertPropertyToDouble(log, singleValue, statistic, &filter)) {
492 if (const auto stringLog = dynamic_cast<const PropertyWithValue<std::string> *>(log)) {
493 // Try to lexically cast string to a double
494 try {
495 singleValue = std::stod(stringLog->value());
496 } catch (const std::invalid_argument &) {
497 throw std::invalid_argument("Run::getPropertyAsSingleValue - Property \"" + name +
498 "\" cannot be converted to a numeric value.");
499 }
500 } else {
501 throw std::invalid_argument("Run::getPropertyAsSingleValue - Property \"" + name +
502 "\" is not a single numeric value or numeric time series.");
503 }
504 }
505 // Put it in the cache
506 m_singleValueCache->setCache(key, singleValue);
507 }
508 return singleValue;
509}
510
518int LogManager::getPropertyAsIntegerValue(const std::string &name) const {
519 int singleValue(0);
520 double discard(0);
521
522 Property *prop = getProperty(name);
523
524 if (convertSingleValue<int32_t>(prop, discard) || convertSingleValue<int64_t>(prop, discard) ||
525 convertSingleValue<uint32_t>(prop, discard) || convertSingleValue<uint64_t>(prop, discard)) {
526 singleValue = std::stoi(prop->value());
527 } else {
528 throw std::invalid_argument("Run::getPropertyAsIntegerValue - Property \"" + name +
529 "\" cannot be converted to an integer value.");
530 }
531
532 return singleValue;
533}
534
541Kernel::Property *LogManager::getProperty(const std::string &name) const { return m_manager->getProperty(name); }
542
550 auto &props = getProperties();
551
552 // Loop over the set of properties, identifying those that are time-series
553 // properties
554 // and then clearing them out.
555 for (auto prop : props) {
556 if (auto tsp = dynamic_cast<ITimeSeriesProperty *>(prop)) {
557 tsp->clear();
558 }
559 }
560}
561
567 auto &props = getProperties();
568 for (auto prop : props) {
569 if (auto tsp = dynamic_cast<ITimeSeriesProperty *>(prop)) {
570 tsp->clearOutdated();
571 }
572 }
573}
574
575const Kernel::TimeROI &LogManager::getTimeROI() const { return *(m_timeroi.get()); }
576
578 m_timeroi->replaceROI(timeroi);
579 this->clearSingleValueCache();
580}
581
582//--------------------------------------------------------------------------------------------
589void LogManager::saveNexus(Nexus::File *file, const std::string &group, bool keepOpen) const {
590 file->makeGroup(group, "NXgroup", true);
591 file->putAttr("version", 1);
592
593 // Save all the properties as NXlog
594 std::vector<Property *> props = m_manager->getProperties();
595 for (auto &prop : props) {
596 try {
597 prop->saveProperty(file);
598 } catch (std::invalid_argument &exc) {
599 g_log.warning(exc.what());
600 }
601 }
602 // save the timeROI to the nexus file
603 if (!(m_timeroi->useAll()))
604 m_timeroi->saveNexus(file);
605
606 if (!keepOpen)
607 file->closeGroup();
608}
609
610//--------------------------------------------------------------------------------------------
621void LogManager::loadNexus(Nexus::File * /*file*/, const std::string & /*group*/,
622 const Nexus::NexusDescriptor & /*fileInfo*/, const std::string & /*prefix*/,
623 bool /*keepOpen*/) {
624 throw std::runtime_error("LogManager::loadNexus should not be used");
625}
626
627//--------------------------------------------------------------------------------------------
636void LogManager::loadNexus(Nexus::File *file, const std::string &group, bool keepOpen) {
637 if (!group.empty()) {
638 file->openGroup(group, "NXgroup");
639 }
640 std::map<std::string, std::string> entries;
641 file->getEntries(entries);
642 LogManager::loadNexus(file, entries);
643
644 if (!(group.empty() || keepOpen)) {
645 file->closeGroup();
646 }
647}
648
649void LogManager::loadNexus(Nexus::File *file, const Nexus::NexusDescriptor &fileInfo, const std::string &prefix) {
650
651 // Only load from NXlog entries
652 const auto &allEntries = fileInfo.getAllEntries();
653 auto itNxLogEntries = allEntries.find("NXlog");
654 const auto nxLogEntries = (itNxLogEntries != allEntries.end()) ? itNxLogEntries->second : std::set<std::string>{};
655
656 const auto levels = std::count(prefix.begin(), prefix.end(), '/');
657
658 auto itLower = nxLogEntries.lower_bound(prefix);
659
660 if (itLower == nxLogEntries.end()) {
661 return;
662 }
663 if (itLower->compare(0, prefix.size(), prefix) != 0) {
664 return;
665 }
666
667 for (auto it = itLower; it != nxLogEntries.end() && it->compare(0, prefix.size(), prefix) == 0; ++it) {
668 // only next level entries
669 const std::string &absoluteEntryName = *it;
670 if (std::count(absoluteEntryName.begin(), absoluteEntryName.end(), '/') != levels + 1) {
671 continue;
672 }
673 const std::string nameClass = absoluteEntryName.substr(absoluteEntryName.find_last_of('/') + 1);
674
675 auto prop = PropertyNexus::loadProperty(file, nameClass, fileInfo, prefix);
676 if (prop) {
677 // get TimeROI
678 if (prop->name() == Kernel::TimeROI::NAME) {
679 auto boolProp = dynamic_cast<TimeSeriesProperty<bool> *>(prop.get());
680 if (boolProp) {
681 m_timeroi->replaceROI(boolProp);
682 } else {
683 throw std::runtime_error("Kernel_TimeROI is not a TimeSeriesPropertyBool");
684 }
685 } else {
686 // everything else gets added to the list of properties
687 m_manager->declareOrReplaceProperty(std::move(prop));
688 }
689 }
690 }
691}
692
693//--------------------------------------------------------------------------------------------
700void LogManager::loadNexus(Nexus::File *file, const std::map<std::string, std::string> &entries) {
701
702 for (const auto &name_class : entries) {
703 // NXLog types are the main one.
704 if (name_class.second == "NXlog") {
705 auto prop = PropertyNexus::loadProperty(file, name_class.first);
706 if (prop) {
707 // get TimeROI
708 if (prop->name() == Kernel::TimeROI::NAME) {
709 auto boolProp = dynamic_cast<TimeSeriesProperty<bool> *>(prop.get());
710 if (boolProp) {
711 m_timeroi->replaceROI(boolProp);
712 } else {
713 throw std::runtime_error("Kernel_TimeROI is not a TimeSeriesPropertyBool");
714 }
715 } else {
716 // everything else gets added to the list of properties
717 m_manager->declareOrReplaceProperty(std::move(prop));
718 }
719 }
720 }
721 }
722}
723
728
730
733std::string LogManager::getInvalidValuesFilterLogName(const std::string &logName) {
735}
736
738bool LogManager::hasInvalidValuesFilter(const std::string &logName) const {
740}
741
744 try {
745 auto log = getLogData(getInvalidValuesFilterLogName(logName));
746 if (auto tsp = dynamic_cast<TimeSeriesProperty<bool> *>(log)) {
747 return tsp;
748 }
749 } catch (Exception::NotFoundError &) {
750 // do nothing, just drop through tto the return line below
751 }
752 return nullptr;
753}
754
755bool LogManager::operator==(const LogManager &other) const {
756 return (*m_manager == *(other.m_manager)) && (*m_timeroi == *(other.m_timeroi));
757}
758
759bool LogManager::operator!=(const LogManager &other) const {
760 return (*m_timeroi != *(other.m_timeroi)) || (*m_manager != *(other.m_manager));
761}
762
763//-----------------------------------------------------------------------------------------------------------------------
764// Private methods
765//-----------------------------------------------------------------------------------------------------------------------
766
769#define INSTANTIATE(TYPE) \
770 template MANTID_API_DLL Kernel::TimeSeriesProperty<TYPE> *LogManager::getTimeSeriesProperty(const std::string &) \
771 const; \
772 template MANTID_API_DLL TYPE LogManager::getPropertyValueAsType(const std::string &) const;
773
774INSTANTIATE(double)
775INSTANTIATE(int32_t)
776INSTANTIATE(int64_t)
777INSTANTIATE(uint32_t)
778INSTANTIATE(uint64_t)
779INSTANTIATE(std::string)
780INSTANTIATE(bool)
781
782template MANTID_API_DLL uint16_t LogManager::getPropertyValueAsType(const std::string &) const;
783template MANTID_API_DLL std::vector<double> LogManager::getPropertyValueAsType(const std::string &) const;
784template MANTID_API_DLL std::vector<size_t> LogManager::getPropertyValueAsType(const std::string &) const;
785template MANTID_API_DLL std::vector<int> LogManager::getPropertyValueAsType(const std::string &) const;
786template MANTID_API_DLL std::vector<long> LogManager::getPropertyValueAsType(const std::string &) const;
789} // namespace Mantid::API
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
double error
#define INSTANTIATE(TYPE)
This class contains the information about the log entries.
Definition LogManager.h:44
double getTimeAveragedStd(const std::string &name) const
Get the time averaged standard deviation for a log.
bool operator!=(const LogManager &other) const
virtual size_t getMemorySize() const
Return an approximate memory size for the object in bytes.
virtual void removeDataOutsideTimeROI()
For the time series properties, remove values according to TimeROI.
const Types::Core::DateAndTime endTime() const
Return the run end time.
virtual void setTimeROI(const Kernel::TimeROI &timeroi)
bool hasProperty(const std::string &name) const
Does the property exist on the object.
const Kernel::TimeROI & getTimeROI() const
void copyAndFilterProperties(const LogManager &other, const Kernel::TimeROI &timeROI)
Copy properties from another LogManager; filter copied time series properties according to TimeROI.
const std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
Definition LogManager.h:146
double getTimeAveragedValue(const std::string &name) const
Get the time averaged value for a log.
std::unique_ptr< Kernel::PropertyManager > m_manager
A pointer to a property manager.
Definition LogManager.h:217
Kernel::TimeSeriesPropertyStatistics getStatistics(const std::string &name) const
Returns various statistics computations for a given property.
Kernel::TimeSeriesProperty< bool > * getInvalidValuesFilter(const std::string &logName) const
returns the invalid values log if the log has a matching invalid values log filter
const Types::Core::DateAndTime startTime() const
Return the run start time.
void clearOutdatedTimeSeriesLogValues()
Empty all but the last value out of all TimeSeriesProperty logs.
void clearSingleValueCache()
Clear the cache of calculated statistics.
virtual ~LogManager()
Destructor.
int getPropertyAsIntegerValue(const std::string &name) const
Returns a property as an integer value.
std::unique_ptr< Kernel::Cache< std::pair< std::string, Kernel::Math::StatisticType >, double > > m_singleValueCache
Cache for the retrieved single values.
Definition LogManager.h:228
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
const Types::Core::DateAndTime getFirstPulseTime() const
Return the first pulse time from sample logs.
void removeProperty(const std::string &name, bool delProperty=true)
Remove a named property.
virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop)
Filter the logs by time.
static const std::string PROTON_CHARGE_LOG_NAME
Name of the log entry containing the proton charge when retrieved using getProtonCharge.
Definition LogManager.h:221
const std::vector< Kernel::Property * > & getProperties() const
Return all of the current properties.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition LogManager.h:91
double getPropertyAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Returns a property as a single double value from its name.
static std::string getInvalidValuesFilterLogName(const std::string &logName)
Gets the correct log name for the matching invalid values log for a given log name.
LogManager * cloneInTimeROI(const Kernel::TimeROI &timeROI)
Create a new LogManager with a partial copy of its time series properties according to TimeROI.
void clearTimeSeriesLogs()
Empty the values out of all TimeSeriesProperty logs.
virtual void saveNexus(Nexus::File *file, const std::string &group, bool keepOpen=false) const
Save the run to a NeXus file with a given group name.
LogManager & operator=(const LogManager &other)
bool operator==(const LogManager &other) const
std::unique_ptr< Kernel::TimeROI > m_timeroi
Definition LogManager.h:218
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
void clearLogs()
Clear the logs.
bool hasValidProtonChargeLog(std::string &error) const
Check if the proton_charge log exists, is of valid type, and is not empty.
Kernel::TimeSeriesProperty< T > * getTimeSeriesProperty(const std::string &name) const
Returns a property as a time series property.
static const std::string PROTON_CHARGE_UNFILTERED_LOG_NAME
Flag to signify if a filter has been applied to the proton charge log.
Definition LogManager.h:223
virtual void loadNexus(Nexus::File *file, const std::string &group, const Mantid::Nexus::NexusDescriptor &fileInfo, const std::string &prefix, bool keepOpen=false)
Load the run from a NeXus file with a given group name. Overload that uses NexusDescriptor for faster...
bool hasInvalidValuesFilter(const std::string &logName) const
returns true if the log has a matching invalid values log filter
void filterByLog(Mantid::Kernel::LogFilter *filter, const std::vector< std::string > &excludedFromFiltering=std::vector< std::string >())
Filter the run by the given log filter.
const Types::Core::DateAndTime getLastPulseTime() const
Return the last pulse time from sample logs.
void setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end)
Set the run start and end.
Cache is a generic caching storage class.
Definition Cache.h:27
Exception for when an item is not found in a collection.
Definition Exception.h:145
A non-templated interface to a TimeSeriesProperty.
This class is for filtering TimeSeriesProperty data.
Definition LogFilter.h:32
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
Property manager helper class.
static std::string getInvalidValuesFilterLogName(const std::string &logName)
Gets the correct log name for the matching invalid values log for a given log name.
The concrete, templated class for properties.
Base class for properties.
Definition Property.h:94
virtual std::string value() const =0
Returns the value of the property as a string.
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
void replaceROI(const TimeSeriesProperty< bool > *roi)
Definition TimeROI.cpp:386
static const std::string NAME
the underlying property needs a name
Definition TimeROI.h:21
void update_or_replace_intersection(const TimeROI &other)
If this is empty, replace it with the supplied TimeROI, otherwise calculate the intersection.
Definition TimeROI.cpp:548
A specialised Property class for holding a series of time-value pairs.
Types::Core::DateAndTime lastTime() const
Returns the last time.
std::vector< Types::Core::DateAndTime > timesAsVector() const override
Return the time series's times as a vector<DateAndTime>
int realSize() const override
Returns the real size of the time series property map:
const std::map< std::string, std::set< std::string > > & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.
Kernel::Logger g_log("ExperimentInfo")
static logger object
StatisticType
Maps a "statistic" to a number.
Definition Statistics.h:18
DLLExport std::unique_ptr< Property > loadProperty(Nexus::File *file, const std::string &group, const Nexus::NexusDescriptor &fileInfo, const std::string &prefix)
Opens a NXlog group in a nexus file and creates the correct Property object from it.
STL namespace.
Struct holding some useful statistics for a TimeSeriesProperty.
double time_standard_deviation
time weighted standard deviation