Ejemplo n.º 1
0
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(
            Prop.SUBALG_LOGGING).value == SubalgLogging.ON
        cleanupMode = self.getProperty(Prop.CLEANUP).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        wsPrefix = self.getPropertyValue(Prop.OUTPUT_WS)
        self._names = utils.NameSource(wsPrefix, cleanupMode)

        ws = self._inputWS()

        self._instrumentName = ws.getInstrument().getName()

        ws, monWS = self._extractMonitors(ws)

        ws, linePosition = self._peakFitting(ws)

        self._addSampleLogInfo(ws, linePosition)

        ws = self._moveDetector(ws, linePosition)

        ws = self._calibrateDetectorAngleByDirectBeam(ws)

        ws = self._waterCalibration(ws)

        ws = self._normaliseToSlits(ws)

        ws = self._normaliseToFlux(ws, monWS)
        self._cleanup.cleanup(monWS)

        ws = self._subtractFlatBkg(ws)

        ws = self._convertToWavelength(ws)

        self._finalize(ws)
    def PyExec(self):
        """Executes the data reduction workflow."""
        progress = Progress(self, 0.0, 1.0, 4)
        self._subalgLogging = self.getProperty(
            common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON
        wsNamePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        self._names = utils.NameSource(wsNamePrefix, cleanupMode)
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)

        progress.report('Loading inputs')
        mainWS = self._inputWS()

        # First subtract the background, then apply the absorption correction to sample
        progress.report('Subtracting EC')
        mainWS, subtracted = self._subtractEC(mainWS)

        progress.report('Applying self shielding corrections')
        mainWS, applied = self._applyCorrections(mainWS)

        if not applied and not subtracted:
            mainWS = self._cloneOnly(mainWS)

        self._finalize(mainWS)
        progress.report('Done')
Ejemplo n.º 3
0
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(Prop.SUBALG_LOGGING).value == SubalgLogging.ON
        cleanupMode = self.getProperty(Prop.CLEANUP).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        wsPrefix = self.getPropertyValue(Prop.OUTPUT_WS)
        self._names = utils.NameSource(wsPrefix, cleanupMode)

        ws = self._inputWS()
        processReflected = not self._directOnly()
        if processReflected:
            self._addBeamStatisticsToLogs(ws)

        sumType = self._sumType()
        if sumType == SumType.IN_LAMBDA:
            ws = self._sumForegroundInLambda(ws)
            self._addSumTypeToLogs(ws, SumType.IN_LAMBDA)
            if processReflected:
                ws = self._rebinToDirect(ws)
        else:
            ws = self._divideByDirect(ws)
            ws = self._sumForegroundInQ(ws)
            self._addSumTypeToLogs(ws, SumType.IN_Q)
        ws = self._applyWavelengthRange(ws)

        self._finalize(ws)
Ejemplo n.º 4
0
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(
            Prop.SUBALG_LOGGING).value == SubalgLogging.ON
        cleanupMode = self.getProperty(Prop.CLEANUP).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        wsPrefix = self.getPropertyValue(Prop.OUTPUT_WS)
        self._names = utils.NameSource(wsPrefix, cleanupMode)

        ws, directWS = self._inputWS()

        ws = self._correctForChopperOpenings(ws, directWS)
        ws = self._convertToMomentumTransfer(ws)

        sumInLambda = self._sumType(ws.run()) == 'SumInLambda'
        if sumInLambda:
            directWS = self._sameQAndDQ(ws, directWS, 'direct_')
        ws = self._toPointData(ws)
        ws = self._groupPoints(ws)

        if sumInLambda:
            directWS = self._toPointData(directWS, 'direct_')
            directWS = self._groupPoints(directWS, 'direct_')
            ws = self._divideByDirect(ws, directWS)

        self._finalize(ws)
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(Prop.SUBALG_LOGGING).value == SubalgLogging.ON
        cleanupMode = self.getProperty(Prop.CLEANUP).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        wsPrefix = self.getPropertyValue(Prop.OUTPUT_WS)
        self._names = utils.NameSource(wsPrefix, cleanupMode)

        ws = self._inputWS()

        self._instrumentName = ws.getInstrument().getName()

        ws, monWS = self._extractMonitors(ws)

        self._addSampleLogInfo(ws)

        if self.getPropertyValue('AngleOption')=='DetectorAngle' and self.getPropertyValue('Measurement')=='ReflectedBeam':
            # we still have to do this after having loaded and found the foreground centre of the reflected beam
            ws = self._calibrateDetectorAngleByDirectBeam(ws)

        ws = self._waterCalibration(ws)

        ws = self._normaliseToSlits(ws)

        ws = self._normaliseToFlux(ws, monWS)
        self._cleanup.cleanup(monWS)

        ws = self._subtractFlatBkg(ws)

        ws = self._convertToWavelength(ws)

        self._finalize(ws)
