Skip to content

Commit

Permalink
Re #6131. Implemented changes to version 2 muon nexus format.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jan 16, 2013
1 parent c971b31 commit 5c58a0d
Show file tree
Hide file tree
Showing 19 changed files with 1,466 additions and 1,232 deletions.
5 changes: 3 additions & 2 deletions Code/Mantid/Framework/Algorithms/test/AlphaCalcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/GroupDetectors.h"
#include "MantidAPI/IAlgorithm.h"
Expand Down Expand Up @@ -38,6 +38,7 @@ class AlphaCalcTest : public CxxTest::TestSuite

void testCalAlphaManySpectra()
{
//system("pause");
//Load the muon nexus file
loader.initialize();
loader.setPropertyValue("Filename", "emu00006473.nxs");
Expand Down Expand Up @@ -93,7 +94,7 @@ class AlphaCalcTest : public CxxTest::TestSuite

private:
AlphaCalc alphaCalc;
Mantid::DataHandling::LoadMuonNexus loader;
Mantid::DataHandling::LoadMuonNexus2 loader;

};

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Algorithms/test/ApplyDeadTimeCorrTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/GroupDetectors.h"
#include "MantidAPI/IAlgorithm.h"
Expand Down Expand Up @@ -199,7 +199,7 @@ class ApplyDeadTimeCorrTest : public CxxTest::TestSuite

private:
ApplyDeadTimeCorr applyDeadTime;
Mantid::DataHandling::LoadMuonNexus loader;
Mantid::DataHandling::LoadMuonNexus2 loader;
};


Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Algorithms/test/MuonAsymmetryCalcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/GroupDetectors.h"
#include "MantidAPI/IAlgorithm.h"
Expand Down Expand Up @@ -91,7 +91,7 @@ class MuonAsymmetryCalcTest : public CxxTest::TestSuite

private:
MuonAsymmetryCalc asymCalc;
Mantid::DataHandling::LoadMuonNexus loader;
Mantid::DataHandling::LoadMuonNexus2 loader;
Mantid::DataHandling::GroupDetectors group1;
Mantid::DataHandling::GroupDetectors group2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidAlgorithms/MuonRemoveExpDecay.h"
#include "MantidAPI/Workspace.h"
#include "MantidDataObjects/Workspace2D.h"
Expand Down Expand Up @@ -93,7 +93,7 @@ class MuonRemoveExpDecayTest : public CxxTest::TestSuite

private:
MuonRemoveExpDecay alg;
Mantid::DataHandling::LoadMuonNexus loader;
Mantid::DataHandling::LoadMuonNexus2 loader;

};

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Algorithms/test/RemoveBinsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <stdexcept>

#include "MantidAlgorithms/RemoveBins.h"
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/UnitFactory.h"
Expand Down Expand Up @@ -177,7 +177,7 @@ class RemoveBinsTest : public CxxTest::TestSuite

