Mantid
Loading...
Searching...
No Matches
Functions
Mantid::DataObjects::MDEventsTestHelper Namespace Reference

Set of helper methods for testing MDEventWorkspace things. More...

Functions

void checkAndDeleteFile (const std::string &filename)
 Delete a file from disk. More...
 
Mantid::DataObjects::EventWorkspace_sptr createDiffractionEventWorkspace (int numEvents, int numPixels=400, int numBins=160)
 Create an EventWorkspace containing fake data of single-crystal diffraction. More...
 
template<typename MDBOX >
static void extents_match (MDBOX box, size_t dim, double min, double max)
 Helper function compares the extents of the given box. More...
 
template<size_t nd>
static void feedMDBox (MDBoxBase< MDLeanEvent< nd >, nd > *box, size_t repeat=1, size_t numPerSide=10, coord_t start=0.5, coord_t step=1.0)
 Feed a MDGridBox with evenly-spaced events. More...
 
template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > makeAnyMDEW (size_t splitInto, coord_t min, coord_t max, size_t numEventsPerBox=0, const std::string &wsName="", const std::string &axisNameFormat="Axis%d", const std::string &axisIdFormat="Axis%d")
 Create a test MDEventWorkspace<nd> . More...
 
template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > makeAnyMDEWWithFrames (size_t splitInto, coord_t min, coord_t max, const Mantid::Geometry::MDFrame &frame, size_t numEventsPerBox=0, const std::string &wsName="", const std::string &axisNameFormat="Axis%d", const std::string &axisIdFormat="Axis%d")
 Create a test MDEventWorkspace<nd> . More...
 
template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > makeAnyMDEWWithIndividualFrames (size_t splitInto, coord_t min, coord_t max, std::vector< Mantid::Geometry::MDFrame_sptr > frames, size_t numEventsPerBox=0, const std::string &wsName="", std::string axisNameFormat="Axis%d", std::string axisIdFormat="Axis%d")
 Create a test MDEventWorkspace<nd> . More...
 
MDEventWorkspace3Lean::sptr makeFakeMDEventWorkspace (const std::string &wsName, long numEvents=10000, Kernel::SpecialCoordinateSystem coord=Kernel::None)
 Make a (optionally) file backed MDEventWorkspace with 10000 fake random data points. More...
 
MDHistoWorkspace_sptr makeFakeMDHistoWorkspace (double signal, size_t numDims, size_t numBins=10, coord_t max=10.0, double errorSquared=1.0, const std::string &name="", double numEvents=1.0)
 Make a fake n-dimensional MDHistoWorkspace. More...
 
Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral (size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, const std::string &name="")
 More general fake n-dimensionsal MDHistoWorkspace. More...
 
Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral (size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, std::vector< std::string > names, const std::string &name="")
 More general fake n-dimensionsal MDHistoWorkspace. More...
 
Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame (double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, size_t numBins, coord_t max, double errorSquared, const std::string &name, double numEvents)
 Creates a fake MDHistoWorkspace with MDFrame selection. More...
 
MDBox< MDLeanEvent< 1 >, 1 > * makeMDBox1 (size_t splitInto=10, API::BoxController *splitter=nullptr)
 Generate an empty MDBox. More...
 
MDBox< MDLeanEvent< 3 >, 3 > * makeMDBox3 ()
 Generate an empty MDBox with 3 dimensions, split 10x5x2. More...
 
std::vector< MDLeanEvent< 1 > > makeMDEvents1 (size_t num)
 Return a vector with this many MDEvents, spaced evenly from 0.5, 1.5, etc. More...
 
template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > makeMDEW (size_t splitInto, coord_t min, coord_t max, size_t numEventsPerBox=0)
 Make a MDEventWorkspace with MDLeanEvents. More...
 
template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDEvent< nd >, nd > > makeMDEWFull (size_t splitInto, coord_t min, coord_t max, size_t numEventsPerBox=0)
 Make a MDEventWorkspace with MDEvents - updated to split dims by splitInto, not 10. More...
 
template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > makeMDEWWithFrames (size_t splitInto, coord_t min, coord_t max, const Mantid::Geometry::MDFrame &frame, size_t numEventsPerBox=0)
 Make a MDEventWorkspace with MDLeanEvents nad MDFrames. More...
 
