Mantid
Loading...
Searching...
No Matches
Typedefs | Functions
Mantid::DataHandling::LoadHelper Namespace Reference

LoadHelper : Auxiliary functions for Loading Files. More...

Typedefs

using detid_t = int32_t
 

Functions

void addNexusFieldsToWsRun (Nexus::File &filehandle, API::Run &runDetails, const std::string &entryName="", bool useFullAddress=false)
 Add properties from a nexus file to the workspace run.
 
double calculateEnergy (double)
 Calculate Neutron Energy from wavelength: \( E = h^2 / 2m\lambda ^2 \).
 
double calculateTOF (double, double)
 Calculate TOF from distance.
 
std::string dateTimeInIsoFormat (const std::string &)
 Parses the date as formatted at the ILL: 29-Jun-12 11:27:26 and converts it to the ISO format used in Mantid: ISO8601 format string: "yyyy-mm-ddThh:mm:ss[Z+-]tz:tz".
 
void fillMovingWorkspace (const API::MatrixWorkspace_sptr &, const Mantid::Nexus::NXInt &, const std::vector< double > &xAxis, int64_t initialSpectrum=0, const std::set< detid_t > &acceptedID=std::set< int >(), const std::vector< detid_t > &customID=std::vector< int >(), const std::tuple< short, short, short > &axisOrder=std::tuple< short, short, short >(0, 1, 2))
 Fills workspace with histogram data from provided data structure.
 
void fillStaticWorkspace (const API::MatrixWorkspace_sptr &, const Mantid::Nexus::NXInt &, const std::vector< double > &xAxis, int64_t initialSpectrum=0, bool pointData=false, const std::vector< detid_t > &detectorIDs=std::vector< int >(), const std::set< detid_t > &acceptedID=std::set< int >(), const std::tuple< short, short, short > &axisOrder=std::tuple< short, short, short >(0, 1, 2))
 Fills workspace with histogram data from provided data structure.
 
std::string findInstrumentNexusAddress (const Mantid::Nexus::NXEntry &)
 Finds the address for the instrument name in the nexus file Usually of the form: entry0/<NXinstrument class>/name.
 
Kernel::V3D getComponentPosition (const API::MatrixWorkspace_sptr &ws, const std::string &componentName)
 LoadHelper::getComponentPosition.
 
Nexus::NXDouble getDoubleDataset (const Nexus::NXEntry &, const std::string &)
 Fetches NXDouble data from the requested group name in the entry provided.
 
double getDoubleFromNexusAddress (const Mantid::Nexus::NXEntry &, const std::string &)
 
double getInstrumentProperty (const API::MatrixWorkspace_sptr &, const std::string &)
 
Nexus::NXInt getIntDataset (const Nexus::NXEntry &, const std::string &)
 Fetches NXInt data from the requested group name in the entry provided.
 
std::string getStringFromNexusAddress (const Mantid::Nexus::NXEntry &, const std::string &)
 
std::vector< double > getTimeBinningFromNexusAddress (const Mantid::Nexus::NXEntry &, const std::string &)
 Gets the time binning from a Nexus float array Adds an extra bin at the end.
 
void loadEmptyInstrument (const API::MatrixWorkspace_sptr &ws, const std::string &instrumentName, const std::string &instrumentAddress="")
 Loads empty instrument of chosen name into a provided workspace.
 
void loadingOrder (const std::tuple< short, short, short > &axisOrder, int *dataIndices)
 Handles non-standard loading order of the provided data, based on the provided data dimension order.
 
void moveComponent (const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::V3D &newPos)
 LoadHelper::moveComponent.
 
void recurseAndAddNexusFieldsToWsRun (Nexus::File &filehandle, API::Run &runDetails, const std::string &parent_name, const std::string &parent_class, int level, bool useFullAddress)
 Recursively add properties from a nexus file to the workspace run.
 
void replaceZeroErrors (const API::MatrixWorkspace_sptr &, double)
 Replaces errors of bins with zero counts with provided value.
 
void rotateComponent (const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::Quat &rot)
 LoadHelper::rotateComponent.
 

Detailed Description

LoadHelper : Auxiliary functions for Loading Files.

Typedef Documentation

◆ detid_t

Definition at line 23 of file LoadHelper.h.

Function Documentation

◆ addNexusFieldsToWsRun()

void Mantid::DataHandling::LoadHelper::addNexusFieldsToWsRun ( Nexus::File &  filehandle,
API::Run runDetails,
const std::string &  entryName = "",
bool  useFullAddress = false 
)

Add properties from a nexus file to the workspace run.

API entry for recursive routine below

