Mantid
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
Mantid::DataObjects::FractionalRebinning Namespace Reference

FractionalRebinning helper functionality, used by the Rebin2D algorithm. More...

Enumerations

enum class  QuadrilateralType { Rectangle , TrapezoidX , TrapezoidY , General }
 

Functions

void calcGeneralIntersections (const std::vector< double > &xAxis, const std::vector< double > &yAxis, const Quadrilateral &inputQ, const size_t qstart, const size_t qend, const size_t x_start, const size_t x_end, std::vector< AreaInfo > &areaInfos)
 Computes the output grid bins which intersect the input quad and their overlapping areas for arbitrary shaped input grids. More...
 
void calcRectangleIntersections (const std::vector< double > &xAxis, const std::vector< double > &yAxis, const Quadrilateral &inputQ, const size_t y_start, const size_t y_end, const size_t x_start, const size_t x_end, std::vector< AreaInfo > &areaInfos)
 Computes the output grid bins which intersect the input quad and their overlapping areas assuming both input and output grids are rectangular. More...
 
void calcTrapezoidYIntersections (const std::vector< double > &xAxis, const std::vector< double > &yAxis, const Quadrilateral &inputQ, const size_t y_start, const size_t y_end, const size_t x_start, const size_t x_end, std::vector< AreaInfo > &areaInfos)
 Computes the output grid bins which intersect the input quad and their overlapping areas assuming input quad is a y-axis aligned trapezoid. More...
 
MANTID_DATAOBJECTS_DLL void finalizeFractionalRebin (DataObjects::RebinnedOutput &outputWS)
 Set finalize flag after fractional rebinning loop. More...
 
MANTID_DATAOBJECTS_DLL bool getIntersectionRegion (const std::vector< double > &xAxis, const std::vector< double > &verticalAxis, const Geometry::Quadrilateral &inputQ, size_t &qstart, size_t &qend, size_t &x_start, size_t &x_end)
 Find the intersect region on the output grid. More...
 
QuadrilateralType getQuadrilateralType (const Quadrilateral &inputQ)
 Determine the (axis-aligned) quadrilateral type of the input polygon. More...
 
MANTID_DATAOBJECTS_DLL void normaliseOutput (const API::MatrixWorkspace_sptr &outputWS, const API::MatrixWorkspace_const_sptr &inputWS, API::Progress *progress=nullptr)
 Compute sqrt of errors and put back in bin width division if necessary. More...
 
MANTID_DATAOBJECTS_DLL void rebinToFractionalOutput (const Geometry::Quadrilateral &inputQ, const API::MatrixWorkspace_const_sptr &inputWS, const size_t i, const size_t j, DataObjects::RebinnedOutput &outputWS, const std::vector< double > &verticalAxis, const DataObjects::RebinnedOutput_const_sptr &inputRB=nullptr)
 Rebin the input quadrilateral to to output grid. More...
 
MANTID_DATAOBJECTS_DLL void rebinToOutput (const Geometry::Quadrilateral &inputQ, const API::MatrixWorkspace_const_sptr &inputWS, const size_t i, const size_t j, API::MatrixWorkspace &outputWS, const std::vector< double > &verticalAxis)
 Rebin the input quadrilateral to to output grid. More...
 

Variables

const double POS_TOLERANCE = 1.e-10
 

Detailed Description

FractionalRebinning helper functionality, used by the Rebin2D algorithm.

Enumeration Type Documentation

◆ QuadrilateralType

Enumerator
Rectangle 
TrapezoidX 
TrapezoidY 
General 

Definition at line 47 of file FractionalRebinning.cpp.

Function Documentation

◆ calcGeneralIntersections()

void Mantid::DataObjects::FractionalRebinning::calcGeneralIntersections ( const std::vector< double > &  xAxis,
const std::vector< double > &  yAxis,
const Quadrilateral inputQ,
const size_t  qstart,
const size_t  qend,
const size_t  x_start,
const size_t  x_end,
std::vector< AreaInfo > &  areaInfos 
)

Computes the output grid bins which intersect the input quad and their overlapping areas for arbitrary shaped input grids.

Parameters
xAxisA vector containing the output horizontal axis edges
yAxisThe output data vertical axis
inputQThe input quadrilateral
qstartThe starting y-axis index
qendThe starting y-axis index
x_startThe starting x-axis index
x_endThe starting x-axis index
areaInfosOutput vector of indices and areas of overlapping bins

Definition at line 442 of file FractionalRebinning.cpp.

References Mantid::Geometry::ConvexPolygon::area(), Mantid::Geometry::ConvexPolygon::clear(), and Mantid::Geometry::intersection().

Referenced by rebinToFractionalOutput().

◆ calcRectangleIntersections()

