Skip to content

Commit

Permalink
Merge branch 'master' into feature/10277_indirect_bayes_fit_preview_p…
Browse files Browse the repository at this point in the history
…lots

Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h
	Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp

Refs #10277
  • Loading branch information
DanNixon committed Nov 3, 2014
2 parents fa72b47 + dd0a9f3 commit 1dddb4b
Show file tree
Hide file tree
Showing 21 changed files with 1,236 additions and 657 deletions.
Expand Up @@ -91,42 +91,70 @@ namespace Mantid
struct SpectraBlock
{
/// Constructor - initialize the block
SpectraBlock(int64_t f,int64_t l,bool m):first(f),last(l),isMonitor(m){}
SpectraBlock(int64_t f,int64_t l,bool is_mon,const std::string &monname):
first(f),last(l),isMonitor(is_mon),monName(monname){}

int64_t first; ///< first spectrum number of the block
int64_t last; ///< last spectrum number of the block
bool isMonitor; ///< is the data in a monitor group
std::string monName;
};

/// The structure describes parameters of a single time-block written in the nexus file
struct DataBlock
{
// The number of data periods
int numberOfPeriods;
// The number of time channels per spectrum (N histogram bins -1)
std::size_t numberOfChannels;
// The number of spectra
size_t numberOfSpectra;
// minimal spectra Id (by default 1, undefined -- max_value)
int64_t spectraID_min;
// maximal spectra Id (by default 1, undefined -- 0)
int64_t spectraID_max;

DataBlock():numberOfPeriods(0),numberOfChannels(0),numberOfSpectra(0),spectraID_min(std::numeric_limits<int64_t>::max()),spectraID_max(0){}

DataBlock(const NeXus::NXInt &data):
numberOfPeriods(data.dim0()),
numberOfChannels(data.dim2()),
numberOfSpectra (data.dim1()),
spectraID_min(std::numeric_limits<int64_t>::max()),
spectraID_max(0)
{};
};
private:
/// Overwrites Algorithm method.
void init();
/// Overwrites Algorithm method
void exec();
// Validate the optional input properties
void checkOptionalProperties();
void checkOptionalProperties(const std::map<int64_t,std::string> &ExcludedMonitors);
/// Prepare a vector of SpectraBlock structures to simplify loading
size_t prepareSpectraBlocks();
size_t prepareSpectraBlocks(std::map<int64_t,std::string > &monitors, const std::map<int64_t,specid_t> &specInd2specNum_map,const DataBlock &LoadBlock);
/// Run LoadInstrument as a ChildAlgorithm
void runLoadInstrument(DataObjects::Workspace2D_sptr);
void runLoadInstrument(DataObjects::Workspace2D_sptr &);
/// Load in details about the run
void loadRunDetails(DataObjects::Workspace2D_sptr local_workspace, Mantid::NeXus::NXEntry & entry);
void loadRunDetails(DataObjects::Workspace2D_sptr &local_workspace, Mantid::NeXus::NXEntry & entry);
/// Parse an ISO formatted date-time string into separate date and time strings
void parseISODateTime(const std::string & datetime_iso, std::string & date, std::string & time) const;
/// Load in details about the sample
void loadSampleData(DataObjects::Workspace2D_sptr, Mantid::NeXus::NXEntry & entry);
void loadSampleData(DataObjects::Workspace2D_sptr &, Mantid::NeXus::NXEntry & entry);
/// Load log data from the nexus file
void loadLogs(DataObjects::Workspace2D_sptr ws, Mantid::NeXus::NXEntry & entry);
void loadLogs(DataObjects::Workspace2D_sptr &ws, Mantid::NeXus::NXEntry & entry);
// Load a given period into the workspace
void loadPeriodData(int64_t period, Mantid::NeXus::NXEntry & entry, DataObjects::Workspace2D_sptr local_workspace);
void loadPeriodData(int64_t period, Mantid::NeXus::NXEntry & entry, DataObjects::Workspace2D_sptr &local_workspace);
// Load a data block
void loadBlock(Mantid::NeXus::NXDataSetTyped<int> & data, int64_t blocksize, int64_t period, int64_t start,
int64_t &hist, int64_t& spec_num, DataObjects::Workspace2D_sptr localWorkspace);
int64_t &hist, int64_t& spec_num, DataObjects::Workspace2D_sptr &localWorkspace);

// Create period logs
void createPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr local_workspace);
void createPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr &local_workspace);
// Validate multi-period logs
void validateMultiPeriodLogs(Mantid::API::MatrixWorkspace_sptr);
void validateMultiPeriodLogs(Mantid::API::MatrixWorkspace_sptr );
// build the list of spectra numbers to load and include in the spectra list
void buildSpectraInd2SpectraNumMap(const std::vector<int64_t> &spec_list);
void buildSpectraInd2SpectraNumMap(bool range_supplied,int64_t range_min,int64_t range_max,const std::vector<int64_t> &spec_list,const std::map<int64_t,std::string> &ExcludedMonitors);


