Skip to content

Commit

Permalink
Refs #9041 Merging master in to take care of a merge conflict
Browse files Browse the repository at this point in the history
Conflict occurred in refl_gui.py

Merge branch origin master into 'feature/9041_refl_gui_plotting'

Conflicts:
	Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
  • Loading branch information
keithnbrown committed Feb 27, 2014
2 parents 6b4f848 + 890a51a commit 9f9dac2
Show file tree
Hide file tree
Showing 226 changed files with 79,333 additions and 64,709 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -171,6 +171,7 @@ set ( INC_FILES
inc/MantidAPI/IBackgroundFunction.h
inc/MantidAPI/IBoxControllerIO.h
inc/MantidAPI/ICatalog.h
inc/MantidAPI/ICatalogInfoService.h
inc/MantidAPI/IConstraint.h
inc/MantidAPI/ICostFunction.h
inc/MantidAPI/IDataItem.h
Expand Down
121 changes: 56 additions & 65 deletions Code/Mantid/Framework/API/inc/MantidAPI/ICatalog.h
@@ -1,82 +1,73 @@
#ifndef MANTID_API_ICATLOG_H_
#define MANTID_API_ICATLOG_H_

#include "MantidAPI/ITableWorkspace.h"

namespace Mantid
{
namespace ICat
{
class CatalogSearchParam;
}

//forward declarations
namespace ICat
{
class CatalogSearchParam;
}

namespace API
{
namespace API
{
/**
This class creates an interface for information catalogs to support multiple facilities
/**
This class creates an interface for information catalogs to support multiple facilities
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
@date 23/09/2010
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
@date 23/09/2010
Copyright © 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Copyright © 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
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 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.
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/>.
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>
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ICatalog
{
public:
// virtual destructor
virtual ~ICatalog(){};
/// method to login to a catalog
virtual void login(const std::string&,const std::string&,const std::string&)=0;
/// logout from catalog
virtual void logout()=0;
///Search investigations
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr&, const int &,const int &)=0;
/// Obtain the number of results returned by the search method.
virtual int64_t getNumberOfSearchResults(const ICat::CatalogSearchParam&)=0;
/// search logged in users data
virtual void myData(ITableWorkspace_sptr &)=0;
/// get datasets.
virtual void getDataSets(const std::string& ,ITableWorkspace_sptr&)=0;
/// get datafiles
virtual void getDataFiles(const std::string&,ITableWorkspace_sptr &)=0;
/// instrument list
virtual void listInstruments(std::vector<std::string>&)=0;
/// get investigationtype lists
virtual void listInvestigationTypes(std::vector<std::string>&)=0;
/// get file locations
virtual void getFileLocation(const long long&,std::string&)=0;
/// get URLs of the files
virtual void getDownloadURL(const long long&,std::string&)=0;
/// get URL of where to PUT (publish) files.
virtual const std::string getUploadURL(const std::string&,const std::string&,const std::string&)=0;
/// keep alive
virtual void keepAlive()=0;
///keep alive in minutes
virtual int keepAliveinminutes()=0;
};
class DLLExport ICatalog
{
public:
/// Virtual destructor
virtual ~ICatalog(){};
/// method to login to a catalog
virtual void login(const std::string&,const std::string&,const std::string&)=0;
/// logout from catalog
virtual void logout()=0;
///Search investigations
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr&, const int &,const int &)=0;
/// Obtain the number of results returned by the search method.
virtual int64_t getNumberOfSearchResults(const ICat::CatalogSearchParam&)=0;
/// search logged in users data
virtual void myData(ITableWorkspace_sptr &)=0;
/// get datasets.
virtual void getDataSets(const std::string& ,ITableWorkspace_sptr&)=0;
/// get datafiles
virtual void getDataFiles(const std::string&,ITableWorkspace_sptr &)=0;
/// instrument list
virtual void listInstruments(std::vector<std::string>&)=0;
/// get investigationtype lists
virtual void listInvestigationTypes(std::vector<std::string>&)=0;
/// keep alive
virtual void keepAlive()=0;
};

typedef boost::shared_ptr<ICatalog> ICatalog_sptr;
typedef boost::shared_ptr<const ICatalog> ICatalog_const_sptr;
typedef boost::shared_ptr<ICatalog> ICatalog_sptr;
typedef boost::shared_ptr<const ICatalog> ICatalog_const_sptr;
}
}
}
#endif

#endif /*MANTID_API_ICATLOG_H_*/
55 changes: 55 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ICatalogInfoService.h
@@ -0,0 +1,55 @@
#ifndef MANTID_API_ICATLOGINFOSERVICE_H_
#define MANTID_API_ICATLOGINFOSERVICE_H_

#include "MantidAPI/DllConfig.h"

namespace Mantid
{
namespace API
{
/**
This class is responsible for interfacing with the Information Data Service (IDS)
to upload and download files to and from the archives.
@author Jay Rainey, ISIS Rutherford Appleton Laboratory
@date 24/02/2010
Copyright &copy; 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 ICatalogInfoService
{
public:
// Virtual destructor
virtual ~ICatalogInfoService(){};
/// Obtain the datafile location string from the archives.
virtual const std::string getFileLocation(const long long&)=0;
/// Obtain url to download a file from.
virtual const std::string getDownloadURL(const long long&)=0;
/// Obtain the url to upload a file to.
virtual const std::string getUploadURL(const std::string&,const std::string&,const std::string&)=0;
};

typedef boost::shared_ptr<ICatalogInfoService> ICatalogInfoService_sptr;
typedef boost::shared_ptr<const ICatalogInfoService> ICatalogInfoService_const_sptr;
}
}

#endif /*MANTID_API_ICATLOGINFOSERVICE_H_*/
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/MDGeometry.h
Expand Up @@ -92,6 +92,9 @@ namespace API

void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset);

size_t getNumberTransformsToOriginal() const;
size_t getNumberTransformsFromOriginal() const;

// --------------------------------------------------------------------------------------------
///@return the vector of the origin (in the original workspace) that corresponds to 0,0,0... in this workspace
Mantid::Kernel::VMD & getOrigin()
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -816,9 +816,7 @@ namespace Mantid

if (startProgress >= 0 && endProgress > startProgress && endProgress <= 1.)
{
std::cerr << "progress observer=" << m_progressObserver << "\n";
alg->addObserver(this->progressObserver());
std::cerr << "progress observer=" << m_progressObserver << "\n";
m_startChildProgress = startProgress;
m_endChildProgress = endProgress;
}
Expand Down
149 changes: 64 additions & 85 deletions Code/Mantid/Framework/API/src/IFunction.cpp
Expand Up @@ -973,54 +973,23 @@ double IFunction::convertValue(double value, Kernel::Unit_sptr& outUnit,
boost::shared_ptr<const MatrixWorkspace> ws,
size_t wsIndex)const
{
double retVal = value;
Kernel::Unit_sptr wsUnit = ws->getAxis(0)->unit();

// if unit required by formula or look-up-table different from ws-unit then
if ( outUnit->unitID().compare(wsUnit->unitID()) != 0 )
// only required if formula or look-up-table different from ws unit
const auto & wsUnit = ws->getAxis(0)->unit();
if ( outUnit->unitID().compare(wsUnit->unitID()) == 0 ) return value;

// first check if it is possible to do a quick conversion and convert
// slight duplication to below to avoid instantiating vector unless necessary
double factor(0.0), power(0.0);
if (wsUnit->quickConversion(*outUnit,factor,power) )
{
// first check if it is possible to do a quick convertion convert
double factor,power;
if (wsUnit->quickConversion(*outUnit,factor,power) )
{
retVal = factor * std::pow(retVal,power);
}
else
{
double l1,l2,twoTheta;

// Get l1, l2 and theta (see also RemoveBins.calculateDetectorPosition())
Instrument_const_sptr instrument = ws->getInstrument();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
if (sample == NULL)
{
g_log.error() << "No sample defined instrument. Cannot convert units for function\n"
<< "Ignore convertion.";
return value;
}
l1 = instrument->getSource()->getDistance(*sample);
Geometry::IDetector_const_sptr det = ws->getDetector(wsIndex);
if ( ! det->isMonitor() )
{
l2 = det->getDistance(*sample);
twoTheta = ws->detectorTwoTheta(det);
}
else // If this is a monitor then make l1+l2 = source-detector distance and twoTheta=0
{
l2 = det->getDistance(*(instrument->getSource()));
l2 = l2 - l1;
twoTheta = 0.0;
}

std::vector<double> endPoint;
endPoint.push_back(retVal);
std::vector<double> emptyVec;
wsUnit->toTOF(endPoint,emptyVec,l1,l2,twoTheta,0,0.0,0.0);
outUnit->fromTOF(endPoint,emptyVec,l1,l2,twoTheta,0,0.0,0.0);
retVal = endPoint[0];
}
}
return retVal;
return factor * std::pow(value,power);
}
else
{
std::vector<double> singleValue(1, value);
convertValue(singleValue, outUnit, ws, wsIndex);
return singleValue.front();
}
}

/** Convert values from unit defined in workspace (ws) to outUnit
Expand All @@ -1035,50 +1004,60 @@ void IFunction::convertValue(std::vector<double>& values, Kernel::Unit_sptr& out
boost::shared_ptr<const MatrixWorkspace> ws,
size_t wsIndex) const
{
Kernel::Unit_sptr wsUnit = ws->getAxis(0)->unit();
// only required if formula or look-up-table different from ws unit
const auto & wsUnit = ws->getAxis(0)->unit();
if ( outUnit->unitID().compare(wsUnit->unitID()) == 0 ) return;

// if unit required by formula or look-up-table different from ws-unit then
if ( outUnit->unitID().compare(wsUnit->unitID()) != 0 )
// first check if it is possible to do a quick conversion convert
double factor, power;
if (wsUnit->quickConversion(*outUnit,factor,power) )
{
// first check if it is possible to do a quick convertion convert
double factor,power;
if (wsUnit->quickConversion(*outUnit,factor,power) )
auto iend = values.end();
for(auto itr = values.begin(); itr != iend; ++itr)
(*itr) = factor * std::pow(*itr, power);
}
else
{
// Get l1, l2 and theta (see also RemoveBins.calculateDetectorPosition())
Instrument_const_sptr instrument = ws->getInstrument();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
if (sample == NULL)
{
for (size_t i = 0; i < values.size(); i++)
values[i] = factor * std::pow(values[i],power);
g_log.error() << "No sample defined instrument. Cannot convert units for function\n"
<< "Ignore convertion.";
return;
}
else
double l1 = instrument->getSource()->getDistance(*sample);
Geometry::IDetector_const_sptr det = ws->getDetector(wsIndex);
double l2(-1.0), twoTheta(0.0);
if ( ! det->isMonitor() )
{
double l1,l2,twoTheta;

// Get l1, l2 and theta (see also RemoveBins.calculateDetectorPosition())
Instrument_const_sptr instrument = ws->getInstrument();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
if (sample == NULL)
{
g_log.error() << "No sample defined instrument. Cannot convert units for function\n"
<< "Ignore convertion.";
return;
}
l1 = instrument->getSource()->getDistance(*sample);
Geometry::IDetector_const_sptr det = ws->getDetector(wsIndex);
if ( ! det->isMonitor() )
{
l2 = det->getDistance(*sample);
twoTheta = ws->detectorTwoTheta(det);
}
else // If this is a monitor then make l1+l2 = source-detector distance and twoTheta=0
{
l2 = det->getDistance(*(instrument->getSource()));
l2 = l2 - l1;
twoTheta = 0.0;
}

std::vector<double> emptyVec;
wsUnit->toTOF(values,emptyVec,l1,l2,twoTheta,0,0.0,0.0);
outUnit->fromTOF(values,emptyVec,l1,l2,twoTheta,0,0.0,0.0);
l2 = det->getDistance(*sample);
twoTheta = ws->detectorTwoTheta(det);
}
}
else // If this is a monitor then make l1+l2 = source-detector distance and twoTheta=0
{
l2 = det->getDistance(*(instrument->getSource()));
l2 = l2 - l1;
twoTheta = 0.0;
}
int emode = static_cast<int>(ws->getEMode());
double efixed(0.0);
try
{
efixed = ws->getEFixed(det);
}
catch(std::exception &)
{
// assume elastic
efixed = 0.0;
emode = 0;
}

std::vector<double> emptyVec;
wsUnit->toTOF(values, emptyVec, l1, l2, twoTheta, emode, efixed, 0.0);
outUnit->fromTOF(values, emptyVec,l1,l2,twoTheta, emode, efixed, 0.0);
}
}

/**
Expand Down

0 comments on commit 9f9dac2

Please sign in to comment.