23#include <boost/math/special_functions/sign.hpp>
45 std::vector<double> extents;
47 "A comma separated list of min, max for each dimension,\n"
48 "specifying the extents of each dimension. Optional, default "
49 "will use ConvertToMDMinMaxLocal to calculate extents for each "
51 setPropertyGroup(
"Extents", getBoxSettingsGroupName());
62 std::vector<double> &maxVal) {
65 if (Extents.size() == 2) {
66 for (
size_t d = 0;
d < 3;
d++) {
67 minVal[
d] = Extents[0];
68 maxVal[
d] = Extents[1];
70 }
else if (Extents.size() == 6) {
71 for (
size_t d = 0;
d < 3;
d++) {
72 minVal[
d] = Extents[2 *
d + 0];
73 maxVal[
d] = Extents[2 *
d + 1];
75 }
else if (Extents.empty()) {
78 throw std::invalid_argument(
"You must specify either 2 or 6 extents (min,max).");
87 std::vector<double> &maxVal) {
91 alg->setPropertyValue(
"QDimensions",
"Q3D");
98 alg->setProperty(
"QConversionScales", Scaling);
102 minVal = alg->getProperty(
"MinValues");
103 maxVal = alg->getProperty(
"MaxValues");
107 const auto INF = std::numeric_limits<double>::infinity();
108 const auto MAX_DBL = std::numeric_limits<double>::max();
109 const auto DEFAULT_BOUND = 50.0;
111 std::replace(minVal.begin(), minVal.end(), -INF, -DEFAULT_BOUND);
112 std::replace(maxVal.begin(), maxVal.end(), INF, DEFAULT_BOUND);
113 std::replace(minVal.begin(), minVal.end(), MAX_DBL, -DEFAULT_BOUND);
114 std::replace(maxVal.begin(), maxVal.end(), -MAX_DBL, DEFAULT_BOUND);
121 for (
size_t i = 0; i < maxVal.size(); ++i) {
122 minVal[i] *= (1 - 1.e-5 * boost::math::sign(minVal[i]));
123 if (
fabs(minVal[i]) < 1.e-5)
125 maxVal[i] *= (1 + 1.e-5 * boost::math::sign(maxVal[i]));
126 if (
fabs(maxVal[i]) < 1.e-5)
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Support for a property that holds an array of values.
void init() override
Initialize the algorithm's properties.
void convertFramePropertyNames(const std::string &TargFrame, std::string &TargFrameName, std::string &ScalingName)
method to convert the value of the target frame specified for the ConvertToDiffractionMDWorksapce int...
ConvertToDiffractionMDWorkspace3 : Create a MDEventWorkspace with events in reciprocal space (Qx,...
void convertExtents(const std::vector< double > &Extents, std::vector< double > &minVal, std::vector< double > &maxVal) override
Splits extents accepted by convertToDiffreactionMD workspace in the form min1,max1 or min1,...
void calculateExtentsFromData(std::vector< double > &minVal, std::vector< double > &maxVal)
Calculate the extents to use for the conversion from the input workspace.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
TargetFrame
enum describes availible target coordinate systems for Q3D mode
static const std::vector< std::string > availableTypes()
Returns the string list of available modes.