Parameters
filehandle:: Nexus file handle to be parsed, just after an NXopengroup
runDetails:: where to add properties
entryName:: entry name to load properties from
useFullAddress:: use full address to entry in nexus tree to generate the log entry name in Mantid

Definition at line 128 of file LoadHelper.cpp.

References recurseAndAddNexusFieldsToWsRun().

Referenced by Mantid::DataHandling::LoadILLTOF3::addAllNexusFieldsAsProperties(), Mantid::DataHandling::LoadILLSALSA::fillWorkspaceMetadata(), Mantid::DataHandling::LoadEventNexus::loadEvents(), Mantid::DataHandling::LoadILLDiffraction::loadMetaData(), Mantid::DataHandling::LoadILLLagrange::loadMetaData(), Mantid::DataHandling::LoadILLPolarizedDiffraction::loadMetaData(), Mantid::DataHandling::LoadILLReflectometry::loadNexusEntriesIntoProperties(), Mantid::DataHandling::LoadILLIndirect2::loadNexusEntriesIntoProperties(), and Mantid::DataHandling::LoadILLSANS::setFinalProperties().

◆ calculateEnergy()

double Mantid::DataHandling::LoadHelper::calculateEnergy ( double  wavelength)

Calculate Neutron Energy from wavelength: \( E = h^2 / 2m\lambda ^2 \).

Parameters
wavelength:: wavelength in \( \mbox{\AA} \)
Returns
tof in seconds

Definition at line 83 of file LoadHelper.cpp.

References Mantid::PhysicalConstants::h, Mantid::PhysicalConstants::meV, and Mantid::PhysicalConstants::NeutronMass.

Referenced by Mantid::DataHandling::LoadILLTOF2::addEnergyToRun(), Mantid::DataHandling::LoadILLTOF3::addEnergyToRun(), Mantid::DataHandling::LoadILLSANS::loadMetaData(), and Mantid::DataHandling::LoadMLZ::loadRunDetails().

◆ calculateTOF()

double Mantid::DataHandling::LoadHelper::calculateTOF ( double  distance,
double  wavelength 
)

Calculate TOF from distance.

Parameters
distance:: distance in meters
wavelength:: wavelength to calculate TOF from
Returns
tof in seconds

Definition at line 95 of file LoadHelper.cpp.

References Mantid::PhysicalConstants::h, and Mantid::PhysicalConstants::NeutronMass.

Referenced by Mantid::DataHandling::LoadMLZ::loadDataIntoTheWorkSpace().

◆ dateTimeInIsoFormat()

std::string Mantid::DataHandling::LoadHelper::dateTimeInIsoFormat ( const std::string &  dateToParse)

Parses the date as formatted at the ILL: 29-Jun-12 11:27:26 and converts it to the ISO format used in Mantid: ISO8601 format string: "yyyy-mm-ddThh:mm:ss[Z+-]tz:tz".

Parameters
dateToParse:: date as string
Returns
date as required in Mantid

Definition at line 302 of file LoadHelper.cpp.

Referenced by Mantid::DataHandling::LoadILLPolarizedDiffraction::loadData(), Mantid::DataHandling::LoadILLReflectometry::loadDataDetails(), Mantid::DataHandling::LoadILLDiffraction::loadDataScan(), Mantid::DataHandling::LoadILLSANS::loadMetaData(), Mantid::DataHandling::LegacyLoadHelper::recurseAndAddNexusFieldsToWsRun(), and recurseAndAddNexusFieldsToWsRun().

◆ fillMovingWorkspace()

void Mantid::DataHandling::LoadHelper::fillMovingWorkspace ( const API::MatrixWorkspace_sptr ws,
const Mantid::Nexus::NXInt data,
const std::vector< double > &  xAxis,
int64_t  initialSpectrum = 0,
const std::set< detid_t > &  acceptedDetectorIDs = std::set<int>(),
const std::vector< detid_t > &  customDetectorIDs = std::vector<int>(),
const std::tuple< short, short, short > &  axisOrder = std::tuple<short, short, short>(0, 1, 2) 
)

Fills workspace with histogram data from provided data structure.

Parameters
wsA MatrixWorkspace to be filled with data
dataData object to extract counts from
xAxisX axis values to be assigned to each spectrum
initialSpectrumInitial spectrum number, optional and defaults to 0
acceptedDetectorIDsSet of accepted detector IDs, defaults to empty (all accepted)
customDetectorIDsVector of custom detector IDs to replace the default detectorID calculation, defaults to empty (default calculation)
axisOrderTuple containing description of axis order of 3D Nexus data, defaults to 0,1,2 meaning tube-pixel-channel order

