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());
65 std::vector<double> &maxVal) {
68 if (Extents.size() == 2) {
69 for (
size_t d = 0;
d < 3;
d++) {
70 minVal[
d] = Extents[0];
71 maxVal[
d] = Extents[1];
73 }
else if (Extents.size() == 6) {
74 for (
size_t d = 0;
d < 3;
d++) {
75 minVal[
d] = Extents[2 *
d + 0];
76 maxVal[
d] = Extents[2 *
d + 1];
78 }
else if (Extents.empty()) {
81 throw std::invalid_argument(
"You must specify either 2 or 6 extents (min,max).");
90 std::vector<double> &maxVal) {
94 alg->setPropertyValue(
"QDimensions",
"Q3D");
101 alg->setProperty(
"QConversionScales", Scaling);
105 minVal = alg->getProperty(
"MinValues");
106 maxVal = alg->getProperty(
"MaxValues");
110 const auto INF = std::numeric_limits<double>::infinity();
111 const auto MAX_DBL = std::numeric_limits<double>::max();
112 const auto DEFAULT_BOUND = 50.0;
114 std::replace(minVal.begin(), minVal.end(), -INF, -DEFAULT_BOUND);
115 std::replace(maxVal.begin(), maxVal.end(), INF, DEFAULT_BOUND);
116 std::replace(minVal.begin(), minVal.end(), MAX_DBL, -DEFAULT_BOUND);
117 std::replace(maxVal.begin(), maxVal.end(), -MAX_DBL, DEFAULT_BOUND);
124 for (
size_t i = 0; i < maxVal.size(); ++i) {
125 minVal[i] *= (1 - 1.e-5 * boost::math::sign(minVal[i]));
126 if (
fabs(minVal[i]) < 1.e-5)
128 maxVal[i] *= (1 + 1.e-5 * boost::math::sign(maxVal[i]));
129 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.