Skip to content

Commit

Permalink
refs #4137 provided for help with coding
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlPalmen committed Nov 28, 2011
1 parent 1664665 commit 47f0292
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
19 changes: 15 additions & 4 deletions Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ None
#include "MantidAPI/WorkspaceOpOverloads.h"
#include "MantidDataHandling/SaveNexusProcessed.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ConfigService.h"
#include "MantidNexus/NexusFileIO.h"
Expand Down Expand Up @@ -209,6 +210,8 @@ namespace DataHandling

MatrixWorkspace_const_sptr matrixWorkspace = boost::dynamic_pointer_cast<const MatrixWorkspace>(inputWorkspace);
ITableWorkspace_const_sptr tableWorkspace = boost::dynamic_pointer_cast<const ITableWorkspace>(inputWorkspace);
PeaksWorkspace_const_sptr peaksWorkspace = boost::dynamic_pointer_cast<const PeaksWorkspace>(inputWorkspace);
if(peaksWorkspace) g_log.debug("We have a peaks workspace");
// check if inputWorkspace is something we know how to save
if (!matrixWorkspace && !tableWorkspace) {
g_log.debug() << "Workspace " << m_title << " not saved because it is not of a type we can presently save.\n";
Expand Down Expand Up @@ -281,11 +284,19 @@ namespace DataHandling
}

} // finish matrix workspace specifics

if (tableWorkspace)

// peaks workspace specifics
if (peaksWorkspace)
{
g_log.information("Peaks Workspace saving to Nexus would be done");
int pNum = peaksWorkspace->getNumberPeaks();
peaksWorkspace->saveNexus( cppFile );

} // finish peaks workspace specifics
else if (tableWorkspace) // Table workspace specifics
{
nexusFile->writeNexusTableWorkspace(tableWorkspace,"table_workspace");
}
nexusFile->writeNexusTableWorkspace(tableWorkspace,"table_workspace");
} // finish table workspace specifics

nexusFile->writeNexusProcessedProcess(inputWorkspace);
nexusFile->closeNexusFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ namespace DataObjects

// ====================================== End ITableWorkspace Methods ==================================

// --- Nexus Methods ---
// Save to Nexus
void PeaksWorkspace::saveNexus(::NeXus::File * file ) const;


};


Expand All @@ -256,6 +261,8 @@ namespace DataObjects
/// Typedef for a shared pointer to a const peaks workspace.
typedef boost::shared_ptr<const PeaksWorkspace> PeaksWorkspace_const_sptr;



}
}
#endif
Expand Down
19 changes: 19 additions & 0 deletions Code/Mantid/Framework/DataObjects/src/PeaksWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "MantidAPI/Column.h"
#include "MantidAPI/ColumnFactory.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidNexusCPP/NeXusFile.hpp"
#include "MantidNexusCPP/NeXusException.hpp"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidDataObjects/PeaksWorkspace.h"
Expand Down Expand Up @@ -232,6 +234,23 @@ namespace DataObjects
return columns[index];
}

void PeaksWorkspace::saveNexus(::NeXus::File * file ) const
{
// This is not fully implemented. Currently a partial save.
int pNum = getNumberPeaks();
//std::vector<Peak>& myPeaks = getPeaks();
std::vector<Peak> my1Peaks = peaks;
// Peak myPeak = getPeak(0);
Peak my1Peak = peaks[0];
int cNum = columnCount();
int rNum = rowCount();
API::Column_const_sptr col = getColumn(0);
std::vector<std::string> cNames = columnNames;
file->makeGroup("detector", "NXdetector", 1);
// file->writeData("Column_names", columnNames ); // This is not resolved by linker
// file->writeData("column names",cNames); // This is not resolved by linker.
// file->writeData( "Column_1", col ); // This is not resolved by linker.
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Geometry/src/Instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ namespace Mantid
}
else
{
std::string imame = comp->getName(); // added for dubugging
nodeQueue.push_back(comp);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Nexus/src/NexusFileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ using namespace DataObjects;
if ( !tableworkspace && !peakworkspace )
return((status==NX_ERROR)?3:0);

if ( !tableworkspace )
return((status==NX_ERROR)?3:0);
// if ( !tableworkspace )
// return((status==NX_ERROR)?3:0);

//write data entry
status=NXmakegroup(fileID,group_name,"NXdata");
Expand Down
Binary file modified Test/AutoTestData/argus0026287.nxs
Binary file not shown.

0 comments on commit 47f0292

Please sign in to comment.