Skip to content

Commit

Permalink
Allow a WorkspaceGroup of 1 item
Browse files Browse the repository at this point in the history
Refs #10621
  • Loading branch information
DanNixon committed Nov 24, 2014
1 parent dceb451 commit 5db0fad
Showing 1 changed file with 25 additions and 26 deletions.
Expand Up @@ -32,7 +32,7 @@ def summary(self):

def PyInit(self):
self.declareProperty(WorkspaceGroupProperty('InputWorkspaces', '', Direction.Input),
doc='Resolution workspace')
doc='Grouped input workspaces')

self.declareProperty(name='Range1Start', defaultValue=0.0, doc='Range 1 start')
self.declareProperty(name='Range1End', defaultValue=0.0, doc='Range 1 end')
Expand Down Expand Up @@ -60,10 +60,6 @@ def PyInit(self):
def validateInputs(self):
issues = dict()

input_workspaces = self.getProperty('InputWorkspaces').value
if len(input_workspaces.getNames()) < 2:
issues['InputWorkspaces'] = 'Input workspace group must contain at least 2 workspaces'

range_2_start = self.getPropertyValue('Range2Start')
range_2_end = self.getPropertyValue('Range2End')

Expand Down Expand Up @@ -95,8 +91,12 @@ def PyExec(self):
# Do setup
self._setup()

# Lists of input and output workspaces
logger.debug('in_ws:'+str(type(self._input_workspaces)))

# Get input workspaces
input_workspace_names = self._input_workspaces.getNames()

# Lists of input and output workspaces
q_workspaces = list()
q2_workspaces = list()
run_numbers = list()
Expand Down Expand Up @@ -131,28 +131,27 @@ def PyExec(self):
if temp is not None:
temperatures.append(temp)

# Must have two of each type of workspace to continue
if len(q_workspaces) < 2:
raise RuntimeError('Have less than 2 result workspaces in Q')
if len(q2_workspaces) < 2:
raise RuntimeError('Have less than 2 result workspaces in Q^2')

logger.information('Creating Q and Q^2 workspaces')

# Append the spectra of the first two workspaces
AppendSpectra(InputWorkspace1=q_workspaces[0], InputWorkspace2=q_workspaces[1], OutputWorkspace=self._q_workspace)
AppendSpectra(InputWorkspace1=q2_workspaces[0], InputWorkspace2=q2_workspaces[1], OutputWorkspace=self._q2_workspace)

# Append to the spectra of each remaining workspace
for idx in range(2, len(input_workspace_names)):
AppendSpectra(InputWorkspace1=self._q_workspace, InputWorkspace2=q_workspaces[idx], OutputWorkspace=self._q_workspace)
AppendSpectra(InputWorkspace1=self._q2_workspace, InputWorkspace2=q2_workspaces[idx], OutputWorkspace=self._q2_workspace)

# Delete the output workspaces from the ElasticWindow algorithms
for q_ws in q_workspaces:
DeleteWorkspace(q_ws)
for q2_ws in q2_workspaces:
DeleteWorkspace(q2_ws)
if len(input_workspace_names) == 1:
# Just rename single workspaces
RenameWorkspace(InputWorkspace=q_workspaces[0], OutputWorkspace=self._q_workspace)
RenameWorkspace(InputWorkspace=q2_workspaces[0], OutputWorkspace=self._q2_workspace)
else:
# Append the spectra of the first two workspaces
AppendSpectra(InputWorkspace1=q_workspaces[0], InputWorkspace2=q_workspaces[1], OutputWorkspace=self._q_workspace)
AppendSpectra(InputWorkspace1=q2_workspaces[0], InputWorkspace2=q2_workspaces[1], OutputWorkspace=self._q2_workspace)

# Append to the spectra of each remaining workspace
for idx in range(2, len(input_workspace_names)):
AppendSpectra(InputWorkspace1=self._q_workspace, InputWorkspace2=q_workspaces[idx], OutputWorkspace=self._q_workspace)
AppendSpectra(InputWorkspace1=self._q2_workspace, InputWorkspace2=q2_workspaces[idx], OutputWorkspace=self._q2_workspace)

# Delete the output workspaces from the ElasticWindow algorithms
for q_ws in q_workspaces:
DeleteWorkspace(q_ws)
for q2_ws in q2_workspaces:
DeleteWorkspace(q2_ws)

logger.information('Setting vertical axis units and values')

Expand Down

0 comments on commit 5db0fad

Please sign in to comment.