Skip to content

Commit

Permalink
Merge 'origin/master' into feature/8538_icat_publish_dois. Refs #8538.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Apr 8, 2014
2 parents f968514 + 602d6bc commit 85af503
Show file tree
Hide file tree
Showing 178 changed files with 4,217 additions and 1,314 deletions.
15 changes: 12 additions & 3 deletions Code/Mantid/Framework/API/inc/MantidAPI/IDomainCreator.h
Expand Up @@ -15,6 +15,7 @@ namespace Mantid
{
class FunctionDomain;
class IFunctionValues;
class Workspace;
}

namespace API
Expand Down Expand Up @@ -89,12 +90,20 @@ namespace Mantid
/// @param function :: A pointer to the fitting function
/// @param domain :: The domain containing x-values for the function
/// @param values :: A FunctionValues instance containing the fitting data
virtual void createOutputWorkspace(
/// @param outputWorkspacePropertyName :: Name of the property to declare and set to the created output workspace.
/// If empty do not create the property, just return a pointer
/// @return A shared pointer to the created workspace.
virtual boost::shared_ptr<API::Workspace> createOutputWorkspace(
const std::string& baseName,
API::IFunction_sptr function,
boost::shared_ptr<API::FunctionDomain> domain,
boost::shared_ptr<API::IFunctionValues> values)
{UNUSED_ARG(baseName);UNUSED_ARG(function);UNUSED_ARG(domain);UNUSED_ARG(values);}
boost::shared_ptr<API::IFunctionValues> values,
const std::string& outputWorkspacePropertyName = "OutputWorkspace"
)
{
UNUSED_ARG(baseName);UNUSED_ARG(function);UNUSED_ARG(domain);UNUSED_ARG(values);UNUSED_ARG(outputWorkspacePropertyName);
throw std::logic_error("Method createOutputWorkspace() isn't implemented");
}

/// Initialize the function
/// @param function :: A function to initialize.
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h
Expand Up @@ -116,6 +116,9 @@ class IMDWorkspace;
/// Find neighbouring indexes.
virtual std::vector<size_t> findNeighbourIndexes() const = 0;

/// Get the linear index.
virtual size_t getLinearIndex() const = 0;

protected:
/// Normalization method for getNormalizedSignal()
Mantid::API::MDNormalization m_normalization;
Expand Down
Expand Up @@ -83,6 +83,8 @@ namespace API

virtual std::vector<size_t> findNeighbourIndexes() const;

virtual size_t getLinearIndex() const;

private:
void calcWorkspacePos(size_t newWI);

Expand Down
Expand Up @@ -54,6 +54,12 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
virtual void function(const FunctionDomain& domain, FunctionValues& values)const;
/// Derivatives of function with respect to active parameters
virtual void functionDeriv(const FunctionDomain& domain, Jacobian& jacobian);
/// Called at the start of each iteration
virtual void iterationStarting();
/// Called at the end of an iteration
virtual void iterationFinished();
/// Create a list of equivalent functions
virtual std::vector<IFunction_sptr> createEquivalentFunctions() const;

/// Associate a function and a domain
void setDomainIndex(size_t funIndex, size_t domainIndex);
Expand All @@ -63,6 +69,8 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
void clearDomainIndices();
/// Get the largest domain index
size_t getMaxIndex() const {return m_maxIndex;}
/// Get domain indices for a member function
void getDomainIndices(size_t i, size_t nDomains, std::vector<size_t>& domains)const;

/// Returns the number of attributes associated with the function
virtual size_t nLocalAttributes()const {return 1;}
Expand All @@ -80,7 +88,6 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
/// Counts number of the domains
void countNumberOfDomains();
void countValueOffsets(const CompositeDomain& domain)const;
void getFunctionDomains(size_t i, const CompositeDomain& cd, std::vector<size_t>& domains)const;

/// Domain index map: finction -> domain
std::map<size_t, std::vector<size_t> > m_domains;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/CatalogManager.cpp
Expand Up @@ -55,7 +55,7 @@ namespace Mantid
}