template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > makeMDEWWithIndividualFrames (size_t splitInto, coord_t min, coord_t max, const std::vector< Mantid::Geometry::MDFrame_sptr > &frame, size_t numEventsPerBox=0)
 Make a MDEventWorkspace with MDLeanEvents and individual MDFrames. More...
 
template<size_t nd>
static MDGridBox< MDLeanEvent< nd >, nd > * makeMDGridBox (size_t split0=10, size_t split1=10, coord_t dimensionMin=0.0, coord_t dimensionMax=10.0)
 Generate an empty MDBox with 2 dimensions, splitting in (default) 10x10 boxes. More...
 
template<size_t nd>
static MDGridBox< MDLeanEvent< nd >, nd > * makeRecursiveMDGridBox (size_t splitInto, size_t levels)
 Generate a recursively gridded MDGridBox. More...
 
template<size_t nd>
static void recurseSplit (MDGridBox< MDLeanEvent< nd >, nd > *box, size_t atRecurseLevel, size_t recurseLimit)
 Recursively split an existing MDGridBox. More...
 

Detailed Description

Set of helper methods for testing MDEventWorkspace things.

Author
Janik Zikovsky
Date
March 29, 2011
Author
Janik Zikovsky
Date
March 29, 2011

Function Documentation

◆ checkAndDeleteFile()

void Mantid::DataObjects::MDEventsTestHelper::checkAndDeleteFile ( const std::string &  filename)

Delete a file from disk.

Parameters
filename: File name to check and delete

Definition at line 342 of file MDEventsTestHelper.cpp.

References Mantid::DataHandling::exists().

◆ createDiffractionEventWorkspace()

EventWorkspace_sptr Mantid::DataObjects::MDEventsTestHelper::createDiffractionEventWorkspace ( int  numEvents,
int  numPixels = 400,
int  numBins = 160 
)

◆ extents_match()

template<typename MDBOX >
static void Mantid::DataObjects::MDEventsTestHelper::extents_match ( MDBOX  box,
size_t  dim,
double  min,
double  max 
)
static

Helper function compares the extents of the given box.

Definition at line 458 of file MDEventsTestHelper.h.

◆ feedMDBox()

template<size_t nd>
static void Mantid::DataObjects::MDEventsTestHelper::feedMDBox ( MDBoxBase< MDLeanEvent< nd >, nd > *  box,
size_t  repeat = 1,
size_t  numPerSide = 10,
coord_t  start = 0.5,
coord_t  step = 1.0 
)
static

Feed a MDGridBox with evenly-spaced events.

Parameters
box:: MDGridBox pointer
repeat:: how many events to stick in the same place
numPerSide:: e.g. if 10, and 3 dimensions, there will be 10x10x10 events
start:: x-coordinate starts at this for event 0
step:: x-coordinate increases by this much.

Definition at line 374 of file MDEventsTestHelper.h.

References Mantid::Geometry::d, Mantid::Kernel::Utils::NestedForLoop::Increment(), and Mantid::Kernel::Utils::NestedForLoop::SetUp().

◆ makeAnyMDEW()

template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > Mantid::DataObjects::MDEventsTestHelper::makeAnyMDEW ( size_t  splitInto,
coord_t  min,
coord_t  max,
size_t  numEventsPerBox = 0,
const std::string &  wsName = "",
const std::string &  axisNameFormat = "Axis%d",
const std::string &  axisIdFormat = "Axis%d" 
)

Create a test MDEventWorkspace<nd> .

Dimensions are names Axis0, Axis1, etc.

Parameters
splitInto:: each dimension will split into this many subgrids
min:: extent of each dimension (min)
max:: extent of each dimension (max)
numEventsPerBox:: will create one MDLeanEvent in the center of each sub-box. 0 = don't split box, don't add events
wsName:: if specified, then add the workspace to the analysis data service
axisNameFormat:: string for the axis name, processed via sprintf()
axisIdFormat:: string for the axis ID, processed via sprintf()
Returns
shared ptr to the created workspace

Definition at line 189 of file MDEventsTestHelper.h.

References Mantid::Kernel::SingletonHolder< T >::Instance().

◆ makeAnyMDEWWithFrames()

