Newer
Older
from __future__ import (absolute_import, division, print_function)
import mantid.simpleapi as mantid
class LoadUtils(object):
A simple class for identifing the current run
and it can return the name, run and instrument.
The current run is the same as the one in MonAnalysis
"""
def __init__(self, parent=None):
exists,tmpWS = self.MuonAnalysisExists()
if exists:
# get everything from the ADS
self.options = mantid.AnalysisDataService.getObjectNames()
self.options = [item.replace(" ","") for item in self.options]
self.instrument=tmpWS.getInstrument().getName()
self.runName=self.instrument+str(tmpWS.getRunNumber()).zfill(8)
else:
mantid.logger.error("Muon Analysis workspace does not exist - no data loaded")
def getNPoints(self):
return self.N_points
def getCurrentWS(self):
return self.runName, self.options
def getInstrument(self):
return self.instrument
if mantid.AnalysisDataService.doesExist("MuonAnalysis_1"):
tmpWS=mantid.AnalysisDataService.retrieve("MuonAnalysis_1")
return True, tmpWS
# if its not period data
elif mantid.AnalysisDataService.doesExist("MuonAnalysis"):
tmpWS=mantid.AnalysisDataService.retrieve("MuonAnalysis")
return True,tmpWS
# Get the groups/pairs for active WS
# ignore raw files
def getWorkspaceNames(self):
# gets all WS in the ADS
runName,options = self.getCurrentWS()
final_options=[]
# only keep the relevant WS (same run as Muon Analysis)
for pick in options:
if ";" in pick and "Raw" not in pick and runName in pick:
final_options.append(pick)
return final_options
# Get the groups/pairs for active WS
def getGroupedWorkspaceNames(self):
# gets all WS in the ADS
runName,options = self.getCurrentWS()
final_options=[]
# only keep the relevant WS (same run as Muon Analysis)
for pick in options:
if "MuonAnalysisGrouped_" in pick:
final_options.append(pick)