Skip to content

Commit

Permalink
Refs #4367: CompressNexus in SaveNexusProcessed for EventWorkspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Dec 28, 2011
1 parent 5cfc454 commit e97a152
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ namespace DataHandling
"For EventWorkspaces, preserve the events when saving (default).\n"
"If false, will save the 2D histogram version of the workspace with the current binning parameters.");
setPropertySettings("PreserveEvents", new EnabledWhenWorkspaceIsType<EventWorkspace>(this, "InputWorkspace", true));

declareProperty("CompressNexus", false,
"For EventWorkspaces, compress the Nexus data field (default False).\n"
"This will make smaller files but takes much longer.");
setPropertySettings("CompressNexus", new EnabledWhenWorkspaceIsType<EventWorkspace>(this, "InputWorkspace", true));

}


Expand Down Expand Up @@ -457,10 +463,12 @@ namespace DataHandling
}
PARALLEL_CHECK_INTERUPT_REGION

/*Default = DONT compress - much faster*/
bool CompressNexus = getProperty("CompressNexus");

// Write out to the NXS file.
nexusFile->writeNexusProcessedDataEventCombined(m_eventWorkspace, indices, tofs, weights, errorSquareds, pulsetimes,
false /*DONT compress - much faster*/);
CompressNexus);

// Free mem.
delete [] tofs;
Expand Down Expand Up @@ -489,4 +497,4 @@ namespace DataHandling
}

} // namespace DataHandling
} // namespace Mantid
} // namespace Mantid
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,12 @@ class SaveNexusProcessedTest : public CxxTest::TestSuite
* @param makeDifferentTypes :: mix event types
* @param clearfiles :: clear files after saving
* @param PreserveEvents :: save as event list
* @param CompressNexus :: compress
* @return
*/
static EventWorkspace_sptr do_testExec_EventWorkspaces(std::string filename_root, EventType type,
std::string & outputFile, bool makeDifferentTypes, bool clearfiles,
bool PreserveEvents=true)
bool PreserveEvents=true, bool CompressNexus=false)
{
std::vector< std::vector<int> > groups(5);
groups[0].push_back(10);
Expand Down Expand Up @@ -291,6 +292,7 @@ class SaveNexusProcessedTest : public CxxTest::TestSuite
outputFile = alg.getPropertyValue("Filename");
alg.setPropertyValue("Title", title);
alg.setProperty("PreserveEvents", PreserveEvents);
alg.setProperty("CompressNexus", CompressNexus);

// Clear the existing file, if any
if( Poco::File(outputFile).exists() ) Poco::File(outputFile).remove();
Expand Down Expand Up @@ -334,6 +336,11 @@ class SaveNexusProcessedTest : public CxxTest::TestSuite
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_EventTo2D", TOF, outputFile, false, clearfiles, false /* DONT preserve events */);
}
void testExec_EventWorkspace_CompressNexus()
{
std::string outputFile;
do_testExec_EventWorkspaces("SaveNexusProcessed_EventTo2D", TOF, outputFile, false, clearfiles, true /* DONT preserve events */, true /* Compress */);
}

void xtestExec_LoadedEventWorkspace() /** Disabled because it takes >3 seconds */
{
Expand Down

0 comments on commit e97a152

Please sign in to comment.