// If we reached this point then the session is corrupt/invalid.
throw std::runtime_error("The session ID you have provided is invalid");
throw std::runtime_error("The session ID you have provided is invalid.");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/IFunction.cpp
Expand Up @@ -1024,7 +1024,7 @@ void IFunction::convertValue(std::vector<double>& values, Kernel::Unit_sptr& out
{
// Get l1, l2 and theta (see also RemoveBins.calculateDetectorPosition())
Instrument_const_sptr instrument = ws->getInstrument();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if (sample == NULL)
{
g_log.error() << "No sample defined instrument. Cannot convert units for function\n"
Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Expand Up @@ -752,8 +752,8 @@ namespace Mantid
{
Instrument_const_sptr instrument = getInstrument();

Geometry::IObjComponent_const_sptr source = instrument->getSource();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
Geometry::IComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if ( source == NULL || sample == NULL )
{
throw Kernel::Exception::InstrumentDefinitionError("Instrument not sufficiently defined: failed to get source and/or sample");
Expand All @@ -778,8 +778,8 @@ namespace Mantid
*/
double MatrixWorkspace::detectorTwoTheta(Geometry::IDetector_const_sptr det) const
{
Geometry::IObjComponent_const_sptr source = getInstrument()->getSource();
Geometry::IObjComponent_const_sptr sample = getInstrument()->getSample();
Geometry::IComponent_const_sptr source = getInstrument()->getSource();
Geometry::IComponent_const_sptr sample = getInstrument()->getSample();
if ( source == NULL || sample == NULL )
{
throw Kernel::Exception::InstrumentDefinitionError("Instrument not sufficiently defined: failed to get source and/or sample");
Expand Down Expand Up @@ -1556,7 +1556,7 @@ namespace Mantid
try
{
Geometry::Instrument_const_sptr inst = this->getInstrument();
Geometry::IObjComponent_const_sptr sample = inst->getSample();
Geometry::IComponent_const_sptr sample = inst->getSample();
if (sample)
{
Kernel::V3D sample_pos = sample->getPos();
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/API/src/MatrixWorkspaceMDIterator.cpp
Expand Up @@ -311,6 +311,11 @@ namespace API
throw std::runtime_error("MatrixWorkspaceMDIterator does not implement findNeighbourIndexes");
}

size_t MatrixWorkspaceMDIterator::getLinearIndex() const
{
throw std::runtime_error("MatrixWorkspaceMDIterator does not implement getLinearIndex");
}


} // namespace Mantid
} // namespace API
85 changes: 81 additions & 4 deletions Code/Mantid/Framework/API/src/MultiDomainFunction.cpp
Expand Up @@ -80,13 +80,16 @@ namespace API

/**
* Populates a vector with domain indices assigned to function i.
* @param i :: Index of a function to get the domain info about.
* @param nDomains :: Maximum number of domains.
* @param domains :: (Output) vector to collect domain indixes.
*/
void MultiDomainFunction::getFunctionDomains(size_t i, const CompositeDomain& cd, std::vector<size_t>& domains)const
void MultiDomainFunction::getDomainIndices(size_t i, size_t nDomains, std::vector<size_t>& domains)const
{
auto it = m_domains.find(i);
if (it == m_domains.end())
{// apply to all domains
domains.resize(cd.getNParts());
domains.resize(nDomains);
for(size_t i = 0; i < domains.size(); ++i)
{
domains[i] = i;
Expand Down Expand Up @@ -128,7 +131,7 @@ namespace API
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getFunctionDomains(iFun, cd, domains);
getDomainIndices(iFun, cd.getNParts(), domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
Expand Down Expand Up @@ -163,7 +166,7 @@ namespace API
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getFunctionDomains(iFun, cd, domains);
getDomainIndices(iFun, cd.getNParts(), domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
Expand All @@ -174,6 +177,28 @@ namespace API
}
}

/**
* Called at the start of each iteration. Call iterationStarting() of the members.
*/
void MultiDomainFunction::iterationStarting()
{
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
getFunction(iFun)->iterationStarting();
}
}

/**
* Called at the end of an iteration. Call iterationFinished() of the members.
*/
void MultiDomainFunction::iterationFinished()
{
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
getFunction(iFun)->iterationFinished();
}
}

/// Return a value of attribute attName
IFunction::Attribute MultiDomainFunction::getLocalAttribute(size_t i, const std::string& attName)const
{
Expand Down Expand Up @@ -251,6 +276,58 @@ namespace API
setDomainIndices(i,indx);
}

/**
* Split this function into independent functions. The number of functions in the
* returned vector must be equal to the number
* of domains. The result of evaluation of the i-th function on the i-th domain must be
* the same as if this MultiDomainFunction was evaluated.
*/
std::vector<IFunction_sptr> MultiDomainFunction::createEquivalentFunctions() const
{
size_t nDomains = m_maxIndex + 1;
std::vector<CompositeFunction_sptr> compositeFunctions(nDomains);
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getDomainIndices(iFun, nDomains, domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
size_t j = *i;
CompositeFunction_sptr cf = compositeFunctions[j];
if ( !cf )
{
// create a composite function for each domain
cf = CompositeFunction_sptr(new CompositeFunction());
compositeFunctions[j] = cf;
}
// add copies of all functions applied to j-th domain to a single compositefunction
cf->addFunction( FunctionFactory::Instance().createInitialized( getFunction(iFun)->asString() ));
}
}
std::vector<IFunction_sptr> outFunctions(nDomains);
// fill in the output vector
// check functions containing a single member and take it out of the composite
for(size_t i = 0; i < compositeFunctions.size(); ++i)
{
auto fun = compositeFunctions[i];
if ( !fun || fun->nFunctions() == 0 )
{
throw std::runtime_error("There is no function for domain " + boost::lexical_cast<std::string>(i));
}
if ( fun->nFunctions() > 1 )
{
outFunctions[i] = fun;
}
else
{
outFunctions[i] = fun->getFunction(0);
}
}
return outFunctions;
}


} // namespace API
} // namespace Mantid
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -6,6 +6,7 @@ set ( SRC_FILES
src/AddLogDerivative.cpp
src/AddPeak.cpp
src/AddSampleLog.cpp
src/AddTimeSeriesLog.cpp
src/AlignDetectors.cpp
src/AlphaCalc.cpp
src/AnyShapeAbsorption.cpp
Expand Down Expand Up @@ -66,6 +67,7 @@ set ( SRC_FILES
src/CrossCorrelate.cpp
src/CuboidGaugeVolumeAbsorption.cpp
src/CylinderAbsorption.cpp
src/DeleteLog.cpp
src/DeleteWorkspace.cpp
src/DetectorDiagnostic.cpp
src/DetectorEfficiencyCor.cpp
Expand Down Expand Up @@ -232,6 +234,7 @@ set ( INC_FILES
inc/MantidAlgorithms/AddLogDerivative.h
inc/MantidAlgorithms/AddPeak.h
inc/MantidAlgorithms/AddSampleLog.h
inc/MantidAlgorithms/AddTimeSeriesLog.h
inc/MantidAlgorithms/AlignDetectors.h
inc/MantidAlgorithms/AlphaCalc.h
inc/MantidAlgorithms/AnyShapeAbsorption.h
Expand Down Expand Up @@ -292,6 +295,7 @@ set ( INC_FILES
inc/MantidAlgorithms/CrossCorrelate.h
inc/MantidAlgorithms/CuboidGaugeVolumeAbsorption.h
inc/MantidAlgorithms/CylinderAbsorption.h
inc/MantidAlgorithms/DeleteLog.h
inc/MantidAlgorithms/DeleteWorkspace.h
inc/MantidAlgorithms/DetectorDiagnostic.h
inc/MantidAlgorithms/DetectorEfficiencyCor.h
Expand Down Expand Up @@ -470,6 +474,7 @@ set ( TEST_FILES
AddLogDerivativeTest.h
AddPeakTest.h
AddSampleLogTest.h
AddTimeSeriesLogTest.h
AlignDetectorsTest.h
AlphaCalcTest.h
AnyShapeAbsorptionTest.h
Expand Down Expand Up @@ -529,6 +534,7 @@ set ( TEST_FILES
CropWorkspaceTest.h
CuboidGaugeVolumeAbsorptionTest.h
CylinderAbsorptionTest.h
DeleteLogTest.h
DeleteWorkspaceTest.h
DetectorEfficiencyCorTest.h
DetectorEfficiencyCorUserTest.h
Expand Down
@@ -0,0 +1,53 @@
#ifndef MANTID_ALGORITHMS_ADDTIMESERIESLOG_H_
#define MANTID_ALGORITHMS_ADDTIMESERIESLOG_H_

#include "MantidAPI/Algorithm.h"

namespace Mantid
{
namespace Algorithms
{

/**
Copyright &copy; 2014 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 AddTimeSeriesLog : public API::Algorithm
{
public:
virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;

private:
virtual void initDocs();
void init();
void exec();

/// Remove an existing log of the given name
void removeExisting(API::MatrixWorkspace_sptr &logWS, const std::string & name);
/// Create or update the named log entry
void createOrUpdate(API::Run &run, const std::string & name);
};

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_ADDTIMESERIESLOG_H_ */
Expand Up @@ -80,7 +80,7 @@ class DLLExport CorrectFlightPaths: public API::Algorithm {


Geometry::Instrument_const_sptr m_instrument;
Geometry::IObjComponent_const_sptr m_sample;
Geometry::IComponent_const_sptr m_sample;

double m_l2;
double m_wavelength;
Expand Down

0 comments on commit 85af503

Please sign in to comment.