Skip to content

Commit

Permalink
Re #4373 Cleaning up code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jan 17, 2012
1 parent e5eeada commit 76f376c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void export_MatrixWorkspace()
return_internal_reference<>(), "Return the spectra at the given workspace index.")
.def("getDetector", (IDetector_sptr (MatrixWorkspace::*) (const size_t) const)&MatrixWorkspace::getDetector,
"Return the Detector or DetectorGroup that is linked to the given workspace index")
.def("getRun", &MatrixWorkspace::mutableRun, return_internal_reference<>(),
"Return the Run object for this workspace")
.def("axes", &MatrixWorkspace::axes, "Returns the number of axes attached to the workspace")
.def("getAxis", &MatrixWorkspace::getAxis, return_internal_reference<>())
.def("isHistogramData", &MatrixWorkspace::isHistogramData, "Returns True if this is conisdered to be binned data.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ void export_ConfigService()
.staticmethod("Instance")
.def("getDataSearchDirs",&ConfigServiceImpl::getDataSearchDirs, return_value_policy<copy_const_reference>(),
"Return the current list of data search paths")
.def("appendDataSearchDir", &ConfigServiceImpl::appendDataSearchDir,
"Append a directory to the current list of data search paths")
// Treat this as a dictionary
.def("__getitem__", (std::string (ConfigServiceImpl::*)(const std::string &))&ConfigServiceImpl::getString)
.def("__setitem__", &ConfigServiceImpl::setString)
Expand Down
69 changes: 15 additions & 54 deletions Code/Mantid/scripts/LargeScaleStructures/data_stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,13 @@ def get_scaled_data(self):

ws_combined = "combined_Iq"

# Copy over dQ
CloneWorkspace(InputWorkspace=self._data_sets[0].get_scaled_ws(),
OutputWorkspace=ws_combined)
first_ws = self._data_sets[0].get_scaled_ws()

x = mtd[ws_combined].dataX(0)
dx = mtd[ws_combined].dataDx(0)
y = mtd[ws_combined].dataY(0)
e = mtd[ws_combined].dataE(0)
HISTO = False
x = mtd[first_ws].dataX(0)
dx = mtd[first_ws].dataDx(0)
y = mtd[first_ws].dataY(0)
e = mtd[first_ws].dataE(0)
if len(x)==len(y)+1:
HISTO = True
xtmp = [(x[i]+x[i+1])/2.0 for i in range(len(y))]
dxtmp = [(dx[i]+dx[i+1])/2.0 for i in range(len(y))]
x = xtmp
Expand Down Expand Up @@ -365,52 +361,17 @@ def cmp(p1,p2):
combined = sorted(zipped, cmp)
x,y,e,dx = zip(*combined)

xtmp = mtd[ws_combined].dataX(0)
ytmp = mtd[ws_combined].dataY(0)
etmp = mtd[ws_combined].dataE(0)
dxtmp = mtd[ws_combined].dataDx(0)
CreateWorkspace(DataX=x, DataY=y, DataE=e,
OutputWorkspace=ws_combined,
UnitX="MomentumTransfer",
ParentWorkspace=first_ws)

# Use the space we have in the current data vectors
npts = len(ytmp)
if len(y)>=npts:
for i in range(npts):
xtmp[i] = x[i]
ytmp[i] = y[i]
etmp[i] = e[i]
dxtmp[i] = dx[i]
if len(y)>npts:
if HISTO:
xtmp[npts] = x[npts]
dxtmp[npts] = dx[npts]
xtmp.extend(x[npts+1:])
ytmp.extend(y[npts:])
etmp.extend(e[npts:])
dxtmp.extend(dx[npts+1:])
else:
xtmp.extend(x[npts:])
ytmp.extend(y[npts:])
etmp.extend(e[npts:])
dxtmp.extend(dx[npts:])
else:
for i in range(len(y)):
xtmp[i] = x[i]
ytmp[i] = y[i]
etmp[i] = e[i]
dxtmp[i] = dx[i]
for i in range(len(y),npts):
xtmp[i] = xtmp[len(y)-1]+1.0
ytmp[i] = 0.0
etmp[i] = 0.0
dxtmp[i] = 0.0
if HISTO:
xtmp[len(y)] = xtmp[len(y)-1]
dxtmp[len(y)] = 0.0
CropWorkspace(InputWorkspace=ws_combined, OutputWorkspace=ws_combined, XMin=0.0, XMax=xtmp[len(y)-1])
return ws_combined
dxtmp = mtd[ws_combined].dataDx(0)



# Fill out dQ
npts = len(x)
for i in range(npts):
dxtmp[i] = dx[i]



return ws_combined

0 comments on commit 76f376c

Please sign in to comment.