Rebin.h 3.12 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8

9
#include "MantidAPI/DistributedAlgorithm.h"
10
#include "MantidAlgorithms/DllConfig.h"
11

12
13
14
15
namespace Mantid {
namespace Algorithms {
/** Takes a workspace as input and rebins the data according to the input rebin
   parameters.
16
17
18

    Required Properties:
    <UL>
19
20
21
22
23
24
    <LI> InputWorkspace  - The name of the workspace to take as input. Must
   contain histogram data. </LI>
    <LI> OutputWorkspace - The name of the workspace in which to store the
   result. </LI>
    <LI> RebinParameters - The new bin boundaries in the form
   X1,deltaX1,X2,deltaX2,X3,... </LI>
25
26
    </UL>

27
28
29
30
31
32
33
    The algorithms used in the VectorHelper::rebin() and
   VectorHelper::createAxisFromRebinParams()
    are based on the algorithms used in OPENGENIE /src/transform_utils.cxx
   (Freddie Akeroyd, ISIS).
    When calculating the bin boundaries, if the last bin ends up with a width
   being less than 25%
    of the penultimate one, then the two are combined.
34
35
36
37

    @author Dickon Champion, STFC
    @date 25/02/2008
 */
38
class MANTID_ALGORITHMS_DLL Rebin : public API::DistributedAlgorithm {
39
40
public:
  /// Algorithm's name for identification overriding a virtual method
41
  const std::string name() const override { return "Rebin"; }
42
  /// Summary of algorithms purpose
43
  const std::string summary() const override {
44
45
46
47
    return "Rebins data with new X bin boundaries. For EventWorkspaces, you "
           "can very quickly rebin in-place by keeping the same output name "
           "and PreserveEvents=true.";
  }
48

49
  /// Algorithm's version for identification overriding a virtual method
50
  int version() const override { return 1; }
51
  /// Algorithm's category for identification overriding a virtual method
52
  const std::string category() const override { return "Transforms\\Rebin"; }
53
  /// Algorithm's aliases
54
  const std::string alias() const override { return "rebin"; }
55
56
  /// Algorithm's seeAlso
  const std::vector<std::string> seeAlso() const override {
Samuel Jones's avatar
Samuel Jones committed
57
    return {"RebinToWorkspace", "Rebin2D", "Rebunch", "Regroup", "RebinByPulseTimes", "RebinByTimeAtSample"};
58
  }
59
  std::map<std::string, std::string> validateInputs() override;
60

Samuel Jones's avatar
Samuel Jones committed
61
62
  static std::vector<double> rebinParamsFromInput(const std::vector<double> &inParams,
                                                  const API::MatrixWorkspace &inputWS, Kernel::Logger &logger);
63

64
protected:
65
  const std::string workspaceMethodName() const override { return "rebin"; }
Samuel Jones's avatar
Samuel Jones committed
66
67
  const std::string workspaceMethodOnTypes() const override { return "MatrixWorkspace"; }
  const std::string workspaceMethodInputProperty() const override { return "InputWorkspace"; }
68

69
  // Overridden Algorithm methods
70
71
  void init() override;
  void exec() override;
72

Samuel Jones's avatar
Samuel Jones committed
73
74
  void propagateMasks(const API::MatrixWorkspace_const_sptr &inputWS, const API::MatrixWorkspace_sptr &outputWS,
                      int hist);
75
76
77
78
};

} // namespace Algorithms
} // namespace Mantid