void Mantid::DataObjects::FractionalRebinning::calcRectangleIntersections ( const std::vector< double > &  xAxis,
const std::vector< double > &  yAxis,
const Quadrilateral inputQ,
const size_t  y_start,
const size_t  y_end,
const size_t  x_start,
const size_t  x_end,
std::vector< AreaInfo > &  areaInfos 
)

Computes the output grid bins which intersect the input quad and their overlapping areas assuming both input and output grids are rectangular.

Parameters
xAxisA vector containing the output horizontal axis edges
yAxisThe output data vertical axis
inputQThe input quadrilateral
y_startThe starting y-axis index
y_endThe starting y-axis index
x_startThe starting x-axis index
x_endThe starting x-axis index
areaInfosOutput vector of indices and areas of overlapping bins

Definition at line 128 of file FractionalRebinning.cpp.

References height, Mantid::Geometry::Quadrilateral::maxX(), Mantid::Geometry::Quadrilateral::maxY(), Mantid::Geometry::Quadrilateral::minX(), and Mantid::Geometry::Quadrilateral::minY().

Referenced by rebinToFractionalOutput().

◆ calcTrapezoidYIntersections()

void Mantid::DataObjects::FractionalRebinning::calcTrapezoidYIntersections ( const std::vector< double > &  xAxis,
const std::vector< double > &  yAxis,
const Quadrilateral inputQ,
const size_t  y_start,
const size_t  y_end,
const size_t  x_start,
const size_t  x_end,
std::vector< AreaInfo > &  areaInfos 
)

Computes the output grid bins which intersect the input quad and their overlapping areas assuming input quad is a y-axis aligned trapezoid.

Parameters
xAxisA vector containing the output horizontal axis edges
yAxisThe output data vertical axis
inputQThe input quadrilateral
y_startThe starting y-axis index
y_endThe ending y-axis index
x_startThe starting x-axis index
x_endThe ending x-axis index
areaInfosOutput vector of indices and areas of overlapping bins

Definition at line 162 of file FractionalRebinning.cpp.

References Mantid::Kernel::V2D::X(), and Mantid::Kernel::V2D::Y().

Referenced by rebinToFractionalOutput().

◆ finalizeFractionalRebin()

void Mantid::DataObjects::FractionalRebinning::finalizeFractionalRebin ( RebinnedOutput outputWS)

Set finalize flag after fractional rebinning loop.

Called at the completion of the fractional rebinning loop to the set the finalize and hasSqrdError flags in the output workspace.

Parameters
outputWSReference to the rebinned output workspace

Definition at line 652 of file FractionalRebinning.cpp.

References Mantid::DataObjects::RebinnedOutput::setFinalized(), and Mantid::DataObjects::RebinnedOutput::setSqrdErrors().

Referenced by Mantid::Algorithms::Rebin2D::exec(), Mantid::Algorithms::SofQWNormalisedPolygon::exec(), and Mantid::DataObjects::ReflectometryTransform::executeNormPoly().

◆ getIntersectionRegion()

bool Mantid::DataObjects::FractionalRebinning::getIntersectionRegion ( const std::vector< double > &  xAxis,
const std::vector< double > &  verticalAxis,
const Quadrilateral inputQ,
size_t &  qstart,
size_t &  qend,
size_t &  x_start,
size_t &  x_end 
)

Find the intersect region on the output grid.

Find the possible region of intersection on the output workspace for the given polygon.

The given polygon must have a CLOCKWISE winding and the first vertex must be the "lowest left" point.

Parameters
xAxisA vector containing the output horizontal axis edges
verticalAxisA vector containing the output vertical axis edges
inputQThe input polygon (Polygon winding must be clockwise)
qstartAn output giving the starting index in the Q direction
qendAn output giving the end index in the Q direction
x_startAn output giving the start index in the dX direction
x_endAn output giving the end index in the dX direction
Returns
True if an intersection is possible

Definition at line 82 of file FractionalRebinning.cpp.

References Mantid::Geometry::Quadrilateral::maxX(), Mantid::Geometry::Quadrilateral::maxY(), Mantid::Geometry::Quadrilateral::minX(), and Mantid::Geometry::Quadrilateral::minY().

Referenced by rebinToFractionalOutput(), and rebinToOutput().

◆ getQuadrilateralType()

QuadrilateralType Mantid::DataObjects::FractionalRebinning::getQuadrilateralType ( const Quadrilateral inputQ)

Determine the (axis-aligned) quadrilateral type of the input polygon.

Parameters
inputQInput polygon (assumes vertices are in order: ll, ul, ur, lr)

Definition at line 53 of file FractionalRebinning.cpp.

References fabs, General, POS_TOLERANCE, Rectangle, TrapezoidX, TrapezoidY, Mantid::Geometry::X, and Mantid::Geometry::Y.

Referenced by rebinToFractionalOutput().