Definition at line 495 of file LoadHelper.cpp.

References Mantid::Nexus::NXDataSet::dim0(), Mantid::Nexus::NXDataSet::dim1(), and Mantid::Nexus::NXDataSet::dim2().

Referenced by Mantid::DataHandling::LoadILLDiffraction::fillMovingInstrumentScan().

◆ fillStaticWorkspace()

void Mantid::DataHandling::LoadHelper::fillStaticWorkspace ( const API::MatrixWorkspace_sptr ws,
const Mantid::Nexus::NXInt data,
const std::vector< double > &  xAxis,
int64_t  initialSpectrum = 0,
bool  pointData = false,
const std::vector< detid_t > &  detectorIDs = std::vector<int>(),
const std::set< detid_t > &  acceptedDetectorIDs = std::set<int>(),
const std::tuple< short, short, short > &  axisOrder = std::tuple<short, short, short>(0, 1, 2) 
)

Fills workspace with histogram data from provided data structure.

Parameters
wsA MatrixWorkspace to be filled with data
dataData object to extract counts from
xAxisX axis values to be assigned to each spectrum
initialSpectrumInitial spectrum number, optional and defaults to 0
pointDataSwitch to decide whether the data is going to be a histogram or point data, defaults to false (histogram)
detectorIDsVector of detector IDs to override the default spectrum number, defaults to empty (IDs equal to index)
acceptedDetectorIDsSet of accepted detector IDs, defaults to empty (all accepted)
axisOrderTuple containing information at which position in data one can find tubes, pixels, and channels (scans), defaults to 0,1,2 meaning default order of tube-pixel-channel

Definition at line 412 of file LoadHelper.cpp.

References Mantid::Nexus::NXDataSet::dim0(), Mantid::Nexus::NXDataSet::dim1(), Mantid::Nexus::NXDataSet::dim2(), loadingOrder(), and Mantid::Kernel::V3D::size().

Referenced by Mantid::DataHandling::LoadILLTOF3::fillScanWorkspace(), Mantid::DataHandling::LoadILLDiffraction::fillStaticInstrumentScan(), Mantid::DataHandling::LoadILLTOF3::fillStaticWorkspace(), Mantid::DataHandling::LoadILLPolarizedDiffraction::loadData(), Mantid::DataHandling::LoadILLReflectometry::loadData(), Mantid::DataHandling::LoadILLSANS::loadDataFromMonitors(), Mantid::DataHandling::LoadILLSANS::loadDataFromTubes(), and Mantid::DataHandling::LoadILLIndirect2::loadDataIntoWorkspace().

◆ findInstrumentNexusAddress()

std::string Mantid::DataHandling::LoadHelper::findInstrumentNexusAddress ( const Mantid::Nexus::NXEntry firstEntry)

◆ getComponentPosition()

V3D Mantid::DataHandling::LoadHelper::getComponentPosition ( const API::MatrixWorkspace_sptr ws,
const std::string &  componentName 
)

◆ getDoubleDataset()

Nexus::NXDouble Mantid::DataHandling::LoadHelper::getDoubleDataset ( const Nexus::NXEntry entry,
const std::string &  groupName 
)

Fetches NXDouble data from the requested group name in the entry provided.

Parameters
entryNXEntry where desired data can be found
groupNameFull name of the data group
Returns
NXDouble data object

Definition at line 568 of file LoadHelper.cpp.

References Mantid::Nexus::NXData::openDoubleData(), and Mantid::Nexus::NXEntry::openNXData().

Referenced by Mantid::DataHandling::LoadILLTOF3::fillScanWorkspace(), Mantid::DataHandling::LoadILLSANS::getOmegaBinning(), Mantid::DataHandling::LoadILLSANS::loadDataFromD16ScanMonitors(), Mantid::DataHandling::LoadILLDiffraction::loadDataScan(), and Mantid::DataHandling::LoadILLTOF3::prepareAxis().

◆ getDoubleFromNexusAddress()

double Mantid::DataHandling::LoadHelper::getDoubleFromNexusAddress ( const Mantid::Nexus::NXEntry firstEntry,
const std::string &  nexusAddress 
)

◆ getInstrumentProperty()

double Mantid::DataHandling::LoadHelper::getInstrumentProperty ( const API::MatrixWorkspace_sptr workspace,
const std::string &  s 
)

Definition at line 110 of file LoadHelper.cpp.

References Mantid::EMPTY_DBL(), and workspace.

◆ getIntDataset()

Nexus::NXInt Mantid::DataHandling::LoadHelper::getIntDataset ( const Nexus::NXEntry entry,
const std::string &  groupName 
)

