Skip to content

Commit

Permalink
Fixed issues with saving file of multi-scan. Refs #11289.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Apr 29, 2015
1 parent 4d2ecad commit 159892c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 14 deletions.
14 changes: 14 additions & 0 deletions Code/Mantid/scripts/HFIRPowderReduction/HfirPDReductionControl.py
Expand Up @@ -792,6 +792,20 @@ def retrieveCorrectionData(self, instrument, exp, scan, localdatadir):
return (True, [wavelength, localdetefffname, localexcldetfname])


def saveMergedScan(self, sfilename, mergeindex):
""" Save the current merged scan
"""
if self._myMergedWSDict.has_key(mergeindex) is True:
wksp = self._myMergedWSDict[mergeindex]
else:
raise NotImplementedError('Unable to locate the merged scan workspace.')

api.SaveFocusedXYE(InputWorkspace=wksp,
StartAtBankNumber=1,
Filename=sfilename)

return


def savePDFile(self, exp, scan, filetype, sfilename):
""" Save a reduced workspace to gsas/fullprof/topaz data file
Expand Down
64 changes: 52 additions & 12 deletions Code/Mantid/scripts/HFIRPowderReduction/HfirPDReductionGUI.py
Expand Up @@ -123,6 +123,10 @@ def __init__(self, parent=None):
self.doMergeScanViewMerged)
self.connect(self.ui.pushButton_clearMultCanvas, QtCore.SIGNAL('clicked()'),
self.doClearMultiRunCanvas)
self.connect(self.ui.pushButton_saveAllIndScans, QtCore.SIGNAL('clicked()'),
self.doSaveMultipleScans)
self.connect(self.ui.pushButton_saveMerge, QtCore.SIGNAL('clicked()'),
self.doSaveMergedScan)

# tab 'Vanadium'
self.connect(self.ui.pushButton_stripVanPeaks, QtCore.SIGNAL('clicked()'),
Expand Down Expand Up @@ -270,6 +274,9 @@ def __init__(self, parent=None):
for key in [2, 3, 4]:
self._tabBinParamDict[key] = [None, None, None]

self._lastMergeLabel = ""
self._lastMergeIndex = -1

return


Expand Down Expand Up @@ -794,6 +801,8 @@ def doMergeScans(self):
self._lastMergeIndex = mindex
self._lastMergeLabel = label

print "Last merged index = ", self._lastMergeIndex

return


Expand Down Expand Up @@ -877,17 +886,19 @@ def doMergeScanView2D(self):
def doMergeScanViewMerged(self):
""" Change the merged run's view to 1D plot
"""
raise NotImplementedError('ASAP')
# Highlight the button's color
self.ui.pushButton_view2D.setStyleSheet('QPushButton {color: black;}')
self.ui.pushButton_viewMerge.setStyleSheet('QPushButton {color: red;}')
self.ui.pushButton_view2D.setStyleSheet('QPushButton {color: red;}')
self.ui.pushButton_view2D.setEnabled(True)
self.ui.pushButton_viewMScan1D.setStyleSheet('QPushButton {color: red;}')
self.ui.pushButton_viewMScan1D.setEnabled(True)

# Clear image
self.ui.graphicsView_mergeRun.clearCanvas()

# Plot
self._plotMergedReducedData(self._lastMergeIndex, self._lastMergeLabel)
self._plotMergedReducedData(mkey=self._lastMergeIndex, label=self._lastMergeLabel)

return


def doPlotIndvDetMain(self):
Expand Down Expand Up @@ -1188,6 +1199,36 @@ def doSaveData(self):

return

def doSaveMergedScan(self):
""" Save merged scan
"""
homedir = os.getcwd()
filefilter = "Fullprof (*.dat)"
sfilename = str(QtGui.QFileDialog.getSaveFileName(self, 'Save File In Fullprof', homedir, filefilter))

self._myControl.saveMergedScan(sfilename, mergeindex=self._lastMergeIndex)

return


def doSaveMultipleScans(self):
""" Save multiple scans
"""
# Get experiment number and scans
expno, scanslist = self._uiGetExpScanTabMultiScans()

# Get base file name
homedir = os.getcwd()
savedir = str(QtGui.QFileDialog.getExistingDirectory(self,'Get Directory To Save Fullprof',homedir))

for scanno in scanslist:
sfilename = os.path.join(savedir, "HB2A_Exp%d_Scan%d_FP.dat"%(expno, scanno))
self._myControl.savePDFile(expno, scanno, 'fullprof', sfilename)
# ENDFOR

return


def doSaveVanRun(self):
""" Save the vanadium run with peaks removed
"""
Expand Down Expand Up @@ -1572,16 +1613,15 @@ def _plotMergedReducedData(self, mkey, label):
canvas.addPlot(vecx, vecy, marker=marker, color=color,
xlabel=xlabel, ylabel='intensity',label=label)

if clearcanvas is True:
xmax = max(vecx)
xmin = min(vecx)
dx = xmax-xmin
xmax = max(vecx)
xmin = min(vecx)
dx = xmax-xmin

ymax = max(vecy)
ymin = min(vecy)
dy = ymax-ymin
ymax = max(vecy)
ymin = min(vecy)
dy = ymax-ymin

canvas.setXYLimit(xmin-dx*0.1, xmax+dx*0.1, ymin-dy*0.1, ymax+dy*0.1)
canvas.setXYLimit(xmin-dx*0.1, xmax+dx*0.1, ymin-dy*0.1, ymax+dy*0.1)

return

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/scripts/HFIRPowderReduction/README.md
@@ -1,8 +1,6 @@
Tasks
-----

6. Tab *Multiple Scans*: implement **Save Merged**
7. Tab *Multiple Scans*: implement **Save All**
6. Find out why the vanadium runs (379-10/11) look funny, i.e., oscilating curves;
7. Talk with Clarina how to deal with vanadium spectrum with peaks striped;
8. Tab *Normalized*: **Normalization Monitor** should have a default value as the average of monitor counts
Expand All @@ -22,6 +20,8 @@ Finished Tasks
7. Tab *Normalized*: **Save** does not work well with option *gsas and fullprof*;
8. Tab *vanadium*: implement **Smooth Data**;
9. Tab *vanadium*: implement **Save**;
10. Tab *Multiple Scans*: implement **Save Merged**
11. Tab *Multiple Scans*: implement **Save All**


Use cases for tabs
Expand Down

0 comments on commit 159892c

Please sign in to comment.