template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > Mantid::DataObjects::MDEventsTestHelper::makeAnyMDEWWithFrames ( size_t  splitInto,
coord_t  min,
coord_t  max,
const Mantid::Geometry::MDFrame frame,
size_t  numEventsPerBox = 0,
const std::string &  wsName = "",
const std::string &  axisNameFormat = "Axis%d",
const std::string &  axisIdFormat = "Axis%d" 
)

Create a test MDEventWorkspace<nd> .

Dimensions are names Axis0, Axis1, etc. But you can set an MDFrame. For now the same frame for all dimensions is used.

Parameters
splitInto:: each dimension will split into this many subgrids
min:: extent of each dimension (min)
max:: extent of each dimension (max)
frame,:the chosen frame
numEventsPerBox:: will create one MDLeanEvent in the center of each sub-box. 0 = don't split box, don't add events
wsName:: if specified, then add the workspace to the analysis data service
axisNameFormat:: string for the axis name, processed via sprintf()
axisIdFormat:: string for the axis ID, processed via sprintf()
Returns
shared ptr to the created workspace

Definition at line 264 of file MDEventsTestHelper.h.

References Mantid::Kernel::SingletonHolder< T >::Instance().

◆ makeAnyMDEWWithIndividualFrames()

template<typename MDE , size_t nd>
std::shared_ptr< Mantid::DataObjects::MDEventWorkspace< MDE, nd > > Mantid::DataObjects::MDEventsTestHelper::makeAnyMDEWWithIndividualFrames ( size_t  splitInto,
coord_t  min,
coord_t  max,
std::vector< Mantid::Geometry::MDFrame_sptr frames,
size_t  numEventsPerBox = 0,
const std::string &  wsName = "",
std::string  axisNameFormat = "Axis%d",
std::string  axisIdFormat = "Axis%d" 
)

Create a test MDEventWorkspace<nd> .

Dimensions are names Axis0, Axis1, etc. But you can set an MDFrame. The frames can be set individually.

Parameters
splitInto:: each dimension will split into this many subgrids
min:: extent of each dimension (min)
max:: extent of each dimension (max)
frames,:the chosen frame
numEventsPerBox:: will create one MDLeanEvent in the center of each sub-box. 0 = don't split box, don't add events
wsName:: if specified, then add the workspace to the analysis data service
axisNameFormat:: string for the axis name, processed via sprintf()
axisIdFormat:: string for the axis ID, processed via sprintf()
Returns
shared ptr to the created workspace

Definition at line 225 of file MDEventsTestHelper.h.

References Mantid::Kernel::SingletonHolder< T >::Instance().

◆ makeFakeMDEventWorkspace()

MDEventWorkspace3Lean::sptr Mantid::DataObjects::MDEventsTestHelper::makeFakeMDEventWorkspace ( const std::string &  wsName,
long  numEvents = 10000,
Kernel::SpecialCoordinateSystem  coord = Kernel::None 
)

Make a (optionally) file backed MDEventWorkspace with 10000 fake random data points.

Make an MDEventWorkspace with nEvents fake data points the points are randomly distributed within the box (nEvents>0) or homoheneously and regularly spread through the box (nEvents<0)

Parameters
wsName:: name of the workspace in ADS
Returns
MDEW sptr
Parameters
wsName:: name of the workspace in ADS
numEvents:: number of events in the target workspace distributed randomly if numEvents>0 or regularly & homogeneously if numEvents<0
coord:: Required coordinate system
Returns
MDEW sptr

Definition at line 137 of file MDEventsTestHelper.cpp.

References Mantid::DataObjects::FakeMD::fill(), Mantid::Kernel::SingletonHolder< T >::Instance(), and Mantid::DataHandling::numEvents().

◆ makeFakeMDHistoWorkspace()

Mantid::DataObjects::MDHistoWorkspace_sptr Mantid::DataObjects::MDEventsTestHelper::makeFakeMDHistoWorkspace ( double  signal,
size_t  numDims,
size_t  numBins,
coord_t  max,
double  errorSquared,
const std::string &  name,
double  numEvents 
)

Make a fake n-dimensional MDHistoWorkspace.

Creates a fake MDHistoWorkspace.

Parameters
signal:: signal in every point
numDims:: number of dimensions to create. They will range from 0 to max
numBins:: bins in each dimensions
max:: max position in each dimension
errorSquared:: error squared in every point
name:: optional name
numEvents:: optional number of events in each bin. Default 1.0
Returns
the MDHisto

Definition at line 217 of file MDEventsTestHelper.cpp.