◆ getStringFromNexusAddress()

std::string Mantid::DataHandling::LoadHelper::getStringFromNexusAddress ( const Mantid::Nexus::NXEntry firstEntry,
const std::string &  nexusAddress 
)

◆ getTimeBinningFromNexusAddress()

std::vector< double > Mantid::DataHandling::LoadHelper::getTimeBinningFromNexusAddress ( const Mantid::Nexus::NXEntry firstEntry,
const std::string &  nexusAddress 
)

◆ loadEmptyInstrument()

void Mantid::DataHandling::LoadHelper::loadEmptyInstrument ( const API::MatrixWorkspace_sptr ws,
const std::string &  instrumentName,
const std::string &  instrumentPath = "" 
)

◆ loadingOrder()

void Mantid::DataHandling::LoadHelper::loadingOrder ( const std::tuple< short, short, short > &  dataOrder,
int *  dataIndices 
)

Handles non-standard loading order of the provided data, based on the provided data dimension order.

Parameters
dataOrdertuple containing where tubes, pixels, and channels (scans) can be found in data
dataIndicespointer to the array containing data indices to be set

Definition at line 474 of file LoadHelper.cpp.

Referenced by fillStaticWorkspace(), and Mantid::DataHandling::LegacyLoadHelper::fillStaticWorkspace().

◆ moveComponent()

void Mantid::DataHandling::LoadHelper::moveComponent ( const API::MatrixWorkspace_sptr ws,
const std::string &  componentName,
const Kernel::V3D newPos 
)

LoadHelper::moveComponent.

Parameters
wsA MatrixWorkspace
componentNameThe name of the component of the instrument
newPosNew position of the component

Definition at line 335 of file LoadHelper.cpp.

Referenced by Mantid::DataHandling::LoadILLReflectometry::placeDetector(), Mantid::DataHandling::LoadSwans::placeDetectorInSpace(), Mantid::DataHandling::LoadILLReflectometry::placeSlits(), and Mantid::DataHandling::LoadILLReflectometry::placeSource().

◆ recurseAndAddNexusFieldsToWsRun()

void Mantid::DataHandling::LoadHelper::recurseAndAddNexusFieldsToWsRun ( Nexus::File &  filehandle,
API::Run runDetails,
const std::string &  parent_name,
const std::string &  parent_class,
int  level,
bool  useFullAddress 
)

Recursively add properties from a nexus file to the workspace run.

Parameters
filehandle:: Nexus file handle to be parsed, just after an NXopengroup
runDetails:: where to add properties
parent_name:: nexus caller name
parent_class:: nexus caller class
level:: current level in nexus tree
useFullAddress:: use full address to entry in nexus tree to generate the log entry name in Mantid

Definition at line 199 of file LoadHelper.cpp.

References Mantid::API::LogManager::addProperty(), NXnumtype::CHAR, dateTimeInIsoFormat(), Mantid::Nexus::Info::dims, NXnumtype::FLOAT32, NXnumtype::FLOAT64, Mantid::API::g_log, Mantid::API::LogManager::getProperty(), Mantid::API::LogManager::hasProperty(), NXnumtype::INT16, NXnumtype::INT32, recurseAndAddNexusFieldsToWsRun(), Mantid::Kernel::Property::setValue(), Mantid::Nexus::Info::type, NXnumtype::UINT16, and Mantid::Kernel::Logger::warning().

Referenced by addNexusFieldsToWsRun(), and recurseAndAddNexusFieldsToWsRun().

◆ replaceZeroErrors()

void Mantid::DataHandling::LoadHelper::replaceZeroErrors ( const API::MatrixWorkspace_sptr ws,
double  zeroCountsError 
)

Replaces errors of bins with zero counts with provided value.

Parameters
wsMatrixWorkspace to have its zero errors replaced
zeroCountsErrorValue to replace default error of square root of counts

Definition at line 543 of file LoadHelper.cpp.

References error.

Referenced by Mantid::DataHandling::LoadILLPolarizedDiffraction::loadData().

◆ rotateComponent()

void Mantid::DataHandling::LoadHelper::rotateComponent ( const API::MatrixWorkspace_sptr ws,
const std::string &  componentName,
const Kernel::Quat rot 
)

LoadHelper::rotateComponent.

Parameters
wsA MantrixWorkspace
componentNameThe Name of the component of the instrument
rotRotations defined by setting a quaternion from an angle in degrees and an axis

Definition at line 353 of file LoadHelper.cpp.

Referenced by Mantid::DataHandling::LoadILLReflectometry::placeDetector(), and Mantid::DataHandling::LoadSwans::placeDetectorInSpace().