Skip to content

Commit

Permalink
Refs #8887 Fixed problem that was stopping auto-calc
Browse files Browse the repository at this point in the history
dq/q calculation was the problem that stopped everything occuring.

The gui now attempts to calculate dq/q if not present, but if the logs it needs aren't there it stops and forces the user to enter one.

If it's given dq/q or can calcualte one itself, it has no problem calulating qmin and qmax if neccessary.
  • Loading branch information
keithnbrown committed Feb 5, 2014
1 parent c20f1d8 commit 5350c7c
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -344,18 +344,17 @@ def process(self):
self.accMethod = self.getAccMethod()
loadedRun = load_live_runs.get_live_data(config['default.instrument'], Accumulation = self.accMethod)
else:
Load(Filename=run, outputWorkspace="run")
Load(Filename=runno[0], OutputWorkspace="run")
loadedRun = mtd["run"]

try:
dqq = calcRes(runno[0])
dqq = calcRes(loadedRun)
item = QtGui.QTableWidgetItem()
item.setText(str(dqq))
self.tableMain.setItem(row, 15, item)
print "Calculated resolution: ", dqq
except IndexError:
logger.warning("Cannot calculate resolution owing to unknown log properties. dq/q will need to be manually entered.")
logger.error("Cannot calculate resolution owing to unknown log properties. dq/q will need to be manually entered.")
return
else:
dqq = float(self.tableMain.item(row, 15).text())
# Populate runlist
Expand Down Expand Up @@ -586,7 +585,6 @@ def saveWorkspaces(self):
except Exception as ex:
logger.notice("Could not open save workspace dialog")
logger.notice(str(ex))
#print "Disabled - Run desired save algorithm from main MantidPlot window instead"
def showHelp(self):
import webbrowser
webbrowser.open('http://www.mantidproject.org/ISIS_Reflectometry_GUI')
Expand All @@ -596,15 +594,23 @@ def showHelp(self):
Get a representative workspace from the input workspace.
'''
def get_representative_workspace(run):
if type(run) == type(int()):
_runno =Load(Filename=run, OutputWorkspace=runno)
elif mtd.doesExist(run):
print type(run)
if isinstance(run, WorkspaceGroup):
run_number = groupGet(run[0], "samp", "run_number")
_runno = Load(Filename=str(run_number))
elif isinstance(run, Workspace):
_runno = run
elif isinstance(run, int):
_runno = Load(Filename=run, OutputWorkspace=runno)
elif isinstance(run, str) and mtd.doesExist(run):
ws = mtd[run]
if isinstance(ws, WorkspaceGroup):
run_number = groupGet(ws[0], "samp", "run_number")
_runno =Load(Filename=str(run_number))
else:
_runno = Load(Filename=str(run_number))
elif isinstance(run, str):
_runno = Load(Filename=run.replace("raw", "nxs", 1), OutputWorkspace=runno)
else:
raise TypeError("Must be a workspace, int or str")
return _runno

'''
Expand All @@ -622,7 +628,10 @@ def calcRes(run):
s1vg = s1vg.getNumberParameter('vertical gap')[0]
s2vg = inst.getComponentByName('slit2')
s2vg = s2vg.getNumberParameter('vertical gap')[0]
if type(theta) != float:
import numpy
if isinstance(theta, numpy.float64):
th = theta.size
elif not isinstance(theta, float):
th = theta[len(theta) - 1]
else:
th = theta
Expand All @@ -641,20 +650,23 @@ def groupGet(wksp, whattoget, field=''):
'''
if (whattoget == 'inst'):
if isinstance(wksp, str):
if isinstance(mtd[wksp], WorkspaceGroup):
at = getattr(mtd[wksp],'size',None)
if callable(at):
return mtd[wksp][0].getInstrument()
else:
return mtd[wksp].getInstrument()
elif isinstance(wksp, Workspace):
if isinstance(wksp, WorkspaceGroup):
at = getattr(wksp,'size',None)
if callable(at):
return wksp[0].getInstrument()
else:
return wksp.getInstrument()
else:
return 0
elif (whattoget == 'samp' and field != ''):
if isinstance(wksp, str):
if isinstance(mtd[wksp], WorkspaceGroup):
at = getattr(mtd[wksp],'size',None)
if callable(at):
try:
log = mtd[wksp][0].getRun().getLogData(field).value
if (type(log) is int or type(log) is str):
Expand All @@ -675,9 +687,10 @@ def groupGet(wksp, whattoget, field=''):
res = 0
print "Block " + field + " not found."
elif isinstance(wksp, Workspace):
if isinstance(wksp, WorkspaceGroup):
at = getattr(wksp,'size',None)
if callable(at):
try:
log = mtd[wksp][0].getRun().getLogData(field).value
log = wksp[0].getRun().getLogData(field).value
if (type(log) is int or type(log) is str):
res = log
else:
Expand All @@ -700,12 +713,14 @@ def groupGet(wksp, whattoget, field=''):
return res
elif (whattoget == 'wksp'):
if isinstance(wksp, str):
if isinstance(mtd[wksp], WorkspaceGroup):
at = getattr(mtd[wksp],'size',None)
if callable(at):
return mtd[wksp][0].getNumberHistograms()
else:
return mtd[wksp].getNumberHistograms()
elif isinstance(wksp, Workspace):
if isinstance(wksp, WorkspaceGroup):
at = getattr(wksp,'size',None)
if callable(at):
return mtd[wksp][0].getNumberHistograms()
else:
return wksp.getNumberHistograms()
Expand Down

0 comments on commit 5350c7c

Please sign in to comment.