Ejemplo n.º 6
0
    def PyExec(self):
        """Execute the data collection workflow."""
        progress = Progress(self, 0.0, 1.0, 9)
        self._report = utils.Report()
        self._subalgLogging = self.getProperty(
            common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON
        namePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        self._names = utils.NameSource(namePrefix, cleanupMode)

        # The variables 'mainWS' and 'monWS shall hold the current main
        # data throughout the algorithm.

        # Get input workspace.
        progress.report('Loading inputs')
        mainWS = self._inputWS()

        # Extract monitors to a separate workspace.
        progress.report('Extracting monitors')
        mainWS, monWS = self._separateMons(mainWS)

        # Save the main workspace for later use, if needed.
        rawWS = None
        if not self.getProperty(common.PROP_OUTPUT_RAW_WS).isDefault:
            rawWS = mainWS
            self._cleanup.protect(rawWS)

        # Normalisation to monitor/time, if requested.
        progress.report('Normalising to monitor/time')
        monWS = self._flatBkgMon(monWS)
        monEPPWS = self._createEPPWSMon(monWS)
        mainWS = self._normalize(mainWS, monWS, monEPPWS)

        # Time-independent background.
        progress.report('Calculating backgrounds')
        mainWS = self._flatBkgDet(mainWS)

        # Calibrate incident energy, if requested.
        progress.report('Calibrating incident energy')
        mainWS, monWS = self._calibrateEi(mainWS, monWS, monEPPWS)
        self._cleanup.cleanup(monWS, monEPPWS)

        # Add the Ei as Efixed instrument parameter
        _addEfixedInstrumentParameter(mainWS)

        progress.report('Correcting TOF')
        mainWS = self._correctTOFAxis(mainWS)
        self._outputRaw(mainWS, rawWS)

        # Find elastic peak positions.
        progress.report('Calculating EPPs')
        self._outputDetEPPWS(mainWS)

        self._finalize(mainWS)
        progress.report('Done')
Ejemplo n.º 7
0
    def PyExec(self):
        """Executes the data reduction workflow."""
        progress = Progress(self, 0.0, 1.0, 9)
        self._report = utils.Report()
        self._subalgLogging = self.getProperty(
            common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON
        wsNamePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        self._names = utils.NameSource(wsNamePrefix, cleanupMode)
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)

        # The variables 'mainWS' and 'monWS shall hold the current main
        # data throughout the algorithm.

        # Get input workspace.
        progress.report('Loading inputs')
        mainWS = self._inputWS()

        progress.report('Applying diagnostics')
        mainWS = self._applyDiagnostics(mainWS)

        # Vanadium normalization.
        progress.report('Normalising to vanadium')
        mainWS = self._normalizeToVana(mainWS)

        # Convert units from TOF to energy.
        progress.report('Converting to energy')
        mainWS = self._convertTOFToDeltaE(mainWS)

        # KiKf conversion.
        mainWS = self._correctByKiKf(mainWS)

        # Rebinning.
        progress.report('Rebinning in energy')
        mainWS = self._rebinInW(mainWS)

        # Divide the energy transfer workspace by bin widths.
        mainWS = self._convertToDistribution(mainWS)

        # Detector efficiency correction.
        progress.report('Correcting detector efficiency')
        mainWS = self._correctByDetectorEfficiency(mainWS)

        progress.report('Grouping detectors')
        mainWS = self._groupDetectors(mainWS)

        self._outputWSConvertedToTheta(mainWS)

        progress.report('Converting to q')
        mainWS = self._sOfQW(mainWS)
        mainWS = self._transpose(mainWS)
        self._finalize(mainWS)
        progress.report('Done')
Ejemplo n.º 8
0
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON
        wsNamePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        self._names = utils.NameSource(wsNamePrefix, cleanupMode)
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)

        # Get input workspace.
        mainWS = self._inputWS()

        # Self shielding and empty container subtraction, if requested.
        correctionWS = self._selfShielding(mainWS)

        self._finalize(correctionWS)
    def PyExec(self):
        """Execute the algorithm."""
        self._subalgLogging = self.getProperty(
            Prop.SUBALG_LOGGING).value == SubalgLogging.ON
        cleanupMode = self.getProperty(Prop.CLEANUP).value
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)
        wsPrefix = self.getPropertyValue(Prop.OUTPUT_WS)
        self._names = utils.NameSource(wsPrefix, cleanupMode)

        wss = self._inputWS()

        effWS = self._efficiencies(wss[0])

        wss = self._commonBinning(wss)

        wss = self._correct(wss, effWS)

        self._finalize(wss)
