Ticket #1295 (closed: fixed)
Mantid terminates using LoadNexus and then deleting some of the periods
Reported by: | Steve Williams | Owned by: | Roman Tolchenov |
---|---|---|---|
Priority: | critical | Milestone: | Iteration 23 |
Component: | Keywords: | ||
Cc: | Blocked By: | ||
Blocking: | Tester: |
Description
The following script is from the SANS scripts and deals with loading a multi-period Nexus file and deleting all but 1 period. It crashes Mantidplot on _my_ computer when logging to file is set to warning, logging to information seems to slow things down enough to stop the conflict. It doesn't crash when run from the command prompt. Problem around add and remove from workspace group signals to Mantidplot's workspace list?
def _leaveSinglePeriod(groupW, period): oldName = groupW.getName()+'_'+str(period) #move this workspace out of the group (this doesn't delete it) groupW.remove(oldName) newName = groupW.getName()+'p'+str(period) #remove the rest of the group mtd.deleteWorkspace(groupW.getName()) return newName def _loadRawData(filename, wsName, ext, spec_min = None, spec_max = None, period = -1): alg = LoadNexus(filename + '.' + ext, wsName,SpectrumMin=spec_min,SpectrumMax=spec_max) pWorksp = mtd[wsName] if pWorksp.isGroup() : #get the number of periods in a group using the fact that each period has a different name nNames = len(pWorksp.getNames()) numPeriods = nNames - 1 else : #if the work space isn't a group there is only one period numPeriods = 1 #period greater than one means we must be looking at a workspace group if period > 1 : if not pWorksp.isGroup() : raise Exception('_loadRawData: A period number can only be specified for a group and workspace '+ pWorksp.getName() + ' is not a group') wsName = _leaveSinglePeriod(pWorksp, period) pWorksp = mtd[wsName] else : #if it is a group but they hadn't specified the period it means load the first spectrum if pWorksp.isGroup() : wsName = _leaveSinglePeriod(pWorksp, 1) pWorksp = mtd[wsName] # Return the filepath actually used to load the data fullpath = alg.getPropertyValue("Filename") return [ os.path.dirname(fullpath), wsName, numPeriods] def _assignHelper(run_string, period = -1): wkspname = '5508_sans_nxs' filename = os.path.join(DATA_PATH,'SANS2D00005508') [filepath, wkspname, nPeriods] = _loadRawData(filename, wkspname, 'nxs', None, None, period) return True, filepath, nPeriods DATA_PATH = '//isis/inst$/cycle_10_1/NDXSANS2D/' print _assignHelper('5508.nxs', 11)
Change History
comment:2 Changed 10 years ago by Steve Williams
The problem caused by the Analysis Data service sends a QT signal to the Mantidplot GUI but doesn't wait for the SLOT function to complete before changing the contents of the Analysis Data service again.
Note: See
TracTickets for help on using
tickets.
This Python causes the same crashes on my machine
The following C++ is equivalent but runs OK in main(). Moving the code into Mantidplot should cause the same crash.