Skip to content

Commit

Permalink
Refs #11289. Checkpointing progress on 3 tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Apr 10, 2015
1 parent 017351b commit 0125ebe
Show file tree
Hide file tree
Showing 8 changed files with 366 additions and 169 deletions.
83 changes: 62 additions & 21 deletions Code/Mantid/scripts/HFIRPowderReduction/HfirPDReductionControl.py
Expand Up @@ -94,32 +94,70 @@ def __init__(self):
return


def getIndividualDetCounts(self, exp, scan, detid, xlabel):
""" Get individual detector counts
"""
# check and get data
if self._myWorkspaceDict.has_key((exp, scan)) is False:
raise NotImplementedError("Exp %d Scan %d does not have reduced \
workspace." % (exp, scan))
else:
rmanager = self._myWorkspaceDict[(exp, scan)]
# END-IF-ELSE

# get raw counts
# FIXME : use **args
if xlabel is None:
tempoutws = api.GetSpiceDataRawCountsFromMD(
InputWorkspace=rmanager.datamdws,
MonitorWorkspace=rmanager.monitormdws,
Mode='Detector',
DetectorID = detid)
else:
tempoutws = api.GetSpiceDataRawCountsFromMD(
InputWorkspace=rmanager.datamdws,
MonitorWorkspace=rmanager.monitormdws,
Mode='Detector',
DetectorID = detid,
XLabel=xlabel)

vecx = tempoutws.readX(0)[:]
vecy = tempoutws.readY(0)[:]

return (vecx, vecy)


def getRawDetectorCounts(self, exp, scan, ptnolist=None):
""" Return raw detector counts as a list of 3-tuples
"""
# check
# check and get data
if self._myWorkspaceDict.has_key((exp, scan)) is False:
raise NotImplementedError("Exp %d Scan %d does not have reduced \
workspace." % (exp, scan))
else:
rmanager = self._myWorkspaceDict[(exp, scan)]
# END-IF-ELSE

# get the complete list of Pt. number
if ptnolist is None:
ptnolist = self._getRunNumberList(datamdws=rmanager.datamdws)

rlist = []
# Loop over all Pt. number
for pt in ptnolist:
# get data
tempoutws = api.GetSpiceDataRawCountsFromMD(
InputWorkspace=rmanager.datamdws,
MonitorWorkspace=rmanager.monitormdws,
Mode='Pt.',
Pt = pt)

vecx = tempoutws.readX(0)[:]
vecy = tempoutws.readY(0)[:]

rlist.append((pt, vecx, vecy))
# ENDFOR

# get data
rmanager = self._myWorkspaceDict[(exp, scan)]
datamdws = rmanager.datamdws

# FIXME - This is a fake
import random
random.seed(1)
x0 = random.random()*40.
listx = []
listy = []
for i in xrange(44):
listx.append(x0+float(i))
listy.append(random.random()*20.)
vecx = numpy.array(listx)
vecy = numpy.array(listy)
ptno = random.randint(1, 45)

rlist = [(ptno, vecx, vecy)]
return (rlist)


Expand Down Expand Up @@ -488,8 +526,11 @@ def downloadFile(url, localfilepath):
Test: 'http://neutron.ornl.gov/user_data/hb2a/exp400/Datafiles/HB2A_exp0400_scan0001.dat'
"""
# open URL
response = urllib2.urlopen(url)
wbuf = response.read()
try:
response = urllib2.urlopen(url)
wbuf = response.read()
except urllib2.HTTPError as e:
raise NotImplementedError("Unable to download file from %s\n\tCause: %s." % (url, str(e)))

if wbuf.count('not found') > 0:
return (False, "File cannot be found at %s." % (url))
Expand Down

0 comments on commit 0125ebe

Please sign in to comment.