Skip to content

Commit

Permalink
Re #4373 Fix saving of stitched data
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jan 13, 2012
1 parent c174d18 commit 42602ac
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def _low_q_browse(self):
fname = self.data_browse_dialog()
if fname:
self._content.low_q_combo.setItemText(0,fname)
self._content.low_q_combo.setCurrentIndex(0)
self._update_low_q()

def _medium_q_browse(self):
Expand All @@ -318,6 +319,7 @@ def _medium_q_browse(self):
fname = self.data_browse_dialog()
if fname:
self._content.medium_q_combo.setItemText(0,fname)
self._content.medium_q_combo.setCurrentIndex(0)
self._update_medium_q()

def _high_q_browse(self):
Expand All @@ -327,6 +329,7 @@ def _high_q_browse(self):
fname = self.data_browse_dialog()
if fname:
self._content.high_q_combo.setItemText(0,fname)
self._content.high_q_combo.setCurrentIndex(0)
self._update_high_q()

def is_running(self, is_running):
Expand Down
49 changes: 35 additions & 14 deletions Code/Mantid/scripts/LargeScaleStructures/data_stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,14 @@ def get_scaled_data(self):
dx = mtd[ws_combined].dataDx(0)
y = mtd[ws_combined].dataY(0)
e = mtd[ws_combined].dataE(0)
if len(x)!=len(y) and len(x)!=len(e):
raise RuntimeError, "Stitcher expected distributions but got histo"
HISTO = False
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
dx = dxtmp
print len(x), len(y)
x, y, e, dx = self.trim_zeros(x, y, e, dx)

for d in self._data_sets[1:]:
Expand All @@ -340,8 +346,12 @@ def get_scaled_data(self):
_y = mtd[ws].dataY(0)
_e = mtd[ws].dataE(0)
_dx = mtd[ws].dataDx(0)
if len(_x)!=len(_y) and len(_x)!=len(_e):
raise RuntimeError, "Stitcher expected distributions but got histo"
if len(_x)==len(_y)+1:
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
_dx = dxtmp

_x, _y, _e, _dx = self.trim_zeros(_x, _y, _e, _dx)
x.extend(_x)
y.extend(_y)
Expand All @@ -363,29 +373,40 @@ def cmp(p1,p2):

# Use the space we have in the current data vectors
npts = len(ytmp)
if len(x)>=npts:
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(x)>npts:
xtmp.extend(x[npts:])
ytmp.extend(y[npts:])
etmp.extend(e[npts:])
dxtmp.extend(dx[npts:])
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(x)):
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(x),npts):
xtmp[i] = xtmp[len(x)-1]+1.0
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
CropWorkspace(InputWorkspace=ws_combined, OutputWorkspace=ws_combined, XMin=0.0, XMax=xtmp[len(x)-1])
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


Expand Down

0 comments on commit 42602ac

Please sign in to comment.