References Mantid::Geometry::GeneralFrame::GeneralFrameDistance, makeFakeMDHistoWorkspaceWithMDFrame(), and Mantid::DataHandling::numEvents().

Referenced by UnaryOperationMDTestHelper::doTest(), and BinaryOperationMDTestHelper::setUpBinaryOperationMDTestHelper().

◆ makeFakeMDHistoWorkspaceGeneral() [1/2]

MDHistoWorkspace_sptr Mantid::DataObjects::MDEventsTestHelper::makeFakeMDHistoWorkspaceGeneral ( size_t  numDims,
double  signal,
double  errorSquared,
size_t *  numBins,
coord_t min,
coord_t max,
const std::string &  name 
)

More general fake n-dimensionsal MDHistoWorkspace.

Creates a fake MDHistoWorkspace with more options.

Parameters
numDims:: number of dimensions to create. They will range from 0 to max
signal:: signal in every point
errorSquared:: error squared in every point
numBins:: array of # of bins in each dimensions
min:: array of min position in each dimension
max:: array of max position in each dimension
name:: optional name
Returns
the MDHisto

Definition at line 238 of file MDEventsTestHelper.cpp.

References Mantid::Geometry::d, Mantid::Geometry::GeneralFrame::GeneralFrameDistance, and Mantid::Kernel::SingletonHolder< T >::Instance().

◆ makeFakeMDHistoWorkspaceGeneral() [2/2]

MDHistoWorkspace_sptr Mantid::DataObjects::MDEventsTestHelper::makeFakeMDHistoWorkspaceGeneral ( size_t  numDims,
double  signal,
double  errorSquared,
size_t *  numBins,
coord_t min,
coord_t max,
std::vector< std::string >  names,
const std::string &  name 
)

More general fake n-dimensionsal MDHistoWorkspace.

Creates a fake MDHistoWorkspace with more options.

Parameters
numDims:: number of dimensions to create. They will range from 0 to max
signal:: signal in every point
errorSquared:: error squared in every point
numBins:: array of # of bins in each dimensions
min:: array of min position in each dimension
max:: array of max position in each dimension
names:: array of names for each dimension
name:: optional name
Returns
the MDHisto

Definition at line 271 of file MDEventsTestHelper.cpp.

References Mantid::Geometry::d, Mantid::Geometry::GeneralFrame::GeneralFrameDistance, and Mantid::Kernel::SingletonHolder< T >::Instance().

◆ makeFakeMDHistoWorkspaceWithMDFrame()

Mantid::DataObjects::MDHistoWorkspace_sptr Mantid::DataObjects::MDEventsTestHelper::makeFakeMDHistoWorkspaceWithMDFrame ( double  signal,
size_t  numDims,
const Mantid::Geometry::MDFrame frame,
size_t  numBins,
coord_t  max,
double  errorSquared,
const std::string &  name,
double  numEvents 
)

Creates a fake MDHistoWorkspace with MDFrame selection.

Parameters
signal:: signal in every point
numDims:: number of dimensions to create. They will range from 0 to max
frame:: the selected frame
numBins:: bins in each dimensions
max:: max position in each dimension
errorSquared:: error squared in every point
name:: optional name
numEvents:: optional number of events in each bin. Default 1.0
Returns
the MDHisto

Definition at line 303 of file MDEventsTestHelper.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), and Mantid::DataHandling::numEvents().

Referenced by makeFakeMDHistoWorkspace().

◆ makeMDBox1()

MDBox< MDLeanEvent< 1 >, 1 > * Mantid::DataObjects::MDEventsTestHelper::makeMDBox1 ( size_t  splitInto = 10,
API::BoxController splitter = nullptr 
)

Generate an empty MDBox.

Generate an empty MDBox , !!! Box controller has to be deleted saparately to avoid memory leaks in tests !!!!

Definition at line 155 of file MDEventsTestHelper.cpp.

References Mantid::DataObjects::MDBoxBase::setExtents(), Mantid::API::BoxController::setSplitInto(), and Mantid::API::BoxController::setSplitThreshold().

◆ makeMDBox3()

MDBox< MDLeanEvent< 3 >, 3 > * Mantid::DataObjects::MDEventsTestHelper::makeMDBox3 ( )

Generate an empty MDBox with 3 dimensions, split 10x5x2.

