diff --git a/Framework/PythonInterface/plugins/algorithms/SaveYDA.py b/Framework/PythonInterface/plugins/algorithms/SaveYDA.py index 70ad90edb44b1a924a5af9f6225e501887b6c4ea..c09d83538c5524a8a556bc1380f7d14340d1f3fc 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveYDA.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveYDA.py @@ -69,13 +69,9 @@ class SaveYDA(PythonAlgorithm): """ Main execution body """ # Properties - ws = mtd[self.getPropertyValue("InputWorkspace")] + ws = self.getProperty("InputWorkspace").value filename = self.getProperty("Filename").value - # check workspace exists - if not ws: - raise NotImplementedError("InputWorkspace does not exist") - run = ws.getRun() ax = ws.getAxis(1) nHist = ws.getNumberHistograms() @@ -124,7 +120,7 @@ class SaveYDA(PythonAlgorithm): temp = OrderedDict() temp["name"] = "T" temp["unit"] = "K" - temp["val"] = temperature + temp["val"] = round(temperature, 14) temp["stdv"] = 0 rpar.append(temp) @@ -137,7 +133,7 @@ class SaveYDA(PythonAlgorithm): ei = OrderedDict() ei["name"] = "Ei" ei["unit"] = "meV" - ei["val"] = eimeV + ei["val"] = round(eimeV, 14) ei["stdv"] = 0 rpar.append(ei) @@ -151,9 +147,7 @@ class SaveYDA(PythonAlgorithm): x["name"] = "w" x["unit"] = "meV" - # set_flow style is used to keep the Frida 2.0 yaml format coord["x"] = x - #coord["x"].fa.set_flow_style() y = FlowOrderedDict() @@ -174,7 +168,8 @@ class SaveYDA(PythonAlgorithm): z["name"] = zname z["unit"] = zunit - coord["z"] = z + coord["z"] = FlowList() + coord["z"].append(z) slices = [] @@ -189,11 +184,13 @@ class SaveYDA(PythonAlgorithm): detector = ws.getDetector(i) # convert radians to degrees twoTheta = detector.getTwoTheta(samplePos, beamPos)*180/math.pi + twoTheta = round(twoTheta, 14) bin.append(twoTheta) elif ax.length() == nHist: # if y axis contains bin centers for i in range(ax.length()): - bin.append(ax.getValue()) + xval = round(ax.getValue(), 14) + bin.append(xval) else: # get the bin centers not the bin edges bin = self._get_bin_centers(ax) @@ -221,7 +218,7 @@ class SaveYDA(PythonAlgorithm): ys = ws.dataY(i) # y is dataY of the workspace - yy = [float(j) for j in ys] + yy = [float(round(j, 14)) for j in ys] slicethis["y"] = FlowList(yy) slices.append(slicethis) @@ -251,7 +248,8 @@ class SaveYDA(PythonAlgorithm): bin = [] for i in range(1, ax.size): - bin.append((ax[i]+ax[i-1])/2) + axval = round((ax[i]+ax[i-1])/2, 14) + bin.append(axval) return bin diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py index b4944830a207237e950c6f298fd8973d6c637169..94e273f871611ff59e933e9b6a6b03fcffdb2cca 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py @@ -84,7 +84,7 @@ class SaveYDATest(unittest.TestCase): self.assertEqual(coord[0], "Coord:\n") self.assertEqual(coord[1], " x: {name: w, unit: meV}\n") self.assertEqual(coord[2], " y: {name: \'S(q,w)\', unit: meV-1}\n") - self.assertEqual(coord[3], " z: {name: 2th, unit: deg}\n") + self.assertEqual(coord[3], " z: [{name: 2th, unit: deg}]\n") ws = self._create_workspace(yAxSpec=False) f = self._file(ws, "File") @@ -98,7 +98,7 @@ class SaveYDATest(unittest.TestCase): self.assertEqual(coord[0], "Coord:\n") self.assertEqual(coord[1], " x: {name: w, unit: meV}\n") self.assertEqual(coord[2], " y: {name: \'S(q,w)\', unit: meV-1}\n") - self.assertEqual(coord[3], " z: {name: q, unit: A-1}\n") + self.assertEqual(coord[3], " z: [{name: q, unit: A-1}]\n") def test_rpar(self): """ Test save RPar from workspace with and without sample logs @@ -121,7 +121,7 @@ class SaveYDATest(unittest.TestCase): self.assertEqual(r_par[8], " stdv: 0\n") r_par = [] - #workspace with no sample logs + # workspace with no sample logs for i in range(10): s = self._no_sample_file.readline() if i >= 9: diff --git a/docs/source/algorithms/SaveYDA-v1.rst b/docs/source/algorithms/SaveYDA-v1.rst index 99ef0dafb001988b1d9903045f3b2ef52cd0ee7a..2fc34c37a903935cd63152a1f2280d549b320708 100644 --- a/docs/source/algorithms/SaveYDA-v1.rst +++ b/docs/source/algorithms/SaveYDA-v1.rst @@ -73,7 +73,7 @@ Usage Coord: x: {name: w, unit: meV} y: {name: 'S(q,w)', unit: meV-1} - z: {name: 2th, unit: deg} + z: [{name: 2th, unit: deg}] .. testcleanup:: SaveYDAExample