Skip to content

Commit

Permalink
Merge branch 'master' into feature/10470_grouped_dets_sxdnorm
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/Framework/MDAlgorithms/src/MDNormSXD.cpp
Refs #10470
  • Loading branch information
martyngigg committed Nov 21, 2014
2 parents c724725 + 385d9aa commit 972c75d
Show file tree
Hide file tree
Showing 30 changed files with 3,898 additions and 2,074 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mantid-developer
Version: 1.4
Version: 1.5
Release: 1%{?dist}
Summary: Meta Package to install dependencies for Mantid Development

Expand All @@ -19,6 +19,7 @@ Requires: git-all
Requires: gsl-devel
Requires: hdf-devel
Requires: hdf5-devel
Requires: jsoncpp-devel
Requires: muParser-devel
Requires: mxml-devel
Requires: nexus >= 4.2
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h
Original file line number Diff line number Diff line change
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
38 changes: 0 additions & 38 deletions Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceValidators.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,44 +369,6 @@ class DLLExport IncreasingAxisValidator : public MatrixWorkspaceValidator
}
};

//===============================================================================================
/**
* A validator which checks whether data in each spectrum of the input workspace are monotonically increasing.
*/
class DLLExport IncreasingDataValidator : public MatrixWorkspaceValidator
{
public:
///Gets the type of the validator
std::string getType() const { return "increasingdata"; }
/// Clone the current state
Kernel::IValidator_sptr clone() const { return boost::make_shared<IncreasingDataValidator>(*this); }

private:
/** Validate a workspace.
* @param value :: The workspace to test
* @return A message for users with negative results, otherwise ""
*/
std::string checkValidity( const MatrixWorkspace_sptr& value ) const
{
if ( value->blocksize() < 2 )
{
return "Spectra must have two or more data points (bins).";
}
for(size_t spec = 0; spec < value->getNumberHistograms(); ++spec)
{
auto &Y = value->readY( spec );
double y = Y.front();
for(auto it = Y.begin() + 1; it != Y.end(); ++it)
{
if ( y > *it ) return "Data in the workspace must monotonically increase.";
y = *it;
}
}
return "";
}

};

} // namespace API
} // namespace Mantid