Generate an empty MDBox with 3 dimensions, split 10x5x2 !!! Box controller has to be deleted saparately to avoid memory leaks in tests !!!!

Definition at line 174 of file MDEventsTestHelper.cpp.

References Mantid::Geometry::d, and Mantid::DataObjects::MDBoxBase::setExtents().

◆ makeMDEvents1()

std::vector< MDLeanEvent< 1 > > Mantid::DataObjects::MDEventsTestHelper::makeMDEvents1 ( size_t  num)

Return a vector with this many MDEvents, spaced evenly from 0.5, 1.5, etc.

Definition at line 194 of file MDEventsTestHelper.cpp.

◆ makeMDEW()

template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > Mantid::DataObjects::MDEventsTestHelper::makeMDEW ( size_t  splitInto,
coord_t  min,
coord_t  max,
size_t  numEventsPerBox = 0 
)

Make a MDEventWorkspace with MDLeanEvents.

Definition at line 285 of file MDEventsTestHelper.h.

◆ makeMDEWFull()

template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDEvent< nd >, nd > > Mantid::DataObjects::MDEventsTestHelper::makeMDEWFull ( size_t  splitInto,
coord_t  min,
coord_t  max,
size_t  numEventsPerBox = 0 
)

Make a MDEventWorkspace with MDEvents - updated to split dims by splitInto, not 10.

Definition at line 309 of file MDEventsTestHelper.h.

◆ makeMDEWWithFrames()

template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > Mantid::DataObjects::MDEventsTestHelper::makeMDEWWithFrames ( size_t  splitInto,
coord_t  min,
coord_t  max,
const Mantid::Geometry::MDFrame frame,
size_t  numEventsPerBox = 0 
)

Make a MDEventWorkspace with MDLeanEvents nad MDFrames.

Definition at line 292 of file MDEventsTestHelper.h.

◆ makeMDEWWithIndividualFrames()

template<size_t nd>
std::shared_ptr< MDEventWorkspace< MDLeanEvent< nd >, nd > > Mantid::DataObjects::MDEventsTestHelper::makeMDEWWithIndividualFrames ( size_t  splitInto,
coord_t  min,
coord_t  max,
const std::vector< Mantid::Geometry::MDFrame_sptr > &  frame,
size_t  numEventsPerBox = 0 
)

Make a MDEventWorkspace with MDLeanEvents and individual MDFrames.

Definition at line 301 of file MDEventsTestHelper.h.

◆ makeMDGridBox()

template<size_t nd>
static MDGridBox< MDLeanEvent< nd >, nd > * Mantid::DataObjects::MDEventsTestHelper::makeMDGridBox ( size_t  split0 = 10,
size_t  split1 = 10,
coord_t  dimensionMin = 0.0,
coord_t  dimensionMax = 10.0 
)
static

Generate an empty MDBox with 2 dimensions, splitting in (default) 10x10 boxes.

Box size is 10x10.

Parameters
split0:: for uneven splitting
split1:: for uneven splitting
dimensionMin:: minimum dimesion extent
dimensionMax:: maximum dimesion extent

Definition at line 340 of file MDEventsTestHelper.h.

References Mantid::Geometry::d.

◆ makeRecursiveMDGridBox()

template<size_t nd>
static MDGridBox< MDLeanEvent< nd >, nd > * Mantid::DataObjects::MDEventsTestHelper::makeRecursiveMDGridBox ( size_t  splitInto,
size_t  levels 
)
static

Generate a recursively gridded MDGridBox.

Parameters
splitInto:: boxes split into this many boxes/side
levels:: levels of splitting recursion (0=just the top level is split)
Returns

Definition at line 436 of file MDEventsTestHelper.h.

References Mantid::Geometry::d, and recurseSplit().

◆ recurseSplit()

template<size_t nd>
static void Mantid::DataObjects::MDEventsTestHelper::recurseSplit ( MDGridBox< MDLeanEvent< nd >, nd > *  box,
size_t  atRecurseLevel,
size_t  recurseLimit 
)
static

Recursively split an existing MDGridBox.

Parameters
box:: box to split
atRecurseLevel:: This is the recursion level at which we are
recurseLimit:: this is where to spot

Definition at line 406 of file MDEventsTestHelper.h.

References recurseSplit().

Referenced by makeRecursiveMDGridBox(), and recurseSplit().