示例#1
0
    def PyExec(self):

        self._setup()

        process_prog = Progress(self,
                                start=0.1,
                                end=0.9,
                                nreports=len(self._workspace_names))
        process_prog.report("Running diffraction")
        scan_alg = self.createChildAlgorithm(
            "ISISIndirectDiffractionReduction", 0.05, 0.95)
        scan_alg.setProperty(
            'InputFiles', formatRuns(self._data_files, self._instrument_name))
        scan_alg.setProperty('ContainerFiles', self._can_files)
        scan_alg.setProperty('ContainerScaleFactor', self._can_scale)
        scan_alg.setProperty('CalFile', self._calib_file)
        scan_alg.setProperty('SumFiles', self._sum_files)
        scan_alg.setProperty('LoadLogFiles', self._load_logs)
        scan_alg.setProperty('Instrument', self._instrument_name)
        scan_alg.setProperty('Mode', self._mode)
        scan_alg.setProperty('SpectraRange', self._spectra_range)
        scan_alg.setProperty('RebinParam', self._rebin_paras)
        scan_alg.setProperty('GroupingPolicy', self._grouping_method)
        scan_alg.setProperty('OutputWorkspace', self._output_ws)
        scan_alg.execute()
        logger.information('OutputWorkspace : %s' % self._output_ws)

        self.setProperty('OutputWorkspace',
                         scan_alg.getPropertyValue('OutputWorkspace'))

        workspace_names = mtd[self._output_ws].getNames()
        scan_workspace = self._output_ws + '_scan'
        temperatures = list()
        run_numbers = []
        for input_ws in workspace_names:
            temp = self._get_temperature(input_ws)
            if temp is not None:
                temperatures.append(temp)
            # Get the run number
            run_no = self._get_InstrRun(input_ws)[1]
            run_numbers.append(run_no)

        clone_alg = self.createChildAlgorithm("CloneWorkspace",
                                              enableLogging=False)
        append_alg = self.createChildAlgorithm("AppendSpectra",
                                               enableLogging=False)
        for idx in range(len(workspace_names)):
            if idx == 0:
                clone_alg.setProperty("InputWorkspace", workspace_names[0])
                clone_alg.setProperty("OutputWorkspace", scan_workspace)
                clone_alg.execute()
                scan_workspace = clone_alg.getProperty("OutputWorkspace").value
            else:
                append_alg.setProperty("InputWorkspace1", scan_workspace)
                append_alg.setProperty("InputWorkspace2", workspace_names[idx])
                append_alg.setProperty("OutputWorkspace", scan_workspace)
                append_alg.execute()
                scan_workspace = append_alg.getProperty(
                    "OutputWorkspace").value

        # Set the vertical axis units
        num_hist = scan_workspace.getNumberHistograms()
        v_axis_is_temp = num_hist == len(temperatures)

        if v_axis_is_temp:
            logger.notice('Vertical axis is in temperature')
            unit = ('Temperature', 'K')
        else:
            logger.notice('Vertical axis is in run number')
            unit = ('Run No', '_last 3 digits')

        # Create a new vertical axis for the workspaces
        y_ws_axis = NumericAxis.create(len(run_numbers))
        y_ws_axis.setUnit("Label").setLabel(unit[0], unit[1])

        # Set the vertical axis values
        for idx in range(num_hist):
            if v_axis_is_temp:
                y_ws_axis.setValue(idx, float(temperatures[idx]))
            else:
                y_ws_axis.setValue(idx, float(run_numbers[idx][-3:]))

        # Add the new vertical axis to each workspace
        scan_workspace.replaceAxis(1, y_ws_axis)

        mtd.addOrReplace(self._output_ws + '_scan', scan_workspace)