◆ normaliseOutput()

void Mantid::DataObjects::FractionalRebinning::normaliseOutput ( const MatrixWorkspace_sptr outputWS,
const MatrixWorkspace_const_sptr inputWS,
Progress progress 
)

Compute sqrt of errors and put back in bin width division if necessary.

Computes the square root of the errors and if the input was a distribution this divides by the new bin-width.

Parameters
outputWSThe workspace containing the output data
inputWSThe input workspace used for testing distribution state
progressAn optional progress object. Reported to once per bin.

Definition at line 468 of file FractionalRebinning.cpp.

References Mantid::Kernel::ProgressBase::report().

Referenced by Mantid::Algorithms::Rebin2D::exec(), Mantid::Algorithms::SofQWNormalisedPolygon::exec(), Mantid::Algorithms::SofQWPolygon::exec(), and Mantid::DataObjects::ReflectometryTransform::executeNormPoly().

◆ rebinToFractionalOutput()

void Mantid::DataObjects::FractionalRebinning::rebinToFractionalOutput ( const Quadrilateral inputQ,
const MatrixWorkspace_const_sptr inputWS,
const size_t  i,
const size_t  j,
RebinnedOutput outputWS,
const std::vector< double > &  verticalAxis,
const RebinnedOutput_const_sptr inputRB 
)

Rebin the input quadrilateral to to output grid.

Rebin the input quadrilateral to the output grid The quadrilateral must have a CLOCKWISE winding.

Parameters
inputQThe input polygon (Polygon winding must be clockwise)
inputWSThe input workspace containing the input intensity values
iThe indexiin the vertical axis direction that inputQ references
jThe index in the horizontal axis direction that inputQ references
outputWSA pointer to the output workspace that accumulates the data Note that the error array of the output workspace contains the variance and not the errors (standard deviations).
verticalAxisA vector containing the output vertical axis bin boundaries
inputRBA pointer, of RebinnedOutput type, to the input workspace. It is used to take into account the input area fractions when calcuting the final output fractions. This can be null to indicate that the input was a standard 2D workspace.

Definition at line 571 of file FractionalRebinning.cpp.

References Mantid::Geometry::Quadrilateral::area(), calcGeneralIntersections(), calcRectangleIntersections(), calcTrapezoidYIntersections(), Mantid::DataObjects::RebinnedOutput::dataF(), error, getIntersectionRegion(), getQuadrilateralType(), Mantid::API::MatrixWorkspace::mutableE(), Mantid::API::MatrixWorkspace::mutableY(), PARALLEL_CRITICAL, Rectangle, TrapezoidY, Mantid::API::MatrixWorkspace::x(), and Mantid::Geometry::X.

Referenced by Mantid::Algorithms::Rebin2D::exec(), Mantid::Algorithms::SofQWNormalisedPolygon::exec(), and Mantid::DataObjects::ReflectometryTransform::executeNormPoly().

◆ rebinToOutput()

void Mantid::DataObjects::FractionalRebinning::rebinToOutput ( const Quadrilateral inputQ,
const MatrixWorkspace_const_sptr inputWS,
const size_t  i,
const size_t  j,
MatrixWorkspace outputWS,
const std::vector< double > &  verticalAxis 
)

Rebin the input quadrilateral to to output grid.

Rebin the input quadrilateral to the output grid.

The quadrilateral must have a CLOCKWISE winding.

Parameters
inputQThe input polygon (Polygon winding must be Clockwise)
inputWSThe input workspace containing the input intensity values
iThe index in the vertical axis direction that inputQ references
jThe index in the horizontal axis direction that inputQ references
outputWSA pointer to the output workspace that accumulates the data
verticalAxisA vector containing the output vertical axis bin boundaries

Definition at line 504 of file FractionalRebinning.cpp.

References Mantid::Geometry::ConvexPolygon::area(), Mantid::Geometry::Quadrilateral::area(), Mantid::Geometry::ConvexPolygon::clear(), getIntersectionRegion(), Mantid::Geometry::intersection(), Mantid::Geometry::ConvexPolygon::maxX(), Mantid::Geometry::ConvexPolygon::minX(), Mantid::API::MatrixWorkspace::mutableE(), Mantid::API::MatrixWorkspace::mutableY(), PARALLEL_CRITICAL, Mantid::API::MatrixWorkspace::x(), Mantid::Geometry::X, and Mantid::Geometry::y.

Referenced by Mantid::Algorithms::Rebin2D::exec(), and Mantid::Algorithms::SofQWPolygon::exec().

Variable Documentation

◆ POS_TOLERANCE

const double Mantid::DataObjects::FractionalRebinning::POS_TOLERANCE = 1.e-10

Definition at line 45 of file FractionalRebinning.cpp.

Referenced by getQuadrilateralType().