Ejemplo n.º 10
0
    def PyExec(self):
        """Executes the data reduction workflow."""
        progress = Progress(self, 0.0, 1.0, 7)
        self._report = utils.Report()
        self._subalgLogging = self.getProperty(
            common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON
        wsNamePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        self._names = utils.NameSource(wsNamePrefix, cleanupMode)
        self._cleanup = utils.Cleanup(cleanupMode, self._subalgLogging)

        progress.report('Loading inputs')
        mainWS = self._inputWS()

        maskWSName = self._names.withSuffix('combined_mask')
        maskWS = _createMaskWS(mainWS, maskWSName, self._subalgLogging)
        self._cleanup.cleanupLater(maskWS)

        reportWS = None
        if not self.getProperty(
                common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS).isDefault:
            reportWSName = self.getProperty(
                common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS).valueAsStr
            reportWS = _createDiagnosticsReportTable(
                reportWSName, mainWS.getNumberHistograms(),
                self._subalgLogging)

        progress.report('Loading default mask')
        defaultMaskWS = self._defaultMask(mainWS)
        defaultMaskedSpectra = set()
        if defaultMaskWS is not None:
            defaultMaskedSpectra = _reportDefaultMask(reportWS, defaultMaskWS)
            maskWS = Plus(LHSWorkspace=maskWS,
                          RHSWorkspace=defaultMaskWS,
                          EnableLogging=self._subalgLogging)
            self._cleanup.cleanup(defaultMaskWS)

        progress.report('User-defined mask')
        userMaskWS = self._userMask(mainWS)
        maskWS = Plus(LHSWorkspace=maskWS,
                      RHSWorkspace=userMaskWS,
                      EnableLogging=self._subalgLogging)
        self._cleanup.cleanup(userMaskWS)

        beamStopMaskedSpectra = set()
        if self._beamStopDiagnosticsEnabled(mainWS):
            progress.report('Diagnosing beam stop')
            beamStopMaskWS = self._beamStopDiagnostics(mainWS, maskWS)
            beamStopMaskedSpectra = _reportBeamStopMask(
                reportWS, beamStopMaskWS)
            maskWS = Plus(LHSWorkspace=maskWS,
                          RHSWorkspace=beamStopMaskWS,
                          EnableLogging=self._subalgLogging)
            self._cleanup.cleanup(beamStopMaskWS)

        bkgMaskedSpectra = set()
        if self._bkgDiagnosticsEnabled(mainWS):
            progress.report('Diagnosing backgrounds')
            bkgMaskWS, bkgWS = self._bkgDiagnostics(mainWS)
            bkgMaskedSpectra = _reportBkgDiagnostics(reportWS, bkgWS,
                                                     bkgMaskWS)
            maskWS = Plus(LHSWorkspace=maskWS,
                          RHSWorkspace=bkgMaskWS,
                          EnableLogging=self._subalgLogging)
            self._cleanup.cleanup(bkgMaskWS)
            self._cleanup.cleanup(bkgWS)

        peakMaskedSpectra = set()
        if self._peakDiagnosticsEnabled(mainWS):
            progress.report('Diagnosing peaks')
            peakMaskWS, peakIntensityWS = self._peakDiagnostics(mainWS)
            peakMaskedSpectra = _reportPeakDiagnostics(reportWS,
                                                       peakIntensityWS,
                                                       peakMaskWS)
            maskWS = Plus(LHSWorkspace=maskWS,
                          RHSWorkspace=peakMaskWS,
                          EnableLogging=self._subalgLogging)
            self._cleanup.cleanup(peakMaskWS)
            self._cleanup.cleanup(peakIntensityWS)

        self._outputReports(reportWS, defaultMaskedSpectra,
                            beamStopMaskedSpectra, peakMaskedSpectra,
                            bkgMaskedSpectra)

        self._finalize(maskWS)
        progress.report('Done')