/// The name and path of the input file
Expand All @@ -136,28 +164,19 @@ namespace Mantid
/// The sample name read from Nexus
std::string m_samplename;

/// The number of spectra
std::size_t m_numberOfSpectra;
/// The number of spectra in the raw file
std::size_t m_numberOfSpectraInFile;
/// The number of periods
int m_numberOfPeriods;
/// The number of periods in the raw file
int m_numberOfPeriodsInFile;
/// The number of time channels per spectrum
std::size_t m_numberOfChannels;
/// The number of time channels per spectrum in the raw file
std::size_t m_numberOfChannelsInFile;
// the description of the data block in the file to load.
// the description of single time-range data block, obtained from detectors
DataBlock m_detBlockInfo;
// the description of single time-range data block, obtained from monitors
DataBlock m_monBlockInfo;
// description of the block to be loaded may include monitors and detectors with the same time binning if the detectors and monitors are loaded together
// in single workspace or equal to the detectorBlock if monitors are excluded
// or monBlockInfo if only monitors are loaded.
DataBlock m_loadBlockInfo;

/// Is there a detector block
bool m_have_detector;


/// Have the spectrum_min/max properties been set?
bool m_range_supplied;
/// The value of the SpectrumMin property
int64_t m_spec_min;
/// The value of the SpectrumMax property
int64_t m_spec_max;
/// if true, a spectra list or range of spectra is supplied
bool m_load_selected_spectra;
/// map of spectra Index to spectra Number (spectraID)
Expand Down Expand Up @@ -192,8 +211,10 @@ namespace Mantid
static double dblSqrt(double in);

// C++ interface to the NXS file
::NeXus::File * m_cppFile;
boost::scoped_ptr< ::NeXus::File> m_cppFile;

bool findSpectraDetRangeInFile(NeXus::NXEntry &entry,boost::shared_array<int> &spectrum_index,int64_t ndets,int64_t n_vms_compat_spectra,
std::map<int64_t,std::string> &monitors,bool excludeMonitors,bool separateMonitors,std::map<int64_t,std::string> &ExcludedMonitors);
};

} // namespace DataHandling
Expand Down
Expand Up @@ -21,7 +21,7 @@ namespace Mantid
Loads an file in ISIS RAW format and stores it in a 2D workspace
(Workspace2D class). LoadRaw is an algorithm and LoadRawHelper class and
overrides the init() & exec() methods.
overrides the init() & exec() methods.
LoadRaw3 uses less memory by only loading up the datablocks as required.
Copyright &copy; 2007-9 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand Down Expand Up @@ -71,12 +71,6 @@ namespace Mantid

/// returns true if the given spectrum is a monitor
bool isMonitor(const std::vector<specid_t>& monitorIndexes,specid_t spectrumNum);
/// returns true if the Exclude Monitor option(property) selected
bool isExcludeMonitors(const std::string &monitorOption);
/// returns true if the Separate Monitor Option selected
bool isSeparateMonitors(const std::string &monitorOption);
/// returns true if the Include Monitor Option selected
bool isIncludeMonitors(const std::string &monitorOption);

