Skip to content

Commit

Permalink
Refs #11289. Checkpointing work on vanadium peak strip.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Apr 9, 2015
1 parent af1222b commit 9626d51
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 60 deletions.
98 changes: 76 additions & 22 deletions Code/Mantid/scripts/HFIRPowderReduction/HfirPDReductionGUI.py
Expand Up @@ -306,6 +306,21 @@ def doCheckSrcServer(self):
def doLoadData(self):
""" Load and reduce data
"""
# Kick away unsupported tabs
itab = self.ui.tabWidget.currentIndex()
tabtext = str(self.ui.tabWidget.tabText(itab))
print "[DB] Current active tab is No. %d as %s." % (itab, tabtext)

if itab == 3:
# 'multiple scans'
self._logNotice("Tab %s does not support 'Load Data'. Use 'Load All' instead." % (tabtext))
return

elif itab == 5:
# 'advanced'
self._logNotice("Tab %s does not support 'Load Data'. Request is ambiguous." % (tabtext))
return

# Get information
try:
expno, scanno = self._uiGetExpScanNumber()
Expand All @@ -321,29 +336,62 @@ def doLoadData(self):
self._logError("Unable to download or locate local data file for Exp %d \
Scan %d." % (expno, scanno))

# Get other information
try:
xmin, binsize, xmax = self._uiGetBinningParams()
except Exception as e:
self._logError(str(e))
return

unit = self._currUnit
wavelength = float(self.ui.lineEdit_wavelength.text())

# Reduce data
execstatus = self._myControl.reduceSpicePDData(expno, scanno, datafilename, unit, xmin,
xmax, binsize, wavelength)
print "[DB] reduction status = ", execstatus
# Now do different tasks for different tab
if itab == 0 or itab == 1:
# Load data only
try:
execstatus = self._myControl.loadSpicePDData(expno, scanno, datafilename)
if execstatus is False:
cause = "Load data failed."
else:
cause = None
except Exception as e:
execstatus = False
cause = str(e)
finally:
if execstatus is False:
self._logError(cause)
return
# END-TRY-EXCEPT-FINALLY

elif itab == 2 or itab == 4:
# load and reduce data
wavelength = float(self.ui.lineEdit_wavelength.text())

# Plot data

clearcanvas = self.ui.checkBox_clearPrevious.isChecked()

xlabel = self._getXLabelFromUnit(unit)
if execstatus is True:
self._plotReducedData(expno, scanno, self.ui.graphicsView_reducedData, xlabel,
label="Exp %d Scan %d Bin = %.5f" % (expno, scanno, binsize), clearcanvas=clearcanvas)
if itab == 2:
# Get other information
unit = self._currUnit
try:
xmin, binsize, xmax = self._uiGetBinningParams()
except Exception as e:
self._logError(str(e))
return
else:
# itab = 4
unit = 'dSpacing'
raise NotImplementedError("Need to read in values!")

# END-IF-ELSE

# Reduce data
execstatus = self._myControl.reduceSpicePDData(expno, scanno, \
datafilename, unit, xmin, xmax, binsize, wavelength)
print "[DB] reduction status = ", execstatus

# Plot data
if execstatus is True:
if itab == 2:
#
clearcanvas = self.ui.checkBox_clearPrevious.isChecked()
xlabel = self._getXLabelFromUnit(unit)
self._plotReducedData(expno, scanno, self.ui.graphicsView_reducedData, \
xlabel, label="Exp %d Scan %d Bin = %.5f" % (expno, scanno, binsize), \
clearcanvas=clearcanvas)
else:
#
raise NotImplementedError("ASAP for vanadium")
# ENDIF(execstatus)
# END-IF-ELSE (itab)

return execstatus

Expand Down Expand Up @@ -899,6 +947,12 @@ def _uiLoadDataFile(self, exp, scan):
Either download the data from a server or copy the data file from local
disk
"""
# FIXME / TODO : Need to load vanadium correction data automatically!
print "************************************************************"
print "* ASAP: Load vanadium correction data! *"
print "************************************************************"


# Get on hold of raw data file
useserver = self.ui.radioButton_useServer.isChecked()
uselocal = self.ui.radioButton_useLocal.isChecked()
Expand Down
51 changes: 13 additions & 38 deletions Code/Mantid/scripts/HFIRPowderReduction/testGUI_vanadiumPeak.py
@@ -1,15 +1,5 @@
###############################################################################
# Tester
#
# Next:
# (-) Add an option/option groups such that the new reduced data can be plot \
# on a clean canvas or over plot on the original one;
# (-) An inner sequence for line-color-marker-style of the plot should be made
# (-) Shall add button to load 'next' and 'previous'
# (-) Make Ge 113 In Config and etc a comboBox for wavelength
# (-) Add tool bar to plot for save/zoom in and out and etc.
# (-) Label of the plots
#
# Tester: Tab as vanadium peak strip
#
# ( 3) A dictionary should be used to manage the history data
# ( 8) Merge runs
Expand Down Expand Up @@ -39,8 +29,6 @@
LINUX = 1
OSX = 2



##########

def qapp():
Expand All @@ -65,43 +53,30 @@ def qapp():
raise NotImplementedError("OS %s is not supported." % (osname))

reducer = HfirPDReductionGUI.MainWindow() #the main ui class in this file is called MainWindow
reducer.show()
if MOS == LINUX:
reducer.ui.lineEdit_cache.setText('/home/wzz/Temp/')
elif MOS == OSX:
reducer.ui.lineEdit_cache.setText('/Users/wzz/Temp/')

# example: 'http://neutron.ornl.gov/user_data/hb2a/exp400/Datafiles/HB2A_exp0400_scan0001.dat'
print "Set to exp 231, scan 1"
reducer.ui.lineEdit_expNo.setText('231')
reducer.ui.lineEdit_scanNo.setText('1')
reducer.ui.lineEdit_wavelength.setText('2.41')

if MOS == LINUX:
reducer.ui.lineEdit_cache.setText('/home/wzz/Temp/')
elif MOS == OSX:
reducer.ui.lineEdit_cache.setText('/Users/wzz/Temp/')

reducer.ui.lineEdit_xmin.setText('5.0')
reducer.ui.lineEdit_xmax.setText('150.0')
reducer.ui.lineEdit_binsize.setText('0.1')
reducer.ui.lineEdit_minD.setText('1.0')
reducer.ui.lineEdit_maxD.setText('20.0')
reducer.ui.lineEdit_binsizeD.setText('0.01')

# set to the right tab
reducer.ui.tabWidget.setCurrentIndex(4)

# load and reduce data
reducer.doLoadData()
reducer.doStripVandiumPeaks()
reducer.doSaveVanRun()

# try:
# reducer.doLoadData()
# except Exception as e:
# print e
# raise e
#
# try:
# reducer.doPlotDspacing()
# except Exception as e:
# print e
#
# try:
# reducer.doPlotQ()
# except Exception as e:
# print e
#
# Skip if there is something wrong
reducer.show()
app.exec_()

0 comments on commit 9626d51

Please sign in to comment.