void xtestRealData()
{
Mantid::DataHandling::LoadMuonNexus loader;
Mantid::DataHandling::LoadMuonNexus2 loader;
loader.initialize();
loader.setPropertyValue("Filename", "emu00006473.nxs");
loader.setPropertyValue("OutputWorkspace", "EMU6473");
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ set ( SRC_FILES
src/LoadMaskingFile.cpp
src/LoadMuonLog.cpp
src/LoadMuonNexus.cpp
src/LoadMuonNexus1.cpp
src/LoadMuonNexus2.cpp
src/LoadNXSPE.cpp
src/LoadNexus.cpp
Expand Down Expand Up @@ -196,6 +197,7 @@ set ( INC_FILES
inc/MantidDataHandling/LoadMaskingFile.h
inc/MantidDataHandling/LoadMuonLog.h
inc/MantidDataHandling/LoadMuonNexus.h
inc/MantidDataHandling/LoadMuonNexus1.h
inc/MantidDataHandling/LoadMuonNexus2.h
inc/MantidDataHandling/LoadNXSPE.h
inc/MantidDataHandling/LoadNexus.h
Expand Down Expand Up @@ -322,8 +324,8 @@ set ( TEST_FILES
LoadMappingTableTest.h
LoadMaskTest.h
LoadMuonLogTest.h
LoadMuonNexus1Test.h
LoadMuonNexus2Test.h
LoadMuonNexusTest.h
LoadNXSPETest.h
LoadNexusLogsTest.h
LoadNexusMonitorsTest.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ namespace Mantid
{
/** @class LoadMuonNexus LoadMuonNexus.h DataHandling/LoadMuonNexus.h
Loads an file in Nexus Muon format and stores it in a 2D workspace
(Workspace2D class). LoadMuonNexus is an algorithm and as such inherits
from the Algorithm class, via DataHandlingCommand, and overrides
the init() & exec() methods.
It is a base class for loadres for versions 1 and 2 of the muon nexus file format.
It implements property initialization and some common for both versions methods.
Required Properties:
<UL>
Expand Down Expand Up @@ -77,19 +75,20 @@ namespace Mantid
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Nexus;Muon"; }

/// do a quick check that this file can be loaded
/// do a quick check that this file can be loaded
virtual bool quickFileCheck(const std::string& filePath,size_t nread,const file_header& header);
/// check the structure of the file and return a value between 0 and 100 of how much this file can be loaded
virtual int fileCheck(const std::string& filePath);
protected:
/// Overwrites Algorithm method
void exec();

virtual void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr) {}
void checkOptionalProperties();
void runLoadInstrument(DataObjects::Workspace2D_sptr);

/// The name and path of the input file
std::string m_filename;
/// The first top-level entry name in the file
std::string m_entry_name;
/// The instrument name from Nexus
std::string m_instrument_name;
/// The sample name read from Nexus
Expand Down Expand Up @@ -120,13 +119,6 @@ namespace Mantid
virtual void initDocs();
/// Overwrites Algorithm method.
void init();

void loadData(const MantidVecPtr::ptr_type& tcbs,size_t hist, specid_t& i,
MuonNexusReader& nxload, const int64_t lengthIn, DataObjects::Workspace2D_sptr localWorkspace);
void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr);
void runLoadMappingTable(DataObjects::Workspace2D_sptr);
void runLoadLog(DataObjects::Workspace2D_sptr);
void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace);
};

} // namespace DataHandling
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#ifndef MANTID_DATAHANDLING_LOADMUONNEXUS1_H_
#define MANTID_DATAHANDLING_LOADMUONNEXUS1_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/System.h"
#include "MantidAPI/SpectraDetectorMap.h"

#include <napi.h>
//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
class MuonNexusReader;

namespace Mantid
{
namespace DataHandling
{
/** @class LoadMuonNexus LoadMuonNexus.h DataHandling/LoadMuonNexus.h
Loads an file in Nexus Muon format version 1 and stores it in a 2D workspace
(Workspace2D class). LoadMuonNexus is an algorithm and as such inherits
from the Algorithm class, via DataHandlingCommand, and overrides
the init() & exec() methods.
Required Properties:
<UL>
<LI> Filename - The name of and path to the input NeXus file </LI>
<LI> OutputWorkspace - The name of the workspace in which to store the imported data
(a multiperiod file will store higher periods in workspaces called OutputWorkspace_PeriodNo)
[ not yet implemented for Nexus ]</LI>
</UL>
Optional Properties: (note that these options are not available if reading a multiperiod file)
<UL>
<LI> spectrum_min - The spectrum to start loading from</LI>
<LI> spectrum_max - The spectrum to load to</LI>
<LI> spectrum_list - An ArrayProperty of spectra to load</LI>
<LI> auto_group - Determines whether the spectra are automatically grouped together based on the groupings in the NeXus file. </LI>
</UL>
Copyright &copy; 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadMuonNexus1 : public LoadMuonNexus
{
public:
/// Default constructor
LoadMuonNexus1();
/// Destructor
virtual ~LoadMuonNexus1() {}
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "LoadMuonNexus"; }
/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Nexus;Muon"; }

/// check the structure of the file and return a value between 0 and 100 of how much this file can be loaded
virtual int fileCheck(const std::string& filePath);
protected:
/// Overwrites Algorithm method
void exec();
/// Implement the base class method
void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr);

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();

void loadData(const MantidVecPtr::ptr_type& tcbs,size_t hist, specid_t& i,
MuonNexusReader& nxload, const int64_t lengthIn, DataObjects::Workspace2D_sptr localWorkspace);
void runLoadMappingTable(DataObjects::Workspace2D_sptr);
void runLoadLog(DataObjects::Workspace2D_sptr);
void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace);
};

} // namespace DataHandling
} // namespace Mantid

#endif /*MANTID_DATAHANDLING_LOADMUONNEXUS1_H_*/
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,12 @@

namespace Mantid
{
namespace NeXus
{
// Forward declarations
template<class T>
class NXDataSetTyped;
typedef NXDataSetTyped<int> NXInt;
}


namespace DataHandling
{
// Forward declarations
template<class T>
class NXDataSetTyped;
typedef NXDataSetTyped<int> NXInt;

/**
Loads an file in NeXus Muon format and stores it in a 2D workspace
Loads an file in NeXus Muon format version 1 and 2 and stores it in a 2D workspace
(Workspace2D class). LoadMuonNexus is an algorithm and as such inherits
from the Algorithm class, via DataHandlingCommand, and overrides
the init() & exec() methods.
Expand Down Expand Up @@ -82,15 +70,15 @@ namespace NeXus
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Nexus;Muon"; }

/// do a quick check that this file can be loaded
virtual bool quickFileCheck(const std::string& filePath,size_t nread,const file_header& header);
/// check the structure of the file and return a value between 0 and 100 of how much this file can be loaded
virtual int fileCheck(const std::string& filePath);
private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
/// Overwrites Algorithm method
void exec();
/// Execute this version of the algorithm
void doExec();

void loadData(const Mantid::NeXus::NXInt& counts,const std::vector<double>& timeBins,int wsIndex,
int period,int spec,API::MatrixWorkspace_sptr localWorkspace);
Expand Down

0 comments on commit 5c58a0d

Please sign in to comment.