Skip to content

Commit

Permalink
refs #10385. Remove log values
Browse files Browse the repository at this point in the history
This fixes the regression test. We clear the logs off the temporary workspace, that way we don't have to do a similar thing in the loop, and we avoid copying them over each time. This is not a fully formed solution, but it's a start.
  • Loading branch information
OwenArnold committed Oct 30, 2014
1 parent 757b004 commit ab1da07
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h
Expand Up @@ -150,6 +150,8 @@ namespace Mantid
virtual void saveNexus(::NeXus::File * file, const std::string & group,bool keepOpen=false) const;
/// Load the run from a NeXus file with a given group name
virtual void loadNexus(::NeXus::File * file, const std::string & group,bool keepOpen=false);
/// Clear the logs
void clearLogs();

protected:
/// A pointer to a property manager
Expand Down
11 changes: 10 additions & 1 deletion Code/Mantid/Framework/API/src/LogManager.cpp
Expand Up @@ -434,13 +434,22 @@ using namespace Kernel;
if (prop)
{
if (m_manager.existsProperty(prop->name() ))
{
m_manager.removeProperty(prop->name() );
}
m_manager.declareProperty(prop);
}
}
}
if (!(group.empty()||keepOpen))file->closeGroup();

}

/**
* Clear the logs.
*/
void LogManager::clearLogs()
{
m_manager.clear();
}

//-----------------------------------------------------------------------------------------------------------------------
Expand Down
49 changes: 18 additions & 31 deletions Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp
Expand Up @@ -281,6 +281,7 @@ namespace Mantid
double nWorkspaceEntries_d = static_cast<double>(nWorkspaceEntries);

MatrixWorkspace_sptr tempWS2D = boost::dynamic_pointer_cast<MatrixWorkspace>(tempWS);
tempWS2D->mutableRun().clearLogs(); // Strip out any loaded logs.

//PARALLEL_FOR_NO_WSP_CHECK()
for (int p = 1; p <= nWorkspaceEntries; ++p)
Expand All @@ -300,38 +301,12 @@ namespace Mantid
}
else
{



g_log.warning("Reading AS MULTIPERIOD");

/*
// Clone the original workspace
auto cloneAlg = this->createChildAlgorithm("CloneWorkspace");
cloneAlg->setProperty("InputWorkspace", tempWS);
cloneAlg->execute();
local_workspace = cloneAlg->getProperty("OutputWorkspace");
MatrixWorkspace_sptr local_workspace_2d = boost::dynamic_pointer_cast<MatrixWorkspace>(
local_workspace);
// Now overwrite the y, e and log values.
*
*/



MatrixWorkspace_sptr local_workspace_2d = WorkspaceFactory::Instance().create(tempWS2D);
//PARALLEL_FOR_NO_WSP_CHECK()
for (int64_t i = 0; i < int64_t(local_workspace_2d->getNumberHistograms()); ++i)
{
//PARALLEL_START_INTERUPT_REGION

local_workspace_2d->setX(i,tempWS2D->refX(i));


// PARALLEL_END_INTERUPT_REGION
}
// PARALLEL_CHECK_INTERUPT_REGION

for (int64_t i = 0; i < int64_t(local_workspace_2d->getNumberHistograms()); ++i)
{
local_workspace_2d->setX(i, tempWS2D->refX(i));
}


local_workspace = local_workspace_2d;
Expand Down Expand Up @@ -362,7 +337,7 @@ namespace Mantid

for (; histIndex < readStop;)
{
if(histIndex >= readOptimumStop)
if (histIndex >= readOptimumStop)
{
blockSize = finalBlockSize;
}
Expand Down Expand Up @@ -393,6 +368,18 @@ namespace Mantid
}
}

std::string parameterStr;
m_cppFile->openPath(mtdEntry.path());
try
{
// This loads logs, sample, and instrument.
local_workspace_2d->loadSampleAndLogInfoNexus(m_cppFile);
} catch (std::exception & e)
{
g_log.information("Error loading Instrument section of nxs file");
g_log.information(e.what());
}

// TODO deal with this not being a workspace2D

// TODO deal with fractional area.
Expand Down

0 comments on commit ab1da07

Please sign in to comment.