Expand Down
11 changes: 10 additions & 1 deletion Code/Mantid/Framework/API/src/LogManager.cpp
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ set ( SRC_FILES
src/SaveParameterFile.cpp
src/SaveRKH.cpp
src/SaveReflTBL.cpp
src/SaveReflThreeColumnAscii.cpp
src/SaveSPE.cpp
src/SaveToSNSHistogramNexus.cpp
src/SaveVTK.cpp
Expand Down Expand Up @@ -277,6 +278,7 @@ set ( INC_FILES
inc/MantidDataHandling/SaveParameterFile.h
inc/MantidDataHandling/SaveRKH.h
inc/MantidDataHandling/SaveReflTBL.h
inc/MantidDataHandling/SaveReflThreeColumnAscii.h
inc/MantidDataHandling/SaveSPE.h
inc/MantidDataHandling/SaveToSNSHistogramNexus.h
inc/MantidDataHandling/SaveVTK.h
Expand Down Expand Up @@ -411,6 +413,7 @@ set ( TEST_FILES
SaveParameterFileTest.h
SaveRKHTest.h
SaveReflTBLTest.h
SaveReflThreeColumnAsciiTest.h
SaveSPETest.h
SaveToSNSHistogramNexusTest.h
SetSampleMaterialTest.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ namespace Mantid
virtual void extraProps() = 0;
/// write any extra information required
virtual void extraHeaders(std::ofstream & file) = 0;
/// write the main content of the data
virtual void data(std::ofstream & file, const std::vector<double> & XData);

/// Overwrites Algorithm method.
void init();
/// Overwrites Algorithm method
Expand All @@ -77,8 +76,11 @@ namespace Mantid
protected:
/// Return the separator character
virtual char sep() {return '\t';}
/// write the main content of the data
virtual void data(std::ofstream & file, const std::vector<double> & XData, bool exportDeltaQ = true);
double m_qres;
size_t m_xlength;

API::MatrixWorkspace_const_sptr m_ws;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//----------------------------------------------------------------------
#include "MantidAPI/IFileLoader.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"

#include "MantidNexus/NexusClasses.h"
#include <nexus/NeXusFile.hpp>
Expand All @@ -15,6 +16,7 @@ namespace Mantid

namespace DataHandling
{

/**
Loads a workspace from a NeXus Processed entry in a NeXus file.
Expand Down Expand Up @@ -155,6 +157,9 @@ namespace Mantid

/// calculates the workspace size
std::size_t calculateWorkspacesize(const std::size_t numberofspectra);

/// Accellerated multiperiod loading
Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(Mantid::NeXus::NXRoot & root, const std::string & entryName, Mantid::API::MatrixWorkspace_sptr& tempMatrixWorkspace, const int64_t nWorkspaceEntries, const int64_t i);

/// Does the current workspace have uniform binning
bool m_shared_bins;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef MANTID_DATAHANDLING_SaveReflCustomAscii_H_
#define MANTID_DATAHANDLING_SaveReflCustomAscii_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/AsciiPointBase.h"

namespace Mantid
{
namespace DataHandling
{
/**
Saves a file in ILL Cosmos format from a 2D workspace
(Workspace2D class). SaveILLCosmosAscii is an algorithm but inherits frrm the
AsciiPointBase class which provides the main implementation for the init() & exec() methods.
Output is tab delimited Ascii point data with dq/q and extra header information.
Copyright &copy; 2007-14 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 SaveReflCustomAscii : public DataHandling::AsciiPointBase
{
public:
/// Default constructor
SaveReflCustomAscii() {}
/// Destructor
~SaveReflCustomAscii() {}
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "SaveReflCustomAscii"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Saves a 2D workspace to a ascii file.";}
/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }


///
void data(std::ofstream & file, const std::vector<double> & XData, bool exportDeltaQ);

private:

/// Return the file extension this algorthm should output.
virtual std::string ext() {return ".dat";}
///extra properties specifically for this
virtual void extraProps();
/// write any extra information required
virtual void extraHeaders(std::ofstream & file);
};
} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_SaveReflCustomAscii_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#ifndef MANTID_DATAHANDLING_SAVEREFLTHREECOLUMNASCII_H_
#define MANTID_DATAHANDLING_SAVEREFLTHREECOLUMNASCII_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/AsciiPointBase.h"

namespace Mantid
{
namespace DataHandling
{
/**
Saves a file in three column format from a 2D workspace
(Workspace2D class). SaveReflThreeColumnAscii is an algorithm but inherits from the
AsciiPointBase class which provides the main implementation for the init() & exec() methods.
Output is tab delimited Ascii point data without dq/q and with extra header information.
Copyright &copy; 2007-14 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 SaveReflThreeColumnAscii : public DataHandling::AsciiPointBase
{
public:
/// Default constructor
SaveReflThreeColumnAscii() {}
/// Destructor
~SaveReflThreeColumnAscii() {}
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "SaveReflThreeColumnAscii"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Saves a 2D workspace to a ascii file.";}
/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }
///Algorithm's version for data output overriding a virtual method
void data(std::ofstream & file, const std::vector<double> & XData, bool exportDeltaQ = false);

private:

/// Return the file extension this algorthm should output.
virtual std::string ext() {return ".dat";}
///extra properties specifically for this
virtual void extraProps();
/// write any extra information required
virtual void extraHeaders(std::ofstream & file);
};
} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_SAVEREFLTHREECOLUMNASCII_H_ */
32 changes: 24 additions & 8 deletions Code/Mantid/Framework/DataHandling/src/AsciiPointBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,38 @@ namespace Mantid
/** virtual method to add information to the file before the data
* @param file :: pointer to output file stream
* @param XData :: pointer to a std::vector<double> containing the point data to be printed
* @param exportDeltaQ :: bool on whether deltaQ column to be printed
*/
void AsciiPointBase::data(std::ofstream & file, const std::vector<double> & XData)
void AsciiPointBase::data(std::ofstream & file, const std::vector<double> & XData, bool exportDeltaQ)
{

const std::vector<double> & yData = m_ws->readY(0);
const std::vector<double> & eData = m_ws->readE(0);
for (size_t i = 0; i < m_xlength; ++i)
if (exportDeltaQ)
{
double dq = XData[i]*m_qres;
outputval(XData[i], file, leadingSep());
outputval(yData[i], file);
outputval(eData[i], file);
outputval(dq, file);
file << std::endl;
for (size_t i = 0; i < m_xlength; ++i)
{
double dq = XData[i]*m_qres;
outputval(XData[i], file, leadingSep());
outputval(yData[i], file);
outputval(eData[i], file);
outputval(dq, file);
file << std::endl;
}
}
else
{
for (size_t i = 0; i < m_xlength; ++i)
{
outputval(XData[i], file, leadingSep());
outputval(yData[i], file);
outputval(eData[i], file);
file << std::endl;
}
}
}


/** writes a properly formatted line of data
* @param val :: the double value to be written
* @param file :: pointer to output file stream
Expand Down

0 comments on commit 972c75d

Please sign in to comment.