示例#2
0
    def PyExec(self):

        self._setup()
        progress = Progress(self, 0.0, 0.05, 3)

        progress.report('Energy transfer')
        scan_alg = self.createChildAlgorithm("ISISIndirectEnergyTransferWrapper", 0.05, 0.95)
        scan_alg.setProperty('InputFiles', formatRuns(self._data_files, self._instrument_name))
        scan_alg.setProperty('SumFiles', self._sum_files)
        scan_alg.setProperty('LoadLogFiles', self._load_logs)
        scan_alg.setProperty('CalibrationWorkspace', self._calibration_ws)
        scan_alg.setProperty('Instrument', self._instrument_name)
        scan_alg.setProperty('Analyser', self._analyser)
        scan_alg.setProperty('Reflection', self._reflection)
        scan_alg.setProperty('Efixed', self._efixed)
        scan_alg.setProperty('SpectraRange', self._spectra_range)
        scan_alg.setProperty('BackgroundRange', self._background_range)
        scan_alg.setProperty('RebinString', self._rebin_string)
        scan_alg.setProperty('DetailedBalance', self._detailed_balance)
        scan_alg.setProperty('ScaleFactor', self._scale_factor)
        scan_alg.setProperty('FoldMultipleFrames', self._fold_multiple_frames)
        scan_alg.setProperty('GroupingMethod', self._grouping_method)
        scan_alg.setProperty('GroupingWorkspace', self._grouping_ws)
        scan_alg.setProperty('MapFile', self._grouping_map_file)
        scan_alg.setProperty('UnitX', self._output_x_units)
        scan_alg.setProperty('OutputWorkspace', self._red_ws)
        scan_alg.execute()
        logger.information('ReducedWorkspace : %s' % self._red_ws)

        Rebin(InputWorkspace=self._red_ws,
              OutputWorkspace=self._red_ws,
              Params=self._energy_range,
              EnableLogging=False)

        input_workspace_names = mtd[self._red_ws].getNames()

        inst = mtd[input_workspace_names[0]].getInstrument()
        if inst.hasParameter('analyser'):
            analyser_name = inst.getStringParameter('analyser')[0]
            analyser_comp = inst.getComponentByName(analyser_name)
            if analyser_comp is not None and analyser_comp.hasParameter('resolution'):
                self._resolution = float(analyser_comp.getNumberParameter('resolution')[0])
            else:
                self._resolution = 0.01
        logger.information('Resolution = %d' % self._resolution)

        output_workspaces = list()
        temperatures = list()
        run_numbers = list()
        sofqw_alg = self.createChildAlgorithm("SofQW", enableLogging=False)
        group_alg = self.createChildAlgorithm("GroupWorkspaces", enableLogging=False)

        for input_ws in input_workspace_names:
            progress.report('SofQW for workspace: %s' % input_ws)
            sofqw_alg.setProperty("InputWorkspace", input_ws)
            sofqw_alg.setProperty("QAxisBinning", self._q_range)
            sofqw_alg.setProperty("EMode", 'Indirect')
            sofqw_alg.setProperty("ReplaceNaNs", True)
            sofqw_alg.setProperty("Method", 'NormalisedPolygon')
            sofqw_alg.setProperty("OutputWorkspace", input_ws + '_sqw')
            sofqw_alg.execute()
            mtd.addOrReplace(input_ws + '_sqw', sofqw_alg.getProperty("OutputWorkspace").value)
            output_workspaces.append(input_ws + '_sqw')

            # Get the sample temperature
            temp = self._get_temperature(input_ws + '_sqw')
            if temp is not None:
                temperatures.append(temp)
            else:
                # Get the run number
                run_no = self._get_InstrRun(input_ws)[1]
                run_numbers.append(run_no)

        y_axis = mtd[input_workspace_names[0] + '_sqw'].getAxis(1)
        y_values = y_axis.extractValues()
        q = list()
        for idx in range(len(y_values)):
            q.append(y_values[idx])
        group_alg.setProperty("InputWorkspaces", output_workspaces)
        group_alg.setProperty("OutputWorkspace", self._sqw_ws)
        group_alg.execute()
        mtd.addOrReplace(self._sqw_ws, group_alg.getProperty("OutputWorkspace").value)
        logger.information('Sqw Workspace : %s' % self._sqw_ws)

        # Get input workspaces
        input_workspace_names = mtd[self._sqw_ws].getNames()
        output_workspaces = list()
        width_workspaces = list()

        delete_alg = self.createChildAlgorithm("DeleteWorkspace", enableLogging=False)
        create_alg = self.createChildAlgorithm("CreateWorkspace", enableLogging=False)
        for input_ws in input_workspace_names:
            progress.report('SofQWMoments for workspace: %s' % input_ws)
            SofQWMoments(InputWorkspace=input_ws,
                         EnergyMin=self._energy_range[0],
                         EnergyMax=self._energy_range[2],
                         Scale=self._scale_factor,
                         OutputWorkspace=input_ws + '_mom',
                         EnableLogging=False)
            output_workspaces.append(input_ws + '_mom')
            progress.report('Fitting workspace: %s' % input_ws)
            num_hist = mtd[input_ws].getNumberHistograms()
            result = '__result'
            params_table = '__result_Parameters'
            dataX = list()
            dataY = list()
            dataE = list()
            func = 'name=Lorentzian,Amplitude=1.0,PeakCentre=0.0,FWHM=0.01'
            func += ',constraint=(Amplitude>0.0,FWHM>0.0)'
            for idx in range(num_hist):
                Fit(InputWorkspace=input_ws,
                    Function=func,
                    DomainType='Simple',
                    WorkspaceIndex=idx,
                    Minimizer='Levenberg-Marquardt',
                    MaxIterations=500,
                    CreateOutput=True,
                    Output=result,
                    OutputParametersOnly=False,
                    EnableLogging=False)
                dataX.append(q[idx])
                para_y = np.asarray(mtd[params_table].column('Value'))
                dataY.append(para_y[2])
                para_e = np.asarray(mtd[params_table].column('Error'))
                dataE.append(para_e[2])
            progress.report('Creating width workspace')
            width_ws = input_ws + '_width'
            create_alg.setProperty("OutputWorkspace", width_ws)
            create_alg.setProperty("DataX", dataX)
            create_alg.setProperty("DataY", dataY)
            create_alg.setProperty("DataE", dataE)
            create_alg.setProperty("NSpec", 1)
            create_alg.setProperty("UnitX", 'MomentumTransfer')
            create_alg.setProperty("YUnitLabel", 'FWHM')
            create_alg.execute()
            mtd.addOrReplace(width_ws, create_alg.getProperty("OutputWorkspace").value)
            width_workspaces.append(width_ws)
            delete_alg.setProperty("Workspace", params_table)
            delete_alg.execute()
            delete_alg.setProperty("Workspace", result + '_NormalisedCovarianceMatrix')
            delete_alg.execute()
            delete_alg.setProperty("Workspace", result + '_Workspace')
            delete_alg.execute()
        logger.information('Moment Workspace : %s' % self._moment_ws)

        width_workspace = self._sqw_ws + '_width'
        clone_alg = self.createChildAlgorithm("CloneWorkspace", enableLogging=True)
        append_alg = self.createChildAlgorithm("AppendSpectra", enableLogging=True)
        for idx in range(len(width_workspaces)):
            if idx == 0:
                clone_alg.setProperty("InputWorkspace", width_workspaces[0])
                clone_alg.setProperty("OutputWorkspace", width_workspace)
                clone_alg.execute()
                mtd.addOrReplace(width_workspace, clone_alg.getProperty("OutputWorkspace").value)
            else:
                append_alg.setProperty("InputWorkspace1", width_workspace)
                append_alg.setProperty("InputWorkspace2", width_workspaces[idx])
                append_alg.setProperty("OutputWorkspace", width_workspace)
                append_alg.execute()
                mtd.addOrReplace(width_workspace, append_alg.getProperty("OutputWorkspace").value)
        logger.information('Width Workspace : %s' % width_workspace)

        numb_temp = len(temperatures)
        x_axis_is_temp = len(input_workspace_names) == numb_temp

        if x_axis_is_temp:
            logger.information('X axis is in temperature')
            unit = ('Temperature', 'K')
        else:
            logger.information('X axis is in run number')
            unit = ('Run No', 'last 3 digits')

        xdat = list()
        ydat = list()
        edat = list()
        for idx in range(len(temperatures)):
            x = mtd[width_workspace].readX(idx)
            y = mtd[width_workspace].readY(idx)
            e = mtd[width_workspace].readE(idx)
            if x_axis_is_temp:
                xdat.append(float(temperatures[idx]))
            else:
                xdat.append(float(run_numbers[idx][-3:]))
            ydat.append(y[5] / x[5])
            edat.append(e[5] / x[5])
        diffusion_workspace = self._sqw_ws + '_diffusion'
        create_alg = self.createChildAlgorithm("CreateWorkspace", enableLogging=False)
        create_alg.setProperty("OutputWorkspace", diffusion_workspace)
        create_alg.setProperty("DataX", xdat)
        create_alg.setProperty("DataY", ydat)
        create_alg.setProperty("DataE", edat)
        create_alg.setProperty("NSpec", 1)
        create_alg.setProperty("YUnitLabel", 'Diffusion')
        create_alg.execute()
        mtd.addOrReplace(diffusion_workspace, create_alg.getProperty("OutputWorkspace").value)
        unitx = mtd[diffusion_workspace].getAxis(0).setUnit("Label")
        unitx.setLabel(unit[0], unit[1])
        logger.information('Diffusion Workspace : %s' % diffusion_workspace)
