diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index 9b2806ebd75091fc520e815837903575cc5d688f..d1059887d1cd238904ed7b7725476688564b18f5 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -67,7 +67,7 @@ void copyLogs(const Mantid::DataHandling::EventWorkspaceCollection_sptr &from, } } } -} // namespace +} //============================================================================================== // Class LoadBankFromDiskTask @@ -626,7 +626,7 @@ private: //---------------------------------------------------------------------------------------------- /** Empty default constructor - */ +*/ LoadEventNexus::LoadEventNexus() : IFileLoader<Kernel::NexusDescriptor>(), m_filename(), filter_tof_min(0), filter_tof_max(0), m_specList(), m_specMin(0), m_specMax(0), @@ -650,11 +650,11 @@ LoadEventNexus::~LoadEventNexus() { //---------------------------------------------------------------------------------------------- /** - * Return the confidence with with this algorithm can load the file - * @param descriptor A descriptor for the file - * @returns An integer specifying the confidence level. 0 indicates it will not - * be used - */ +* Return the confidence with with this algorithm can load the file +* @param descriptor A descriptor for the file +* @returns An integer specifying the confidence level. 0 indicates it will not +* be used +*/ int LoadEventNexus::confidence(Kernel::NexusDescriptor &descriptor) const { int confidence(0); if (descriptor.classTypeExists("NXevent_data")) { @@ -668,7 +668,7 @@ int LoadEventNexus::confidence(Kernel::NexusDescriptor &descriptor) const { //---------------------------------------------------------------------------------------------- /** Initialisation method. - */ +*/ void LoadEventNexus::init() { const std::vector<std::string> exts{"_event.nxs", ".nxs.h5", ".nxs"}; this->declareProperty( @@ -871,7 +871,7 @@ void LoadEventNexus::init() { //---------------------------------------------------------------------------------------------- /** set the name of the top level NXentry m_top_entry_name - */ +*/ void LoadEventNexus::setTopEntryName() { std::string nxentryProperty = getProperty("NXentryName"); if (!nxentryProperty.empty()) { @@ -937,8 +937,8 @@ void LoadEventNexus::filterDuringPause<EventWorkspaceCollection_sptr>( //------------------------------------------------------------------------------------------------ /** Executes the algorithm. Reading in the file and creating and populating - * the output workspace - */ +* the output workspace +*/ void LoadEventNexus::exec() { // Retrieve the filename from the properties m_filename = getPropertyValue("Filename"); @@ -1072,16 +1072,16 @@ void LoadEventNexus::makeMapToEventLists(std::vector<std::vector<T>> &vectors) { } /** - * Get the number of events in the currently opened group. - * - * @param file The handle to the nexus file opened to the group to look at. - * @param hasTotalCounts Whether to try looking at the total_counts field. This - * variable will be changed if the field is not there. - * @param oldNeXusFileNames Whether to try using old names. This variable will - * be changed if it is determined that old names are being used. - * - * @return The number of events. - */ +* Get the number of events in the currently opened group. +* +* @param file The handle to the nexus file opened to the group to look at. +* @param hasTotalCounts Whether to try looking at the total_counts field. This +* variable will be changed if the field is not there. +* @param oldNeXusFileNames Whether to try using old names. This variable will +* be changed if it is determined that old names are being used. +* +* @return The number of events. +*/ std::size_t numEvents(::NeXus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames) { // try getting the value of total_counts @@ -1133,18 +1133,18 @@ void LoadEventNexus::createWorkspaceIndexMaps( } /** Load the instrument from the nexus file - * - * @param nexusfilename :: The name of the nexus file being loaded - * @param localWorkspace :: Templated workspace in which to put the instrument - *geometry - * @param alg :: Handle of the algorithm - * @param returnpulsetimes :: flag to return shared pointer for BankPulseTimes, - *otherwise NULL. - * @param nPeriods : Number of periods (write to) - * @param periodLog : Period logs DateAndTime to int map. - * - * @return Pulse times given in the DAS logs - */ +* +* @param nexusfilename :: The name of the nexus file being loaded +* @param localWorkspace :: Templated workspace in which to put the instrument +*geometry +* @param alg :: Handle of the algorithm +* @param returnpulsetimes :: flag to return shared pointer for BankPulseTimes, +*otherwise NULL. +* @param nPeriods : Number of periods (write to) +* @param periodLog : Period logs DateAndTime to int map. +* +* @return Pulse times given in the DAS logs +*/ template <typename T> boost::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs( const std::string &nexusfilename, T localWorkspace, API::Algorithm &alg, @@ -1227,19 +1227,19 @@ boost::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs( } /** Load the instrument from the nexus file - * - * @param nexusfilename :: The name of the nexus file being loaded - * @param localWorkspace :: EventWorkspaceCollection in which to put the - *instrument - *geometry - * @param alg :: Handle of the algorithm - * @param returnpulsetimes :: flag to return shared pointer for BankPulseTimes, - *otherwise NULL. - * @param nPeriods : Number of periods (write to) - * @param periodLog : Period logs DateAndTime to int map. - * - * @return Pulse times given in the DAS logs - */ +* +* @param nexusfilename :: The name of the nexus file being loaded +* @param localWorkspace :: EventWorkspaceCollection in which to put the +*instrument +*geometry +* @param alg :: Handle of the algorithm +* @param returnpulsetimes :: flag to return shared pointer for BankPulseTimes, +*otherwise NULL. +* @param nPeriods : Number of periods (write to) +* @param periodLog : Period logs DateAndTime to int map. +* +* @return Pulse times given in the DAS logs +*/ template <> boost::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs<EventWorkspaceCollection_sptr>( @@ -1255,15 +1255,15 @@ LoadEventNexus::runLoadNexusLogs<EventWorkspaceCollection_sptr>( //----------------------------------------------------------------------------- /** - * Load events from the file. - * @param prog :: A pointer to the progress reporting object - * @param monitors :: If true the events from the monitors are loaded and not - *the main banks - * - * This also loads the instrument, but only if it has not been set in the - *workspace - * being used as input (m_ws data member). Same applies to the logs. - */ +* Load events from the file. +* @param prog :: A pointer to the progress reporting object +* @param monitors :: If true the events from the monitors are loaded and not the +* main banks +* +* This also loads the instrument, but only if it has not been set in the +*workspace +* being used as input (m_ws data member). Same applies to the logs. +*/ void LoadEventNexus::loadEvents(API::Progress *const prog, const bool monitors) { bool metaDataOnly = getProperty("MetaDataOnly"); @@ -1649,15 +1649,15 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, //----------------------------------------------------------------------------- /** Load the instrument from the nexus file - * - * @param nexusfilename :: The name of the nexus file being loaded - * @param localWorkspace :: EventWorkspaceCollection in which to put the - *instrument - *geometry - * @param top_entry_name :: entry name at the top of the Nexus file - * @param alg :: Handle of the algorithm - * @return true if successful - */ +* +* @param nexusfilename :: The name of the nexus file being loaded +* @param localWorkspace :: EventWorkspaceCollection in which to put the +*instrument +*geometry +* @param top_entry_name :: entry name at the top of the Nexus file +* @param alg :: Handle of the algorithm +* @return true if successful +*/ template <> bool LoadEventNexus::runLoadIDFFromNexus<EventWorkspaceCollection_sptr>( const std::string &nexusfilename, @@ -1671,9 +1671,9 @@ bool LoadEventNexus::runLoadIDFFromNexus<EventWorkspaceCollection_sptr>( } /** method used to return instrument name for some old ISIS files where it is - * not written properly within the instrument - * @param hFile :: A reference to the NeXus file opened at the root entry - */ +* not written properly within the instrument +* @param hFile :: A reference to the NeXus file opened at the root entry +*/ std::string LoadEventNexus::readInstrumentFromISIS_VMSCompat(::NeXus::File &hFile) { std::string instrumentName; @@ -1698,16 +1698,16 @@ LoadEventNexus::readInstrumentFromISIS_VMSCompat(::NeXus::File &hFile) { //----------------------------------------------------------------------------- /** Load the instrument definition file specified by info in the NXS file for - * a EventWorkspaceCollection - * - * @param nexusfilename :: Used to pick the instrument. - * @param localWorkspace :: EventWorkspaceCollection in which to put the - *instrument - *geometry - * @param top_entry_name :: entry name at the top of the NXS file - * @param alg :: Handle of the algorithm - * @return true if successful - */ +* a EventWorkspaceCollection +* +* @param nexusfilename :: Used to pick the instrument. +* @param localWorkspace :: EventWorkspaceCollection in which to put the +*instrument +*geometry +* @param top_entry_name :: entry name at the top of the NXS file +* @param alg :: Handle of the algorithm +* @return true if successful +*/ template <> bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>( const std::string &nexusfilename, @@ -1722,10 +1722,10 @@ bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>( //----------------------------------------------------------------------------- /** - * Deletes banks for a workspace given the bank names. - * @param workspace :: The workspace to contain the spectra mapping - * @param bankNames :: Bank names that are in Nexus file - */ +* Deletes banks for a workspace given the bank names. +* @param workspace :: The workspace to contain the spectra mapping +* @param bankNames :: Bank names that are in Nexus file +*/ void LoadEventNexus::deleteBanks(EventWorkspaceCollection_sptr workspace, std::vector<std::string> bankNames) { Instrument_sptr inst = boost::const_pointer_cast<Instrument>( @@ -1810,15 +1810,15 @@ void LoadEventNexus::deleteBanks(EventWorkspaceCollection_sptr workspace, } //----------------------------------------------------------------------------- /** - * Create the required spectra mapping. If the file contains an isis_vms_compat - * block then - * the mapping is read from there, otherwise a 1:1 map with the instrument is - * created (along - * with the associated spectra axis) - * @param nxsfile :: The name of a nexus file to load the mapping from - * @param monitorsOnly :: Load only the monitors is true - * @param bankNames :: An optional bank name for loading specified banks - */ +* Create the required spectra mapping. If the file contains an isis_vms_compat +* block then +* the mapping is read from there, otherwise a 1:1 map with the instrument is +* created (along +* with the associated spectra axis) +* @param nxsfile :: The name of a nexus file to load the mapping from +* @param monitorsOnly :: Load only the monitors is true +* @param bankNames :: An optional bank name for loading specified banks +*/ void LoadEventNexus::createSpectraMapping( const std::string &nxsfile, const bool monitorsOnly, const std::vector<std::string> &bankNames) { @@ -1876,9 +1876,9 @@ void LoadEventNexus::createSpectraMapping( //----------------------------------------------------------------------------- /** - * Returns whether the file contains monitors with events in them - * @returns True if the file contains monitors with event data, false otherwise - */ +* Returns whether the file contains monitors with events in them +* @returns True if the file contains monitors with event data, false otherwise +*/ bool LoadEventNexus::hasEventMonitors() { bool result(false); // Determine whether to load histograms or events @@ -1905,16 +1905,16 @@ bool LoadEventNexus::hasEventMonitors() { } /** - * Load the Monitors from the NeXus file into an event workspace. A - * new event workspace is created and associated to the data - * workspace. The name of the new event workspace is contructed by - * appending '_monitors' to the base workspace name. - * - * This is used when the property "MonitorsAsEvents" is enabled, and - * there are monitors with events. - * - * @param prog :: progress reporter - */ +* Load the Monitors from the NeXus file into an event workspace. A +* new event workspace is created and associated to the data +* workspace. The name of the new event workspace is contructed by +* appending '_monitors' to the base workspace name. +* +* This is used when the property "MonitorsAsEvents" is enabled, and +* there are monitors with events. +* +* @param prog :: progress reporter +*/ void LoadEventNexus::runLoadMonitorsAsEvents(API::Progress *const prog) { try { // Note the reuse of the m_ws member variable below. Means I need to grab a @@ -1980,13 +1980,13 @@ void LoadEventNexus::runLoadMonitorsAsEvents(API::Progress *const prog) { //----------------------------------------------------------------------------- /** - * Load the Monitors from the NeXus file into a workspace. The original - * workspace name is used and appended with _monitors. - * - * This is used when the property "MonitorsAsEvents" is not - * enabled, and uses LoadNexusMonitors to load monitor data into a - * Workspace2D. - */ +* Load the Monitors from the NeXus file into a workspace. The original +* workspace name is used and appended with _monitors. +* +* This is used when the property "MonitorsAsEvents" is not +* enabled, and uses LoadNexusMonitors to load monitor data into a +* Workspace2D. +*/ void LoadEventNexus::runLoadMonitors() { std::string mon_wsname = this->getProperty("OutputWorkspace"); mon_wsname.append("_monitors"); @@ -2163,10 +2163,10 @@ bool LoadEventNexus::loadSpectraMapping(const std::string &filename, } /** - * Set the filters on TOF. - * @param monitors :: If true check the monitor properties else use the standard - * ones - */ +* Set the filters on TOF. +* @param monitors :: If true check the monitor properties else use the standard +* ones +*/ void LoadEventNexus::setTimeFilters(const bool monitors) { // Get the limits to the filter std::string prefix("Filter"); @@ -2194,12 +2194,12 @@ void LoadEventNexus::setTimeFilters(const bool monitors) { // ISIS event corrections //----------------------------------------------------------------------------- /** - * Check if time_of_flight can be found in the file and load it - * - * @param WS :: The event workspace collection which events will be modified. - * @param entry_name :: An NXentry tag in the file - * @param classType :: The type of the events: either detector or monitor - */ +* Check if time_of_flight can be found in the file and load it +* +* @param WS :: The event workspace collection which events will be modified. +* @param entry_name :: An NXentry tag in the file +* @param classType :: The type of the events: either detector or monitor +*/ void LoadEventNexus::loadTimeOfFlight(EventWorkspaceCollection_sptr WS, const std::string &entry_name, const std::string &classType) { @@ -2304,14 +2304,14 @@ void LoadEventNexus::loadTimeOfFlight(EventWorkspaceCollection_sptr WS, //----------------------------------------------------------------------------- /** - * Load the time of flight data. file must have open the group containing - * "time_of_flight" data set. - * @param file :: The nexus file to read from. - * @param WS :: The event workspace collection to write to. - * @param binsName :: bins name - * @param start_wi :: First workspace index to process - * @param end_wi :: Last workspace index to process - */ +* Load the time of flight data. file must have open the group containing +* "time_of_flight" data set. +* @param file :: The nexus file to read from. +* @param WS :: The event workspace collection to write to. +* @param binsName :: bins name +* @param start_wi :: First workspace index to process +* @param end_wi :: Last workspace index to process +*/ void LoadEventNexus::loadTimeOfFlightData(::NeXus::File &file, EventWorkspaceCollection_sptr WS, const std::string &binsName, @@ -2391,19 +2391,19 @@ void LoadEventNexus::loadTimeOfFlightData(::NeXus::File &file, } /** - * Load information of the sample. It is valid only for ISIS it get the - * information from the group isis_vms_compat. - * - * If it does not find this group, it assumes that there is nothing to do. - * But, if the information is there, but not in the way it was expected, it - * will log the occurrence. - * - * @note: It does essentially the same thing of the - * method: LoadISISNexus2::loadSampleData - * - * @param file : handle to the nexus file - * @param WS : pointer to the workspace - */ +* Load information of the sample. It is valid only for ISIS it get the +* information from the group isis_vms_compat. +* +* If it does not find this group, it assumes that there is nothing to do. +* But, if the information is there, but not in the way it was expected, it +* will log the occurrence. +* +* @note: It does essentially the same thing of the +* method: LoadISISNexus2::loadSampleData +* +* @param file : handle to the nexus file +* @param WS : pointer to the workspace +*/ void LoadEventNexus::loadSampleDataISIScompatibility( ::NeXus::File &file, EventWorkspaceCollection &WS) { try { @@ -2436,12 +2436,12 @@ void LoadEventNexus::loadSampleDataISIScompatibility( } /** - * Check the validity of the optional spectrum range/list provided and identify - *if partial data should be loaded. - * - * @param min :: The minimum spectrum number read from file - * @param max :: The maximum spectrum number read from file - */ +* Check the validity of the optional spectrum range/list provided and identify +*if partial data should be loaded. +* +* @param min :: The minimum spectrum number read from file +* @param max :: The maximum spectrum number read from file +*/ void LoadEventNexus::createSpectraList(int32_t min, int32_t max) { diff --git a/Framework/DataHandling/src/LoadMuonNexus2.cpp b/Framework/DataHandling/src/LoadMuonNexus2.cpp index 30ab316243735282f2da77d60afaf1ece41d06c3..05ecbd642c14f5b23088b0d45aef72ca00b6b492 100644 --- a/Framework/DataHandling/src/LoadMuonNexus2.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus2.cpp @@ -45,11 +45,11 @@ using namespace Mantid::NeXus; LoadMuonNexus2::LoadMuonNexus2() : LoadMuonNexus() {} /** Executes the right version of the muon nexus loader: versions 1 or 2. - * - * @throw Exception::FileError If the Nexus file cannot be found/opened - * @throw std::invalid_argument If the optional properties are set to invalid - *values - */ +* +* @throw Exception::FileError If the Nexus file cannot be found/opened +* @throw std::invalid_argument If the optional properties are set to invalid +*values +*/ void LoadMuonNexus2::exec() { std::string filePath = getPropertyValue("Filename"); LoadMuonNexus1 load1; @@ -81,11 +81,11 @@ void LoadMuonNexus2::exec() { } /** Read in a muon nexus file of the version 2. - * - * @throw Exception::FileError If the Nexus file cannot be found/opened - * @throw std::invalid_argument If the optional properties are set to invalid - *values - */ +* +* @throw Exception::FileError If the Nexus file cannot be found/opened +* @throw std::invalid_argument If the optional properties are set to invalid +*values +*/ void LoadMuonNexus2::doExec() { // Create the root Nexus class NXRoot root(getPropertyValue("Filename")); @@ -299,8 +299,8 @@ void LoadMuonNexus2::doExec() { } /** loadData - * Load the counts data from an NXInt into a workspace - */ +* Load the counts data from an NXInt into a workspace +*/ Histogram LoadMuonNexus2::loadData(const BinEdges &edges, const Mantid::NeXus::NXInt &counts, int period, int spec) { @@ -321,11 +321,11 @@ Histogram LoadMuonNexus2::loadData(const BinEdges &edges, } /** Load logs from Nexus file. Logs are expected to be in - * /run/sample group of the file. - * @param ws :: The workspace to load the logs to. - * @param entry :: The Nexus entry - * @param period :: The period of this workspace - */ +* /run/sample group of the file. +* @param ws :: The workspace to load the logs to. +* @param entry :: The Nexus entry +* @param period :: The period of this workspace +*/ void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, int period) { // Avoid compiler warning @@ -361,8 +361,8 @@ void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, } /** Log the run details from the file - * @param localWorkspace :: The workspace details to use - */ +* @param localWorkspace :: The workspace details to use +*/ void LoadMuonNexus2::loadRunDetails( DataObjects::Workspace2D_sptr localWorkspace) { API::Run &runDetails = localWorkspace->mutableRun(); diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index c151d0b40ec51d7c02ff64c96491f3e34df252ac..e061969627b8b7f4f0ff330e449d63c895d4f5d0 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -111,9 +111,9 @@ void LoadNexusMonitors2::init() { //------------------------------------------------------------------------------ /** - * Executes the algorithm. Reading in the file and creating and populating - * the output workspace - */ +* Executes the algorithm. Reading in the file and creating and populating +* the output workspace +*/ void LoadNexusMonitors2::exec() { // Retrieve the filename from the properties m_filename = this->getPropertyValue("Filename"); @@ -368,12 +368,12 @@ void LoadNexusMonitors2::exec() { //------------------------------------------------------------------------------ /** - * Can we get a histogram (non event data) for every monitor? - * - * @param file :: NeXus file object (open) - * @param monitorNames :: names of monitors of interest - * @return If there seems to be histograms for all monitors (they have "data") - **/ +* Can we get a histogram (non event data) for every monitor? +* +* @param file :: NeXus file object (open) +* @param monitorNames :: names of monitors of interest +* @return If there seems to be histograms for all monitors (they have "data") +**/ bool LoadNexusMonitors2::allMonitorsHaveHistoData( ::NeXus::File &file, const std::vector<std::string> &monitorNames) { bool res = true; @@ -394,14 +394,14 @@ bool LoadNexusMonitors2::allMonitorsHaveHistoData( //------------------------------------------------------------------------------ /** - * Fix the detector numbers if the defaults are not correct. Currently checks - * the isis_vms_compat block and reads them from there if possible. - * - * @param det_ids :: An array of prefilled detector IDs - * @param file :: A reference to the NeXus file opened at the root entry - * @param spec_ids :: An array of spectrum numbers that the monitors have - * @param nmonitors :: The size of the det_ids and spec_ids arrays - */ +* Fix the detector numbers if the defaults are not correct. Currently checks +* the isis_vms_compat block and reads them from there if possible. +* +* @param det_ids :: An array of prefilled detector IDs +* @param file :: A reference to the NeXus file opened at the root entry +* @param spec_ids :: An array of spectrum numbers that the monitors have +* @param nmonitors :: The size of the det_ids and spec_ids arrays +*/ void LoadNexusMonitors2::fixUDets( boost::scoped_array<detid_t> &det_ids, ::NeXus::File &file, const boost::scoped_array<specnum_t> &spec_ids, @@ -461,11 +461,11 @@ void LoadNexusMonitors2::runLoadLogs(const std::string filename, //------------------------------------------------------------------------------ /** - * Helper method to make sure that a file is / can be openend as a NeXus file - * - * @param fname :: name of the file - * @return True if opening the file as NeXus and retrieving entries succeeds - **/ +* Helper method to make sure that a file is / can be openend as a NeXus file +* +* @param fname :: name of the file +* @return True if opening the file as NeXus and retrieving entries succeeds +**/ bool LoadNexusMonitors2::canOpenAsNeXus(const std::string &fname) { bool res = true; ::NeXus::File *f = nullptr; @@ -485,11 +485,11 @@ bool LoadNexusMonitors2::canOpenAsNeXus(const std::string &fname) { //------------------------------------------------------------------------------ /** - * Splits multiperiod histogram data into seperate workspaces and puts them in - * a group - * - * @param numPeriods :: number of periods - **/ +* Splits multiperiod histogram data into seperate workspaces and puts them in +* a group +* +* @param numPeriods :: number of periods +**/ void LoadNexusMonitors2::splitMutiPeriodHistrogramData( const size_t numPeriods) { // protection - we should not have entered the routine if these are not true @@ -626,16 +626,16 @@ size_t LoadNexusMonitors2::getMonitorInfo( } /** Create output workspace - * @brief LoadNexusMonitors2::createOutputWorkspace - * @param numHistMon - * @param numEventMon - * @param monitorsAsEvents - * @param monitorNames - * @param isEventMonitors - * @param monitorNumber2Name - * @param loadMonitorFlags - * @return - */ +* @brief LoadNexusMonitors2::createOutputWorkspace +* @param numHistMon +* @param numEventMon +* @param monitorsAsEvents +* @param monitorNames +* @param isEventMonitors +* @param monitorNumber2Name +* @param loadMonitorFlags +* @return +*/ bool LoadNexusMonitors2::createOutputWorkspace( size_t numHistMon, size_t numEventMon, bool monitorsAsEvents, std::vector<std::string> &monitorNames, std::vector<bool> &isEventMonitors, diff --git a/Framework/Nexus/inc/MantidNexus/NexusClasses.h b/Framework/Nexus/inc/MantidNexus/NexusClasses.h index 58d42e5d209b9b845db870f805654682937d21c1..3d5c3db96b420d3564c582b5d78f759ed5acf5e5 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusClasses.h +++ b/Framework/Nexus/inc/MantidNexus/NexusClasses.h @@ -6,16 +6,13 @@ //---------------------------------------------------------------------- #include "MantidAPI/Algorithm.h" #include "MantidAPI/Sample.h" -#include "MantidKernel/DateAndTime.h" #include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include <nexus/napi.h> -#include <boost/shared_array.hpp> #include <boost/shared_ptr.hpp> +#include <boost/shared_array.hpp> #include <map> - -using namespace Mantid::Kernel::DateAndTimeHelpers; //---------------------------------------------------------------------- // Forward declaration //---------------------------------------------------------------------- @@ -51,8 +48,8 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ /** Structure for keeping information about a Nexus data set, - * such as the dimensions and the type - */ +* such as the dimensions and the type +*/ struct NXInfo { NXInfo() : nxname(), rank(0), dims(), type(-1), stat(NX_ERROR) {} std::string nxname; ///< name of the object @@ -64,7 +61,7 @@ struct NXInfo { }; /** Information about a Nexus class - */ +*/ struct NXClassInfo { NXClassInfo() : nxname(), nxclass(), datatype(-1), stat(NX_ERROR) {} std::string nxname; ///< name of the object @@ -76,15 +73,15 @@ struct NXClassInfo { }; /** - * LoadNexusProcessed and SaveNexusProcessed need to share some attributes, put - * them at - * namespace level here - */ +* LoadNexusProcessed and SaveNexusProcessed need to share some attributes, put +* them at +* namespace level here +*/ /// Default block size for reading and writing processed files const int g_processed_blocksize = 8; /** Nexus attributes. The type of each attribute is NX_CHAR - */ +*/ class DLLExport NXAttributes { public: int n() const { return int(m_values.size()); } ///< number of attributes @@ -106,8 +103,8 @@ private: class NXClass; /** The base abstract class for NeXus classes and data sets. - * NX classes and data sets are defined at www.nexusformat.org - */ +* NX classes and data sets are defined at www.nexusformat.org +*/ class DLLExport NXObject { friend class NXDataSet; ///< a friend class declaration friend class NXClass; ///< a friend class declaration @@ -140,17 +137,18 @@ private: }; /** Abstract base class for a Nexus data set. A typical use include: - * <ul> - * <li>Creating a dataset object using either the concrete type - * constructor or specialized methods of NXClass'es</li> <li>Opening the dataset - * with open() method. Specialized NXClass creation methods call open() - * internally (so no need to call it again).</li> <li>Loading the data using - * load(...) method. The data can be loaded either in full or by chunks of - * smaller rank (dimension)</li> - * </ul> - * There is no need to free the memory allocated by the NXDataSet as it is done - * at the destruction. - */ +* <ul> +* <li>Creating a dataset object using either the concrete type constructor +* or specialized methods of NXClass'es</li> +* <li>Opening the dataset with open() method. Specialized NXClass creation +* methods call open() internally +* (so no need to call it again).</li> +* <li>Loading the data using load(...) method. The data can be loaded +* either in full or by chunks of smaller rank (dimension)</li> +* </ul> +* There is no need to free the memory allocated by the NXDataSet as it is done +* at the destruction. +*/ class DLLExport NXDataSet : public NXObject { public: // Constructor @@ -179,23 +177,23 @@ public: /// Returns the Nexus type of the data. The types are defied in napi.h int type() const { return m_info.type; } /** Load the data from the file. Calling this method with all default - * arguments - * makes it to read in all the data. - * @param blocksize :: The size of the block of data that should be read. - * Note that this is only used for rank 2 and 3 datasets currently - * @param i :: Calling load with non-negative i reads in a chunk of - * dimension rank()-1 and i is the index of the chunk. The rank of the data - * must be >= 1 - * @param j :: Non-negative value makes it read a chunk of dimension - * rank()-2. i and j are its indices. - * The rank of the data must be >= 2 - * @param k :: Non-negative value makes it read a chunk of dimension - * rank()-3. i,j and k are its indices. - * The rank of the data must be >= 3 - * @param l :: Non-negative value makes it read a chunk of dimension - * rank()-4. i,j,k and l are its indices. - * The rank of the data must be 4 - */ + * arguments + * makes it to read in all the data. + * @param blocksize :: The size of the block of data that should be read. + * Note that this is only used for rank 2 and 3 datasets currently + * @param i :: Calling load with non-negative i reads in a chunk of dimension + * rank()-1 and i is the index + * of the chunk. The rank of the data must be >= 1 + * @param j :: Non-negative value makes it read a chunk of dimension + * rank()-2. i and j are its indices. + * The rank of the data must be >= 2 + * @param k :: Non-negative value makes it read a chunk of dimension + * rank()-3. i,j and k are its indices. + * The rank of the data must be >= 3 + * @param l :: Non-negative value makes it read a chunk of dimension + * rank()-4. i,j,k and l are its indices. + * The rank of the data must be 4 + */ virtual void load(const int blocksize = 1, int i = -1, int j = -1, int k = -1, int l = -1) { // Avoid compiler warnings @@ -216,21 +214,21 @@ private: /** Templated class implementation of NXDataSet. After loading the data it can * be accessed via operators () and []. - */ +*/ template <class T> class NXDataSetTyped : public NXDataSet { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the dataset. - * @param name :: The name of the dataset relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the dataset. + * @param name :: The name of the dataset relative to its parent + */ NXDataSetTyped(const NXClass &parent, const std::string &name) : NXDataSet(parent, name), m_n(0) {} /** Returns a pointer to the internal data buffer. - * @throw runtime_error exception if the data have not been loaded / - * initialized. - * @return a pointer to the array of items - */ + * @throw runtime_error exception if the data have not been loaded / + * initialized. + * @return a pointer to the array of items + */ T *operator()() const { if (!m_data) throw std::runtime_error("Attempt to read uninitialized data from " + @@ -238,11 +236,11 @@ public: return m_data.get(); } /** Returns the i-th value in the internal buffer - * @param i :: The linear index of the data element - * @throw runtime_error if the data have not been loaded / initialized. - * @throw range_error if the index is greater than the buffer size. - * @return A reference to the value - */ + * @param i :: The linear index of the data element + * @throw runtime_error if the data have not been loaded / initialized. + * @throw range_error if the index is greater than the buffer size. + * @return A reference to the value + */ T &operator[](int i) const { if (!m_data) throw std::runtime_error("Attempt to read uninitialized data from " + @@ -252,21 +250,21 @@ public: return m_data[i]; } /** Returns a value assuming the data is a two-dimensional array - * @param i :: The index along dim0() - * @param j :: The index along dim1() - * @throw runtime_error if the data have not been loaded / initialized. - * @throw range_error if the indeces point outside the buffer. - * @return A reference to the value - */ + * @param i :: The index along dim0() + * @param j :: The index along dim1() + * @throw runtime_error if the data have not been loaded / initialized. + * @throw range_error if the indeces point outside the buffer. + * @return A reference to the value + */ T &operator()(int i, int j) const { return this->operator[](i * dim1() + j); } /** Returns a value assuming the data is a tree-dimensional array - * @param i :: The index along dim0() - * @param j :: The index along dim1() - * @param k :: The index along dim2() - * @throw runtime_error if the data have not been loaded / initialized. - * @throw range_error if the indeces point outside the buffer. - * @return A reference to the value - */ + * @param i :: The index along dim0() + * @param j :: The index along dim1() + * @param k :: The index along dim2() + * @throw runtime_error if the data have not been loaded / initialized. + * @throw range_error if the indeces point outside the buffer. + * @return A reference to the value + */ T &operator()(int i, int j, int k) const { return this->operator[]((i * dim1() + j) * dim2() + k); } @@ -275,26 +273,26 @@ public: /// Returns the size of the data buffer int size() const { return m_n; } /** Implementation of the virtual NXDataSet::load(...) method. Internally the - * data are stored as a 1d array. - * If the data are loaded in chunks the newly read in data replace the old - * ones. The actual rank of the loaded - * data is equal or less than the rank of the dataset (returned by rank() - * method). - * @param blocksize :: The size of the block of data that should be read. - * Note that this is only used for rank 2 and 3 datasets currently - * @param i :: Calling load with non-negative i reads in a chunk of - * dimension rank()-1 and i is the index of the chunk. The rank of the data - * must be >= 1 - * @param j :: Non-negative value makes it read a chunk of dimension - * rank()-2. i and j are its indeces. - * The rank of the data must be >= 2 - * @param k :: Non-negative value makes it read a chunk of dimension - * rank()-3. i,j and k are its indeces. - * The rank of the data must be >= 3 - * @param l :: Non-negative value makes it read a chunk of dimension - * rank()-4. i,j,k and l are its indeces. - * The rank of the data must be 4 - */ + * data are stored as a 1d array. + * If the data are loaded in chunks the newly read in data replace the old + * ones. The actual rank of the loaded + * data is equal or less than the rank of the dataset (returned by rank() + * method). + * @param blocksize :: The size of the block of data that should be read. + * Note that this is only used for rank 2 and 3 datasets currently + * @param i :: Calling load with non-negative i reads in a chunk of dimension + * rank()-1 and i is the index + * of the chunk. The rank of the data must be >= 1 + * @param j :: Non-negative value makes it read a chunk of dimension + * rank()-2. i and j are its indeces. + * The rank of the data must be >= 2 + * @param k :: Non-negative value makes it read a chunk of dimension + * rank()-3. i,j and k are its indeces. + * The rank of the data must be >= 3 + * @param l :: Non-negative value makes it read a chunk of dimension + * rank()-4. i,j,k and l are its indeces. + * The rank of the data must be 4 + */ void load(const int blocksize = 1, int i = -1, int j = -1, int k = -1, int l = -1) override { if (rank() > 4) { @@ -444,8 +442,8 @@ public: private: /** Allocates memory for the data buffer - * @param n :: The number of elements to allocate. - */ + * @param n :: The number of elements to allocate. + */ void alloc(int n) { if (n <= 0) { throw std::runtime_error("Attempt to load from an empty dataset " + @@ -488,47 +486,47 @@ typedef NXDataSetTyped<unsigned int> NXUInt; //-------------------- classes --------------------------// /** The base class for a Nexus class (group). A Nexus class can contain - * datasets and other Nexus classes. - * The NeXus file format (www.nexusformat.org) specifies the content of the - * Nexus classes. - * Derived classes have specialized methods for creating classes and datasets - * specific for the particular Nexus class. - * NXClass is a conctrete C++ class so arbitrary, non-standard Nexus classes - * (groups) can be created and loaded from - * NeXus files. - */ +* datasets and other Nexus classes. +* The NeXus file format (www.nexusformat.org) specifies the content of the +* Nexus classes. +* Derived classes have specialized methods for creating classes and datasets +* specific for the particular Nexus class. +* NXClass is a conctrete C++ class so arbitrary, non-standard Nexus classes +* (groups) can be created and loaded from +* NeXus files. +*/ class DLLExport NXClass : public NXObject { friend class NXRoot; public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXClass(const NXClass &parent, const std::string &name); /// The NX class identifier std::string NX_class() const override { return "NXClass"; } /** Returns the class information about the next entry (class or dataset) in * this class. - */ + */ NXClassInfo getNextEntry(); /// Creates a new object in the NeXus file at path path. // virtual void make(const std::string& path) = 0; /// Resets the current position for getNextEntry() to the beginning void reset(); /** - * Check if a path exists relative to the current class path - * @param path :: A string representing the path to test - * @return True if it is valid - */ + * Check if a path exists relative to the current class path + * @param path :: A string representing the path to test + * @return True if it is valid + */ bool isValid(const std::string &path) const; /** Templated method for creating derived NX classes. It also opens the - * created class. - * @param name :: The name of the class - * @tparam NX Concrete Nexus class - * @return The new object - */ + * created class. + * @param name :: The name of the class + * @tparam NX Concrete Nexus class + * @return The new object + */ template <class NX> NX openNXClass(const std::string &name) const { NX nxc(*this, name); nxc.open(); @@ -536,18 +534,18 @@ public: } /** Creates and opens an arbitrary (non-standard) class (group). - * @param name :: The name of the class. - * @return The opened NXClass - */ + * @param name :: The name of the class. + * @return The opened NXClass + */ NXClass openNXGroup(const std::string &name) const { return openNXClass<NXClass>(name); } /** Templated method for creating datasets. It also opens the created set. - * @param name :: The name of the dataset - * @tparam T The type of the data (int, double, ...). - * @return The new object - */ + * @param name :: The name of the dataset + * @tparam T The type of the data (int, double, ...). + * @return The new object + */ template <class T> NXDataSetTyped<T> openNXDataSet(const std::string &name) const { NXDataSetTyped<T> data(*this, name); @@ -556,59 +554,59 @@ public: } /** Creates and opens an integer dataset - * @param name :: The name of the dataset - * @return The int - */ + * @param name :: The name of the dataset + * @return The int + */ NXInt openNXInt(const std::string &name) const { return openNXDataSet<int>(name); } /** Creates and opens a float dataset - * @param name :: The name of the dataset - * @return The float - */ + * @param name :: The name of the dataset + * @return The float + */ NXFloat openNXFloat(const std::string &name) const { return openNXDataSet<float>(name); } /** Creates and opens a double dataset - * @param name :: The name of the dataset - * @return The double - */ + * @param name :: The name of the dataset + * @return The double + */ NXDouble openNXDouble(const std::string &name) const { return openNXDataSet<double>(name); } /** Creates and opens a char dataset - * @param name :: The name of the dataset - * @return The char - */ + * @param name :: The name of the dataset + * @return The char + */ NXChar openNXChar(const std::string &name) const { return openNXDataSet<char>(name); } /** Creates and opens a size_t dataset - * @param name :: The name of the dataset - * @return The size_t - */ + * @param name :: The name of the dataset + * @return The size_t + */ NXSize openNXSize(const std::string &name) const { return openNXDataSet<std::size_t>(name); } /** Returns a string - * @param name :: The name of the NXChar dataset - * @return The string - */ + * @param name :: The name of the NXChar dataset + * @return The string + */ std::string getString(const std::string &name) const; /** Returns a double - * @param name :: The name of the NXDouble dataset - * @return The double - */ + * @param name :: The name of the NXDouble dataset + * @return The double + */ double getDouble(const std::string &name) const; /** Returns a float - * @param name :: The name of the NXFloat dataset - * @return The float - */ + * @param name :: The name of the NXFloat dataset + * @return The float + */ float getFloat(const std::string &name) const; /** Returns a int - * @param name :: The name of the NXInt dataset - * @return The int - */ + * @param name :: The name of the NXInt dataset + * @return The int + */ int getInt(const std::string &name) const; /// Returns a list of all classes (or groups) in this NXClass @@ -618,9 +616,9 @@ public: /// Returns a list of all datasets in this NXClass std::vector<NXInfo> &datasets() const { return *m_datasets; } /** Returns NXInfo for a dataset - * @param name :: The name of the dataset - * @return NXInfo::stat is set to NX_ERROR if the dataset does not exist - */ + * @param name :: The name of the dataset + * @return NXInfo::stat is set to NX_ERROR if the dataset does not exist + */ NXInfo getDataSetInfo(const std::string &name) const; /// Returns whether an individual dataset is present bool containsDataSet(const std::string &query) const; @@ -653,14 +651,14 @@ private: //------------------- auxiliary classes ----------------------------// /** Implements NXlog Nexus class. - */ +*/ class DLLExport NXLog : public NXClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXLog(const NXClass &parent, const std::string &name) : NXClass(parent, name) {} /// Nexus class id @@ -684,7 +682,8 @@ private: if (start_time.empty()) { start_time = "2000-01-01T00:00:00"; } - auto start_t = createFromSanitizedISO8601(start_time); + auto start_t = + Kernel::DateAndTimeHelpers::createFromSanitizedISO8601(start_time); NXInfo vinfo = getDataSetInfo("value"); if (!vinfo) return nullptr; @@ -698,7 +697,8 @@ private: value.openLocal(); value.load(); for (int i = 0; i < value.dim0(); i++) { - auto t = start_t + boost::posix_time::seconds(int(times[i])); + auto t = + start_t + boost::posix_time::seconds(int(times[i])); for (int j = 0; j < value.dim1(); j++) { char *c = &value(i, j); if (!isprint(*c)) @@ -757,14 +757,14 @@ private: }; /** Implements NXnote Nexus class. - */ +*/ class DLLExport NXNote : public NXClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXNote(const NXClass &parent, const std::string &name) : NXClass(parent, name), m_author_ok(), m_data_ok(), m_description_ok() {} /// Nexus class id @@ -786,14 +786,14 @@ protected: }; /** Implements NXnote Nexus class with binary data. - */ +*/ class DLLExport NXBinary : public NXNote { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXBinary(const NXClass &parent, const std::string &name) : NXNote(parent, name) {} /// Return the binary data associated with the note @@ -806,44 +806,44 @@ private: //-------------------- main classes -------------------------------// /** Main class is the one that can contain auxiliary classes. - */ +*/ class DLLExport NXMainClass : public NXClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXMainClass(const NXClass &parent, const std::string &name) : NXClass(parent, name) {} /** Opens a NXLog class - * @param name :: The name of the NXLog - * @return The log - */ + * @param name :: The name of the NXLog + * @return The log + */ NXLog openNXLog(const std::string &name) { return openNXClass<NXLog>(name); } /** Opens a NXNote class - * @param name :: The name of the NXNote - * @return The note - */ + * @param name :: The name of the NXNote + * @return The note + */ NXNote openNXNote(const std::string &name) { return openNXClass<NXNote>(name); } }; /** Implements NXdata Nexus class. - */ +*/ class DLLExport NXData : public NXMainClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXData(const NXClass &parent, const std::string &name); /// Nexus class id std::string NX_class() const override { return "NXdata"; } /** Opens the dataset within this NXData with signal=1 attribute. - */ + */ template <typename T> NXDataSetTyped<T> openData() { for (std::vector<NXInfo>::const_iterator it = datasets().begin(); it != datasets().end(); it++) { @@ -874,14 +874,14 @@ public: }; /** Implements NXdetector Nexus class. - */ +*/ class DLLExport NXDetector : public NXMainClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXDetector(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {} /// Nexus class id @@ -895,14 +895,14 @@ public: }; /** Implements NXdisk_chopper Nexus class. - */ +*/ class DLLExport NXDiskChopper : public NXMainClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXDiskChopper(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {} /// Nexus class id @@ -912,66 +912,66 @@ public: }; /** Implements NXinstrument Nexus class. - */ +*/ class DLLExport NXInstrument : public NXMainClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXInstrument(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {} /// Nexus class id std::string NX_class() const override { return "NXinstrument"; } /** Opens a NXDetector - * @param name :: The name of the class - * @return The detector - */ + * @param name :: The name of the class + * @return The detector + */ NXDetector openNXDetector(const std::string &name) { return openNXClass<NXDetector>(name); } /** Opens a NXDetector - * @param name :: The name of the class - * @return The detector - */ + * @param name :: The name of the class + * @return The detector + */ NXDiskChopper openNXDiskChopper(const std::string &name) { return openNXClass<NXDiskChopper>(name); } }; /** Implements NXentry Nexus class. - */ +*/ class DLLExport NXEntry : public NXMainClass { public: /** Constructor. - * @param parent :: The parent Nexus class. In terms of HDF it is the group - * containing the NXClass. - * @param name :: The name of the NXClass relative to its parent - */ + * @param parent :: The parent Nexus class. In terms of HDF it is the group + * containing the NXClass. + * @param name :: The name of the NXClass relative to its parent + */ NXEntry(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {} /// Nexus class id std::string NX_class() const override { return "NXentry"; } /** Opens a NXData - * @param name :: The name of the class - * @return the nxdata entry - */ + * @param name :: The name of the class + * @return the nxdata entry + */ NXData openNXData(const std::string &name) { return openNXClass<NXData>(name); } /** Opens a NXInstrument - * @param name :: The name of the class - * @return the instrument - */ + * @param name :: The name of the class + * @return the instrument + */ NXInstrument openNXInstrument(const std::string &name) { return openNXClass<NXInstrument>(name); } }; /** Implements NXroot Nexus class. - */ +*/ class DLLExport NXRoot : public NXClass { public: // Constructor @@ -986,9 +986,9 @@ public: /// definition. bool isStandard() const; /** Opens an entry -- a topmost Nexus class - * @param name :: The name of the entry - * @return the entry - */ + * @param name :: The name of the entry + * @return the entry + */ NXEntry openEntry(const std::string &name) { return openNXClass<NXEntry>(name); }