diff --git a/Code/Mantid/DataHandling/src/LoadSpice2D.cpp b/Code/Mantid/DataHandling/src/LoadSpice2D.cpp index 85ffafa1faa9603fdec3455d2db748764fc18e85..855dfbfc93abd2430ed895529d10dcbecc4722b1 100644 --- a/Code/Mantid/DataHandling/src/LoadSpice2D.cpp +++ b/Code/Mantid/DataHandling/src/LoadSpice2D.cpp @@ -202,7 +202,7 @@ namespace Mantid int pixelcount = pixels.count(); if( pixelcount != numberXPixels*numberYPixels ) { - throw Kernel::Exception::FileError("Inconsitent data set: " + throw Kernel::Exception::FileError("Inconsistent data set: " "There were more data pixels found than declared in the Spice XML meta-data.", fileName); } if( numSpectra == 0 ) @@ -247,6 +247,14 @@ namespace Mantid // run load instrument runLoadInstrument(instrument, ws); runLoadMappingTable(ws, numberXPixels, numberYPixels); + + // Set the sample-detector distance + boost::shared_ptr<Mantid::API::IInstrument> i = ws->getInstrument(); + boost::shared_ptr<Mantid::Geometry::IComponent> sample = i->getSample(); + + Geometry::ParameterMap &pmap = ws->instrumentParameters(); + pmap.add("double", sample.get(), "sample-detector-distance", distance); + } /** Run the sub-algorithm LoadInstrument (as for LoadRaw) diff --git a/Code/Mantid/PythonAPI/scripts/SANS/SANSReductionSteps.py b/Code/Mantid/PythonAPI/scripts/SANS/SANSReductionSteps.py index 994bac93d39d9a1e3ea1fc44c485ab2bfa38156a..eb55d2a0d13d71c6d95976ded8be4bad9ec81718 100644 --- a/Code/Mantid/PythonAPI/scripts/SANS/SANSReductionSteps.py +++ b/Code/Mantid/PythonAPI/scripts/SANS/SANSReductionSteps.py @@ -32,7 +32,7 @@ class BaseBeamFinder(ReductionStep): """ # Load the file to extract the beam center from, and process it. filepath = reducer._full_file_path(self._datafile) - LoadSpice2D(filepath, "beam_center") + Load(filepath, "beam_center") beam_center = FindCenterOfMassPosition("beam_center", Output = None, @@ -130,19 +130,19 @@ class BeamSpreaderTransmission(BaseTransmission): sample_spreader_ws = "_trans_sample_spreader" filepath = reducer._full_file_path(self._sample_spreader) - LoadSpice2D(filepath, sample_spreader_ws) + Load(filepath, sample_spreader_ws) direct_spreader_ws = "_trans_direct_spreader" filepath = reducer._full_file_path(self._direct_spreader) - LoadSpice2D(filepath, direct_spreader_ws) + Load(filepath, direct_spreader_ws) sample_scatt_ws = "_trans_sample_scatt" filepath = reducer._full_file_path(self._sample_scattering) - LoadSpice2D(filepath, sample_scatt_ws) + Load(filepath, sample_scatt_ws) direct_scatt_ws = "_trans_direct_scatt" filepath = reducer._full_file_path(self._direct_scattering) - LoadSpice2D(filepath, direct_scatt_ws) + Load(filepath, direct_scatt_ws) # Subtract dark current if reducer._dark_current_subtracter is not None: @@ -199,11 +199,11 @@ class DirectBeamTransmission(BaseTransmission): sample_ws = "_transmission_sample" filepath = reducer._full_file_path(self._sample_file) - LoadSpice2D(filepath, sample_ws) + Load(filepath, sample_ws) empty_ws = "_transmission_empty" filepath = reducer._full_file_path(self._empty_file) - LoadSpice2D(filepath, empty_ws) + Load(filepath, empty_ws) # Subtract dark current if reducer._dark_current_subtracter is not None: @@ -281,7 +281,7 @@ class SubtractDarkCurrent(ReductionStep): if self._dark_current_ws is None: filepath = reducer._full_file_path(self._dark_current_file) self._dark_current_ws = extract_workspace_name(filepath) - LoadSpice2D(filepath, self._dark_current_ws) + Load(filepath, self._dark_current_ws) # Normalize the dark current data to counting time darktimer_ws = self._dark_current_ws+"_timer" @@ -333,8 +333,8 @@ class LoadRun(ReductionStep): # Load data filepath = reducer._full_file_path(self._data_file) - loader = LoadSpice2D(filepath, workspace) - reducer.instrument.sample_detector_distance = float(loader.getPropertyValue("SampleDetectorDistance")) + loader = Load(filepath, workspace) + reducer.instrument.sample_detector_distance = mtd[workspace].getInstrument().getSample().getNumberParameter("sample-detector-distance")[0] mantid.sendLogMessage("Loaded %s: sample-detector distance = %g" %(workspace, reducer.instrument.sample_detector_distance)) # Move detector array to correct position diff --git a/Code/Mantid/PythonAPI/scripts/SANS/utest_CommandInterface.py b/Code/Mantid/PythonAPI/scripts/SANS/utest_CommandInterface.py index 596d3518e8a2b24a2bba2be0b2f2f50b8649a14f..a078f52c14a2378ae984dbbc3faca643b4b386d5 100644 --- a/Code/Mantid/PythonAPI/scripts/SANS/utest_CommandInterface.py +++ b/Code/Mantid/PythonAPI/scripts/SANS/utest_CommandInterface.py @@ -56,30 +56,28 @@ def _check_result(ws, test_file, tolerance=1e-6): # Utility methods for manipulating the lists def _diff_chi2(x,y): return (x[1]-y[1])*(x[1]-y[1])/(x[2]*x[2]) - def _diff_iq(x,y): - #print x[1], y[1] - return x[1]-y[1] + def _diff_iq(x,y): return x[1]-y[1] def _diff_err(x,y): return x[2]-y[2] def _add(x,y): return x+y # Check that I(q) is the same for both data sets deltas = map(_diff_iq, data_mantid, data_igor) delta = reduce(_add, deltas)/len(deltas) - if math.fabs(delta)>tolerance: + if math.fabs(delta)>tolerance or math.isnan(delta): passed = False print "Sum of I(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta), tolerance) # Then compare the errors deltas = map(_diff_err, data_mantid, data_igor) delta_err = reduce(_add, deltas)/len(deltas) - if math.fabs(delta_err)>tolerance: + if math.fabs(delta_err)>tolerance or math.isnan(delta): passed = False print "Sum of dI(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta_err), tolerance) # Compute chi2 of our result relative to IGOR deltas = map(_diff_chi2, data_mantid, data_igor) chi2 = reduce(_add, deltas)/len(data_igor) - if chi2>10.0*tolerance: + if chi2>10.0*tolerance or math.isnan(delta): passed= False print "Chi2 is outside tolerance: %g > %g" % (chi2, 10.0*tolerance)