/// validate workspace sizes
void validateWorkspaceSizes( bool bexcludeMonitors ,bool bseparateMonitors,
Expand Down
Expand Up @@ -27,32 +27,32 @@ namespace Mantid
{
/** @class LoadRawHelper DataHandling/LoadRawHelper.h
Helper class for LoadRaw algorithms.
Helper class for LoadRaw algorithms.
@author Sofia Antony, ISIS,RAL
@date 14/04/2010
@author Sofia Antony, ISIS,RAL
@date 14/04/2010
Copyright &copy; 2007-9 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Copyright &copy; 2007-9 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadRawHelper: public API::IFileLoader<Kernel::FileDescriptor>
{
public:
Expand All @@ -74,6 +74,37 @@ namespace Mantid
/// Returns a confidence value that this algorithm can load a file
virtual int confidence(Kernel::FileDescriptor & descriptor) const;

/// returns true if the Exclude Monitor option(property) selected
static bool isExcludeMonitors(const std::string &monitorOption);
/// returns true if the Separate Monitor Option selected
static bool isSeparateMonitors(const std::string &monitorOption);
/// returns true if the Include Monitor Option selected
static bool isIncludeMonitors(const std::string &monitorOption);


static void ProcessLoadMonitorOptions(bool &bincludeMonitors,bool &bseparateMonitors,bool &bexcludeMonitors,API::Algorithm *const pAlgo);
///creates monitor workspace
static void createMonitorWorkspace(DataObjects::Workspace2D_sptr& monws_sptr,
DataObjects::Workspace2D_sptr& ws_sptr,API::WorkspaceGroup_sptr& mongrp_sptr,
const int64_t mwsSpecs,const int64_t nwsSpecs,const int64_t numberOfPeriods,const int64_t lenthIn,std::string title,API::Algorithm *const pAlg);
/// creates shared pointer to group workspace
static API::WorkspaceGroup_sptr createGroupWorkspace();

///creates shared pointer to workspace from parent workspace
static DataObjects::Workspace2D_sptr createWorkspace(DataObjects::Workspace2D_sptr ws_sptr,
int64_t nVectors=-1,int64_t xLengthIn=-1,int64_t yLengthIn=-1);

/// overloaded method to create shared pointer to workspace
static DataObjects::Workspace2D_sptr createWorkspace(int64_t nVectors,int64_t xlengthIn,int64_t ylengthIn,const std::string& title);

/// sets the workspace property
static void setWorkspaceProperty(const std::string & propertyName,const std::string& title,
API::WorkspaceGroup_sptr grpws_sptr,DataObjects::Workspace2D_sptr ws_sptr,int64_t numberOfPeriods,bool bMonitor,API::Algorithm * const pAlg);

/// overloaded method to set the workspace property
static void setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr,API::WorkspaceGroup_sptr grpws_sptr,const int64_t period,bool bmonitors,API::Algorithm *const pAlg);


protected:
/// Overwrites Algorithm method.
void init();
Expand All @@ -95,19 +126,6 @@ namespace Mantid
bool readData(FILE* file,int histToRead);
bool readData(FILE* file,int64_t histToRead);

///creates shared pointer to workspace from parent workspace
DataObjects::Workspace2D_sptr createWorkspace(DataObjects::Workspace2D_sptr ws_sptr,
int64_t nVectors=-1,int64_t xLengthIn=-1,int64_t yLengthIn=-1);

/// overloaded method to create shared pointer to workspace
DataObjects::Workspace2D_sptr createWorkspace(int64_t nVectors,int64_t xlengthIn,int64_t ylengthIn,const std::string& title);
///creates monitor workspace
void createMonitorWorkspace(DataObjects::Workspace2D_sptr& monws_sptr,
DataObjects::Workspace2D_sptr& ws_sptr,API::WorkspaceGroup_sptr& mongrp_sptr,
const int64_t mwsSpecs,const int64_t nwsSpecs,const int64_t numberOfPeriods,const int64_t lenthIn,std::string title);

/// creates shared pointer to group workspace
API::WorkspaceGroup_sptr createGroupWorkspace();

//Constructs the time channel (X) vector(s)
std::vector<boost::shared_ptr<MantidVec> > getTimeChannels(const int64_t& regimes, const int64_t& lengthIn);
Expand All @@ -126,16 +144,10 @@ namespace Mantid
///gets the monitor spectrum list from the workspace
std::vector<specid_t> getmonitorSpectrumList(const API::SpectrumDetectorMapping& mapping);

/// sets the workspace property
void setWorkspaceProperty(const std::string & propertyName,const std::string& title,
API::WorkspaceGroup_sptr grpws_sptr,DataObjects::Workspace2D_sptr ws_sptr,int64_t numberOfPeriods,bool bMonitor);

/// overloaded method to set the workspace property
void setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr,API::WorkspaceGroup_sptr grpws_sptr,const int64_t period,bool bmonitors);

/// This method sets the raw file data to workspace vectors
void setWorkspaceData(DataObjects::Workspace2D_sptr newWorkspace,const std::vector<boost::shared_ptr<MantidVec> >&
timeChannelsVec,int64_t wsIndex,specid_t nspecNum,int64_t noTimeRegimes,int64_t lengthIn,int64_t binStart);
timeChannelsVec,int64_t wsIndex,specid_t nspecNum,int64_t noTimeRegimes,int64_t lengthIn,int64_t binStart);


/// ISISRAW class instance which does raw file reading. Shared pointer to prevent memory leak when an exception is thrown.
Expand All @@ -161,10 +173,10 @@ namespace Mantid
specid_t calculateWorkspaceSize();
/// calculate workspace sizes if separate or exclude monitors are selected
void calculateWorkspacesizes(const std::vector<specid_t>& monitorSpecList,
specid_t& normalwsSpecs, specid_t& monitorwsSpecs);
/// load the specra
specid_t& normalwsSpecs, specid_t& monitorwsSpecs);
/// load the spectra
void loadSpectra(FILE* file,const int& period, const int& m_total_specs,
DataObjects::Workspace2D_sptr ws_sptr,std::vector<boost::shared_ptr<MantidVec> >);
DataObjects::Workspace2D_sptr ws_sptr,std::vector<boost::shared_ptr<MantidVec> >);

/// Has the spectrum_list property been set?
bool m_list;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp
Expand Up @@ -200,7 +200,7 @@ namespace Mantid
}
}

// Check for cancelled algorithm
// Check for canceled algorithm
if (alg->getCancel())
{
return;
Expand Down

0 comments on commit 1dddb4b

Please sign in to comment.