示例#3
0
    def PyExec(self):

        self._setup()
        progress = Progress(self, 0.0, 0.05, 3)

        progress.report('Energy transfer')
        scan_alg = self.createChildAlgorithm(
            "ISISIndirectEnergyTransferWrapper", 0.05, 0.95)
        scan_alg.setProperty(
            'InputFiles', formatRuns(self._data_files, self._instrument_name))
        scan_alg.setProperty('SumFiles', self._sum_files)
        scan_alg.setProperty('LoadLogFiles', self._load_logs)
        scan_alg.setProperty('CalibrationWorkspace', self._calibration_ws)
        scan_alg.setProperty('Instrument', self._instrument_name)
        scan_alg.setProperty('Analyser', self._analyser)
        scan_alg.setProperty('Reflection', self._reflection)
        scan_alg.setProperty('Efixed', self._efixed)
        scan_alg.setProperty('SpectraRange', self._spectra_range)
        scan_alg.setProperty('BackgroundRange', self._background_range)
        scan_alg.setProperty('RebinString', self._rebin_string)
        scan_alg.setProperty('DetailedBalance', self._detailed_balance)
        scan_alg.setProperty('ScaleFactor', self._scale_factor)
        scan_alg.setProperty('FoldMultipleFrames', self._fold_multiple_frames)
        scan_alg.setProperty('GroupingMethod', self._grouping_method)
        scan_alg.setProperty('GroupingWorkspace', self._grouping_ws)
        scan_alg.setProperty('MapFile', self._grouping_map_file)
        scan_alg.setProperty('UnitX', self._output_x_units)
        scan_alg.setProperty('OutputWorkspace', self._red_ws)
        scan_alg.execute()
        logger.information('ReducedWorkspace : %s' % self._red_ws)

        Rebin(InputWorkspace=self._red_ws,
              OutputWorkspace=self._red_ws,
              Params=self._energy_range,
              EnableLogging=False)

        input_workspace_names = mtd[self._red_ws].getNames()

        inst = mtd[input_workspace_names[0]].getInstrument()
        if inst.hasParameter('analyser'):
            analyser_name = inst.getStringParameter('analyser')[0]
            analyser_comp = inst.getComponentByName(analyser_name)
            if analyser_comp is not None and analyser_comp.hasParameter(
                    'resolution'):
                self._resolution = float(
                    analyser_comp.getNumberParameter('resolution')[0])
            else:
                self._resolution = 0.01
        logger.information('Resolution = %d' % self._resolution)

        output_workspaces = list()
        temperatures = list()
        run_numbers = list()
        sofqw_alg = self.createChildAlgorithm("SofQW", enableLogging=False)
        group_alg = self.createChildAlgorithm("GroupWorkspaces",
                                              enableLogging=False)

        for input_ws in input_workspace_names:
            progress.report('SofQW for workspace: %s' % input_ws)
            sofqw_alg.setProperty("InputWorkspace", input_ws)
            sofqw_alg.setProperty("QAxisBinning", self._q_range)
            sofqw_alg.setProperty("EMode", 'Indirect')
            sofqw_alg.setProperty("ReplaceNaNs", True)
            sofqw_alg.setProperty("Method", 'NormalisedPolygon')
            sofqw_alg.setProperty("OutputWorkspace", input_ws + '_sqw')
            sofqw_alg.execute()
            mtd.addOrReplace(input_ws + '_sqw',
                             sofqw_alg.getProperty("OutputWorkspace").value)
            output_workspaces.append(input_ws + '_sqw')

            # Get the sample temperature
            temp = self._get_temperature(input_ws + '_sqw')
            if temp is not None:
                temperatures.append(temp)
            else:
                # Get the run number
                run_no = self._get_InstrRun(input_ws)[1]
                run_numbers.append(run_no)

        y_axis = mtd[input_workspace_names[0] + '_sqw'].getAxis(1)
        y_values = y_axis.extractValues()
        q = list()
        for idx in range(len(y_values)):
            q.append(y_values[idx])
        group_alg.setProperty("InputWorkspaces", output_workspaces)
        group_alg.setProperty("OutputWorkspace", self._sqw_ws)
        group_alg.execute()
        mtd.addOrReplace(self._sqw_ws,
                         group_alg.getProperty("OutputWorkspace").value)
        logger.information('Sqw Workspace : %s' % self._sqw_ws)

        # Get input workspaces
        input_workspace_names = mtd[self._sqw_ws].getNames()
        output_workspaces = list()
        width_workspaces = list()

        delete_alg = self.createChildAlgorithm("DeleteWorkspace",
                                               enableLogging=False)
        create_alg = self.createChildAlgorithm("CreateWorkspace",
                                               enableLogging=False)
        for input_ws in input_workspace_names:
            progress.report('SofQWMoments for workspace: %s' % input_ws)
            SofQWMoments(InputWorkspace=input_ws,
                         EnergyMin=self._energy_range[0],
                         EnergyMax=self._energy_range[2],
                         Scale=self._scale_factor,
                         OutputWorkspace=input_ws + '_mom',
                         EnableLogging=False)
            output_workspaces.append(input_ws + '_mom')
            progress.report('Fitting workspace: %s' % input_ws)
            num_hist = mtd[input_ws].getNumberHistograms()
            result = '__result'
            params_table = '__result_Parameters'
            dataX = list()
            dataY = list()
            dataE = list()
            func = 'name=Lorentzian,Amplitude=1.0,PeakCentre=0.0,FWHM=0.01'
            func += ',constraint=(Amplitude>0.0,FWHM>0.0)'
            for idx in range(num_hist):
                Fit(InputWorkspace=input_ws,
                    Function=func,
                    DomainType='Simple',
                    WorkspaceIndex=idx,
                    Minimizer='Levenberg-Marquardt',
                    MaxIterations=500,
                    CreateOutput=True,
                    Output=result,
                    OutputParametersOnly=False,
                    EnableLogging=False)
                dataX.append(q[idx])
                para_y = np.asarray(mtd[params_table].column('Value'))
                dataY.append(para_y[2])
                para_e = np.asarray(mtd[params_table].column('Error'))
                dataE.append(para_e[2])
            progress.report('Creating width workspace')
            width_ws = input_ws + '_width'
            create_alg.setProperty("OutputWorkspace", width_ws)
            create_alg.setProperty("DataX", dataX)
            create_alg.setProperty("DataY", dataY)
            create_alg.setProperty("DataE", dataE)
            create_alg.setProperty("NSpec", 1)
            create_alg.setProperty("UnitX", 'MomentumTransfer')
            create_alg.setProperty("YUnitLabel", 'FWHM')
            create_alg.execute()
            mtd.addOrReplace(width_ws,
                             create_alg.getProperty("OutputWorkspace").value)
            width_workspaces.append(width_ws)
            delete_alg.setProperty("Workspace", params_table)
            delete_alg.execute()
            delete_alg.setProperty("Workspace",
                                   result + '_NormalisedCovarianceMatrix')
            delete_alg.execute()
            delete_alg.setProperty("Workspace", result + '_Workspace')
            delete_alg.execute()
        logger.information('Moment Workspace : %s' % self._moment_ws)

        width_workspace = self._sqw_ws + '_width'
        clone_alg = self.createChildAlgorithm("CloneWorkspace",
                                              enableLogging=True)
        append_alg = self.createChildAlgorithm("AppendSpectra",
                                               enableLogging=True)
        for idx in range(len(width_workspaces)):
            if idx == 0:
                clone_alg.setProperty("InputWorkspace", width_workspaces[0])
                clone_alg.setProperty("OutputWorkspace", width_workspace)
                clone_alg.execute()
                mtd.addOrReplace(
                    width_workspace,
                    clone_alg.getProperty("OutputWorkspace").value)
            else:
                append_alg.setProperty("InputWorkspace1", width_workspace)
                append_alg.setProperty("InputWorkspace2",
                                       width_workspaces[idx])
                append_alg.setProperty("OutputWorkspace", width_workspace)
                append_alg.execute()
                mtd.addOrReplace(
                    width_workspace,
                    append_alg.getProperty("OutputWorkspace").value)
        logger.information('Width Workspace : %s' % width_workspace)

        numb_temp = len(temperatures)
        x_axis_is_temp = len(input_workspace_names) == numb_temp

        if x_axis_is_temp:
            logger.information('X axis is in temperature')
            unit = ('Temperature', 'K')
        else:
            logger.information('X axis is in run number')
            unit = ('Run No', 'last 3 digits')

        xdat = list()
        ydat = list()
        edat = list()
        for idx in range(len(temperatures)):
            x = mtd[width_workspace].readX(idx)
            y = mtd[width_workspace].readY(idx)
            e = mtd[width_workspace].readE(idx)
            if x_axis_is_temp:
                xdat.append(float(temperatures[idx]))
            else:
                xdat.append(float(run_numbers[idx][-3:]))
            ydat.append(y[5] / x[5])
            edat.append(e[5] / x[5])
        diffusion_workspace = self._sqw_ws + '_diffusion'
        create_alg = self.createChildAlgorithm("CreateWorkspace",
                                               enableLogging=False)
        create_alg.setProperty("OutputWorkspace", diffusion_workspace)
        create_alg.setProperty("DataX", xdat)
        create_alg.setProperty("DataY", ydat)
        create_alg.setProperty("DataE", edat)
        create_alg.setProperty("NSpec", 1)
        create_alg.setProperty("YUnitLabel", 'Diffusion')
        create_alg.execute()
        mtd.addOrReplace(diffusion_workspace,
                         create_alg.getProperty("OutputWorkspace").value)
        unitx = mtd[diffusion_workspace].getAxis(0).setUnit("Label")
        unitx.setLabel(unit[0], unit[1])
        logger.information('Diffusion Workspace : %s' % diffusion_workspace)
    def PyExec(self):

        self._setup()

        process_prog = Progress(self, start=0.1, end=0.9, nreports=len(self._workspace_names))
        process_prog.report("Running diffraction")
        scan_alg = self.createChildAlgorithm("ISISIndirectDiffractionReduction", 0.05, 0.95)
        scan_alg.setProperty('InputFiles', formatRuns(self._data_files, self._instrument_name))
        scan_alg.setProperty('ContainerFiles', self._can_files)
        scan_alg.setProperty('ContainerScaleFactor', self._can_scale)
        scan_alg.setProperty('CalFile', self._calib_file)
        scan_alg.setProperty('SumFiles', self._sum_files)
        scan_alg.setProperty('LoadLogFiles', self._load_logs)
        scan_alg.setProperty('Instrument', self._instrument_name)
        scan_alg.setProperty('Mode', self._mode)
        scan_alg.setProperty('SpectraRange', self._spectra_range)
        scan_alg.setProperty('RebinParam', self._rebin_paras)
        scan_alg.setProperty('GroupingPolicy', self._grouping_method)
        scan_alg.setProperty('OutputWorkspace', self._output_ws)
        scan_alg.execute()
        logger.information('OutputWorkspace : %s' % self._output_ws)

        self.setProperty('OutputWorkspace', scan_alg.getPropertyValue('OutputWorkspace'))

        workspace_names = mtd[self._output_ws].getNames()
        scan_workspace = self._output_ws + '_scan'
        temperatures = list()
        run_numbers = []
        for input_ws in workspace_names:
            temp = self._get_temperature(input_ws)
            if temp is not None:
                temperatures.append(temp)
            # Get the run number
            run_no = self._get_InstrRun(input_ws)[1]
            run_numbers.append(run_no)

        clone_alg = self.createChildAlgorithm("CloneWorkspace", enableLogging=False)
        append_alg = self.createChildAlgorithm("AppendSpectra", enableLogging=False)
        for idx in range(len(workspace_names)):
            if idx == 0:
                clone_alg.setProperty("InputWorkspace", workspace_names[0])
                clone_alg.setProperty("OutputWorkspace", scan_workspace)
                clone_alg.execute()
                scan_workspace = clone_alg.getProperty("OutputWorkspace").value
            else:
                append_alg.setProperty("InputWorkspace1", scan_workspace)
                append_alg.setProperty("InputWorkspace2", workspace_names[idx])
                append_alg.setProperty("OutputWorkspace", scan_workspace)
                append_alg.execute()
                scan_workspace = append_alg.getProperty("OutputWorkspace").value

        # Set the vertical axis units
        num_hist = scan_workspace.getNumberHistograms()
        v_axis_is_temp = num_hist == len(temperatures)

        if v_axis_is_temp:
            logger.notice('Vertical axis is in temperature')
            unit = ('Temperature', 'K')
        else:
            logger.notice('Vertical axis is in run number')
            unit = ('Run No', '_last 3 digits')

        # Create a new vertical axis for the workspaces
        y_ws_axis = NumericAxis.create(len(run_numbers))
        y_ws_axis.setUnit("Label").setLabel(unit[0], unit[1])

        # Set the vertical axis values
        for idx in range(num_hist):
            if v_axis_is_temp:
                y_ws_axis.setValue(idx, float(temperatures[idx]))
            else:
                y_ws_axis.setValue(idx, float(run_numbers[idx][-3:]))

        # Add the new vertical axis to each workspace
        scan_workspace.replaceAxis(1, y_ws_axis)

        mtd.addOrReplace(self._output_ws + '_scan', scan_workspace)