Skip to content
Snippets Groups Projects
Commit dde47003 authored by William F Godoy's avatar William F Godoy
Browse files

Rebase master

parent fb0baecd
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,8 @@ public: ...@@ -32,7 +32,8 @@ public:
/// Required to pass m_fileInfo to static functions /// Required to pass m_fileInfo to static functions
/// Keeping it shared_ptr to match setFileInfo signature (although passing /// Keeping it shared_ptr to match setFileInfo signature (although passing
/// ownership is not the main goal). /// ownership is not the main goal).
virtual std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor> getFileInfo(); virtual const std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor>
getFileInfo() const noexcept;
virtual int virtual int
confidence(Kernel::NexusHDF5Descriptor &descriptor) const override = 0; confidence(Kernel::NexusHDF5Descriptor &descriptor) const override = 0;
......
...@@ -37,8 +37,8 @@ void NexusFileLoader::setFileInfo( ...@@ -37,8 +37,8 @@ void NexusFileLoader::setFileInfo(
m_fileInfo = std::move(fileInfo); m_fileInfo = std::move(fileInfo);
} }
std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor> const std::shared_ptr<Mantid::Kernel::NexusHDF5Descriptor>
NexusFileLoader::getFileInfo() { NexusFileLoader::getFileInfo() const noexcept {
return m_fileInfo; return m_fileInfo;
} }
......
...@@ -439,10 +439,7 @@ void LoadNexusLogs::execLoader() { ...@@ -439,10 +439,7 @@ void LoadNexusLogs::execLoader() {
// match for 2nd level entry /a/b // match for 2nd level entry /a/b
if (std::count(entry.begin(), entry.end(), '/') == 2) { if (std::count(entry.begin(), entry.end(), '/') == 2) {
if (isLog) { if (isLog) {
const std::string group_name = loadLogs(file, entry, group_class, workspace);
entry.substr(entry.find_last_of("/") + 1);
loadLogs(file, group_name, group_class, workspace);
// loadLogs(file, entry, group_class, workspace);
} else { } else {
loadNPeriods(file, workspace); loadNPeriods(file, workspace);
} }
...@@ -466,8 +463,7 @@ void LoadNexusLogs::execLoader() { ...@@ -466,8 +463,7 @@ void LoadNexusLogs::execLoader() {
continue; continue;
} }
// here we must search only in NxLogs and NXpositioner sets // here we must search only in NxLogs and NXpositioner sets
loadLogs(file, group_name, group_class, workspace); loadLogs(file, absoluteGroupName, group_class, workspace);
// loadLogs(file, absoluteGroupName, group_class, workspace);
} }
}; };
...@@ -479,8 +475,6 @@ void LoadNexusLogs::execLoader() { ...@@ -479,8 +475,6 @@ void LoadNexusLogs::execLoader() {
// If there's title information, load that info as logs. // If there's title information, load that info as logs.
loadAndApplyRunTitle(&file, *workspace); loadAndApplyRunTitle(&file, *workspace);
// TODO: remove
std::map<std::string, std::string> entries = file.getEntries();
// Freddie Akeroyd 12/10/2011 // Freddie Akeroyd 12/10/2011
// current ISIS implementation contains an additional indirection between // current ISIS implementation contains an additional indirection between
// collected frames via an // collected frames via an
...@@ -682,21 +676,43 @@ void LoadNexusLogs::loadNPeriods( ...@@ -682,21 +676,43 @@ void LoadNexusLogs::loadNPeriods(
* @param workspace :: A pointer to the workspace to store the logs * @param workspace :: A pointer to the workspace to store the logs
*/ */
void LoadNexusLogs::loadLogs( void LoadNexusLogs::loadLogs(
::NeXus::File &file, const std::string &entry_name, ::NeXus::File &file, const std::string &absolute_entry_name,
const std::string &entry_class, const std::string &entry_class,
const std::shared_ptr<API::MatrixWorkspace> &workspace) const { const std::shared_ptr<API::MatrixWorkspace> &workspace) const {
file.openGroup(entry_name, entry_class);
std::map<std::string, std::string> entries = file.getEntries(); const std::map<std::string, std::set<std::string>> &allEntries =
std::map<std::string, std::string>::const_iterator iend = entries.end(); getFileInfo()->getAllEntries();
for (std::map<std::string, std::string>::const_iterator itr = entries.begin();
itr != iend; ++itr) { auto lf_LoadByLogClass = [&](const std::string &logClass,
std::string log_class = itr->second; const bool isNxLog) {
if (log_class == "NXlog" || log_class == "NXpositioner") { auto itLogClass = allEntries.find(logClass);
loadNXLog(file, itr->first, log_class, workspace); if (itLogClass == allEntries.end()) {
} else if (log_class == "IXseblock") { return;
loadSELog(file, itr->first, workspace);
} }
} const std::set<std::string> &logsSet = itLogClass->second;
auto itPrefixBegin = logsSet.lower_bound(absolute_entry_name);
for (auto it = itPrefixBegin;
it != logsSet.end() &&
it->compare(0, absolute_entry_name.size(), absolute_entry_name) == 0;
++it) {
// must be third level entry
if (std::count(it->begin(), it->end(), '/') == 3) {
if (isNxLog) {
loadNXLog(file, *it, logClass, workspace);
} else {
loadSELog(file, *it, workspace);
}
}
}
};
const std::string entry_name =
absolute_entry_name.substr(absolute_entry_name.find_last_of("/") + 1);
file.openGroup(entry_name, entry_class);
lf_LoadByLogClass("NXlog", true);
lf_LoadByLogClass("NXpositioner", true);
lf_LoadByLogClass("IXseblock", false);
loadVetoPulses(file, workspace); loadVetoPulses(file, workspace);
file.closeGroup(); file.closeGroup();
...@@ -711,21 +727,50 @@ void LoadNexusLogs::loadLogs( ...@@ -711,21 +727,50 @@ void LoadNexusLogs::loadLogs(
* @param workspace :: A pointer to the workspace to store the logs * @param workspace :: A pointer to the workspace to store the logs
*/ */
void LoadNexusLogs::loadNXLog( void LoadNexusLogs::loadNXLog(
::NeXus::File &file, const std::string &entry_name, ::NeXus::File &file, const std::string &absolute_entry_name,
const std::string &entry_class, const std::string &entry_class,
<<<<<<< HEAD
const std::shared_ptr<API::MatrixWorkspace> &workspace) const { const std::shared_ptr<API::MatrixWorkspace> &workspace) const {
g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n"; g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n";
=======
const boost::shared_ptr<API::MatrixWorkspace> &workspace) const {
>>>>>>> Refactored LoadNexusLogs
const std::string entry_name =
absolute_entry_name.substr(absolute_entry_name.find_last_of("/") + 1);
g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n";
file.openGroup(entry_name, entry_class); file.openGroup(entry_name, entry_class);
// Validate the NX log class. // Validate the NX log class.
std::map<std::string, std::string> entries = file.getEntries(); // Just verify that time and value entries exist
if ((entries.find("value") == entries.end()) || const std::string timeEntry = absolute_entry_name + "/time";
(entries.find("time") == entries.end())) { const std::string valueEntry = absolute_entry_name + "/value";
bool foundValue = false;
bool foundTime = false;
const std::map<std::string, std::set<std::string>> &allEntries =
getFileInfo()->getAllEntries();
// reverse search to take advantage of the fact that these are located in SDS
for (auto it = allEntries.rbegin(); it != allEntries.rend(); ++it) {
const std::set<std::string> &entriesSet = it->second;
if (entriesSet.count(timeEntry) == 1) {
foundTime = true;
}
if (entriesSet.count(valueEntry) == 1) {
foundValue = true;
}
if (foundTime && foundValue) {
break;
}
}
if (!foundTime || !foundValue) {
g_log.warning() << "Invalid NXlog entry " << entry_name g_log.warning() << "Invalid NXlog entry " << entry_name
<< " found. Did not contain 'value' and 'time'.\n"; << " found. Did not contain 'value' and 'time'.\n";
file.closeGroup(); file.closeGroup();
return; return;
} }
// whether or not to overwrite logs on workspace // whether or not to overwrite logs on workspace
bool overwritelogs = this->getProperty("OverwriteLogs"); bool overwritelogs = this->getProperty("OverwriteLogs");
try { try {
...@@ -750,9 +795,17 @@ void LoadNexusLogs::loadNXLog( ...@@ -750,9 +795,17 @@ void LoadNexusLogs::loadNXLog(
* @param workspace :: A pointer to the workspace to store the logs * @param workspace :: A pointer to the workspace to store the logs
*/ */
void LoadNexusLogs::loadSELog( void LoadNexusLogs::loadSELog(
<<<<<<< HEAD
::NeXus::File &file, const std::string &entry_name, ::NeXus::File &file, const std::string &entry_name,
const std::shared_ptr<API::MatrixWorkspace> &workspace) const { const std::shared_ptr<API::MatrixWorkspace> &workspace) const {
// Open the entry // Open the entry
=======
::NeXus::File &file, const std::string &absolute_entry_name,
const boost::shared_ptr<API::MatrixWorkspace> &workspace) const {
const std::string entry_name =
absolute_entry_name.substr(absolute_entry_name.find_last_of("/") + 1);
>>>>>>> Refactored LoadNexusLogs
file.openGroup(entry_name, "IXseblock"); file.openGroup(entry_name, "IXseblock");
std::string propName = entry_name; std::string propName = entry_name;
if (workspace->run().hasProperty(propName)) { if (workspace->run().hasProperty(propName)) {
...@@ -762,9 +815,28 @@ void LoadNexusLogs::loadSELog( ...@@ -762,9 +815,28 @@ void LoadNexusLogs::loadSELog(
// value_log - A time series entry. This can contain a corrupt value entry // value_log - A time series entry. This can contain a corrupt value entry
// so if it does use the value one // so if it does use the value one
// value - A single value float entry // value - A single value float entry
const std::string valueEntry = absolute_entry_name + "/value";
const std::string valueLogEntry = absolute_entry_name + "/value_log";
bool foundValue = false;
bool foundValueLog = false;
const std::map<std::string, std::set<std::string>> &allEntries =
getFileInfo()->getAllEntries();
for (auto it = allEntries.rbegin(); it != allEntries.rend(); ++it) {
const std::set<std::string> &entriesSet = it->second;
if (entriesSet.count(valueEntry) == 1) {
foundValue = true;
}
if (entriesSet.count(valueLogEntry) == 1) {
foundValueLog = true;
// takes precedence
break;
}
}
std::unique_ptr<Kernel::Property> logValue; std::unique_ptr<Kernel::Property> logValue;
const auto entries = file.getEntries(); if (foundValueLog) {
if (entries.find("value_log") != entries.end()) {
try { try {
try { try {
file.openGroup("value_log", "NXlog"); file.openGroup("value_log", "NXlog");
...@@ -785,7 +857,7 @@ void LoadNexusLogs::loadSELog( ...@@ -785,7 +857,7 @@ void LoadNexusLogs::loadSELog(
file.closeGroup(); // entry_name file.closeGroup(); // entry_name
return; return;
} }
} else if (entries.find("value") != entries.end()) { } else if (foundValue) {
try { try {
// This may have a larger dimension than 1 bit it has no time field so // This may have a larger dimension than 1 bit it has no time field so
// take the first entry // take the first entry
......
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