Skip to content

Commit

Permalink
Merge pull request #370 from mantidproject/feature/11282_spice_issues
Browse files Browse the repository at this point in the history
Fixing usability issues for reducing HFIR data from SPICE file
  • Loading branch information
AndreiSavici committed Mar 18, 2015
2 parents a0d243f + 2265ef0 commit f946f7f
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 49 deletions.
18 changes: 14 additions & 4 deletions Code/Mantid/Framework/DataHandling/src/LoadSpiceAscii.cpp
Expand Up @@ -129,8 +129,16 @@ void LoadSpiceAscii::init() {
"Otherwise, any log name is not listed will be treated as "
"string property.");

declareProperty(new ArrayProperty<std::string>("DateAndTimeLog"),
"Name and format for date and time");
// date: MM/DD/YYYY,time: HH:MM:SS AM is the standard SPICE date time log name
// and format
std::vector<std::string> defaultlogformat(4);
defaultlogformat[0] = "date";
defaultlogformat[1] = "MM/DD/YYYY";
defaultlogformat[2] = "time";
defaultlogformat[3] = "HH:MM:SS AM";
declareProperty(
new ArrayProperty<std::string>("DateAndTimeLog", defaultlogformat),
"Name and format for date and time");

// Output
declareProperty(new WorkspaceProperty<ITableWorkspace>("OutputWorkspace", "",
Expand Down Expand Up @@ -461,8 +469,10 @@ void LoadSpiceAscii::setupRunStartTime(
runinfows->run().hasProperty(timelogname))) {
std::stringstream errss;
errss << "Unable to locate user specified date and time sample logs "
<< datelogname << " and " << timelogname << ".";
throw std::runtime_error(errss.str());
<< datelogname << " and " << timelogname << "."
<< "run_start will not be set up.";
g_log.error(errss.str());
return;
}

const std::string &rawdatestring =
Expand Down
12 changes: 9 additions & 3 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/Unit.h
Expand Up @@ -616,11 +616,17 @@ class MANTID_KERNEL_DLL Time : public Unit {
class MANTID_KERNEL_DLL Degrees : public Empty {
public:
Degrees();
const std::string unitID() const { return ""; }
virtual const std::string caption() const { return "Scattering angle"; }
const std::string unitID() const; /// < Degrees
const std::string caption() const { return "Scattering angle"; }
const UnitLabel label() const;

virtual Unit *clone() const { return new Degrees(*this); }
virtual void init();
virtual Unit *clone() const;

virtual double singleToTOF(const double x) const;
virtual double singleFromTOF(const double tof) const;
virtual double conversionTOFMin() const;
virtual double conversionTOFMax() const;

private:
UnitLabel m_label;
Expand Down
26 changes: 26 additions & 0 deletions Code/Mantid/Framework/Kernel/src/Unit.cpp
Expand Up @@ -1122,10 +1122,36 @@ Unit *Time::clone() const { return new Time(*this); }
* Degrees prints degrees as a label
*/

DECLARE_UNIT(Degrees)

Degrees::Degrees() : Empty(), m_label("degrees") {}

const UnitLabel Degrees::label() const { return m_label; }

void Degrees::init() {}

double Degrees::singleToTOF(const double x) const {
UNUSED_ARG(x);
throw std::runtime_error("Degrees is not allowed to be convert to TOF. ");
return 0.0;
}

double Degrees::singleFromTOF(const double tof) const {
UNUSED_ARG(tof);
throw std::runtime_error("Degrees is not allwed to be converted from TOF. ");
return 0.0;
}

double Degrees::conversionTOFMax() const {
return std::numeric_limits<double>::quiet_NaN();
}

double Degrees::conversionTOFMin() const {
return std::numeric_limits<double>::quiet_NaN();
}

Unit *Degrees::clone() const { return new Degrees(*this); }

} // namespace Units

} // namespace Kernel
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/Kernel/test/UnitTest.h
Expand Up @@ -1325,6 +1325,11 @@ class UnitTest : public CxxTest::TestSuite

}

/// Test unit Degress
void testDegress() {
TS_ASSERT_EQUALS(degrees.caption(), "Scattering angle");
TS_ASSERT_EQUALS(degrees.unitID(), "Degrees");
}

private:
Units::Label label;
Expand All @@ -1340,6 +1345,7 @@ class UnitTest : public CxxTest::TestSuite
Units::Momentum k_i;
Units::SpinEchoLength delta;
Units::SpinEchoTime tau;
Units::Degrees degrees;
};

#endif /*UNITTEST_H_*/
Expand Up @@ -108,8 +108,12 @@ class DLLExport ConvertCWPDMDToSpectra : public API::Algorithm {

/// Summary of algorithms purpose
virtual const std::string summary() const {
return "Binning the constant wavelength powder diffracton data stored in "
"MDWorkspaces to single spectrum.";
return "Convert constant wavelength (CW) powder diffraction (PD) data in "
"MDEventWorksapces "
" to a single-spectrum MatrixWorkspace, i.e., binning the "
"diffraction data "
" to single spectrum according to neutron's scattering angle, "
"d-spacing or Q. ";
}

/// Algorithm's version
Expand All @@ -134,6 +138,12 @@ class DLLExport ConvertCWPDMDToSpectra : public API::Algorithm {
const std::map<int, double> &map_runwavelength, const double xmin,
const double xmax, const double binsize, bool dolinearinterpolation);

/// Find the binning boundary according to detectors' positions
void findXBoundary(API::IMDEventWorkspace_const_sptr dataws,
const std::string &targetunit,
const std::map<int, double> &map_runwavelength,
double &xmin, double &xmax);

/// Bin signals to its 2theta position
void binMD(API::IMDEventWorkspace_const_sptr mdws, const char &unitbit,
const std::map<int, double> &map_runlambda,
Expand Down

0 comments on commit f946f7f

Please sign in to comment.