Example #1
0
def strip_bragg_peaks(ws_list_to_correct):
    # TODO move hardcoded spline values into adv. config

    # Strip peaks on banks 1-12 (or 0-11 using 0 based index)
    for index, ws in enumerate(ws_list_to_correct[:12]):
        ws_list_to_correct[index] = mantid.StripPeaks(InputWorkspace=ws,
                                                      OutputWorkspace=ws,
                                                      FWHM=15,
                                                      Tolerance=8)

    # Banks 13 / 14 have broad peaks which are missed so compensate for that and run twice as peaks are very broad
    for _ in range(2):
        ws_list_to_correct[12] = mantid.StripPeaks(
            InputWorkspace=ws_list_to_correct[12],
            OutputWorkspace=ws_list_to_correct[12],
            FWHM=100,
            Tolerance=10)

        ws_list_to_correct[13] = mantid.StripPeaks(
            InputWorkspace=ws_list_to_correct[13],
            OutputWorkspace=ws_list_to_correct[13],
            FWHM=60,
            Tolerance=10)

    return ws_list_to_correct
Example #2
0
def _strip_peaks_new_inst(input_ws, alg_range):
    van_stripped_ws = mantid.StripPeaks(InputWorkspace=input_ws, FWHM=15, Tolerance=8, WorkspaceIndex=0)
    for i in range(1, alg_range):
        van_stripped_ws = mantid.StripPeaks(InputWorkspace=van_stripped_ws, FWHM=15, Tolerance=8,
                                            WorkspaceIndex=i)

    return van_stripped_ws
Example #3
0
def _spline_old_background(in_workspace):
    van_stripped = mantid.ConvertUnits(InputWorkspace=in_workspace, Target="dSpacing")

    # remove bragg peaks before spline
    van_stripped = mantid.StripPeaks(InputWorkspace=van_stripped, FWHM=15, Tolerance=6, WorkspaceIndex=0)
    van_stripped = mantid.StripPeaks(InputWorkspace=van_stripped, FWHM=15, Tolerance=6, WorkspaceIndex=2)
    van_stripped = mantid.StripPeaks(InputWorkspace=van_stripped, FWHM=15, Tolerance=6, WorkspaceIndex=3)
    van_stripped = mantid.StripPeaks(InputWorkspace=van_stripped, FWHM=40, Tolerance=12, WorkspaceIndex=1)
    van_stripped = mantid.StripPeaks(InputWorkspace=van_stripped, FWHM=60, Tolerance=12, WorkspaceIndex=1)

    # Mask low d region that is zero before spline
    for reg in range(0, 4):
        if reg == 1:
            van_stripped = mantid.MaskBins(InputWorkspace=van_stripped, XMin=0, XMax=0.14, SpectraList=reg)
        else:
            van_stripped = mantid.MaskBins(InputWorkspace=van_stripped, XMin=0, XMax=0.06, SpectraList=reg)

    van_stripped = mantid.ConvertUnits(InputWorkspace=van_stripped, Target="TOF")

    splined_ws_list = []
    for i in range(0, 4):
        out_ws_name = "spline" + str(i+1)
        if i == 1:
            coeff = 80
        else:
            coeff = 100
        splined_ws_list.append(mantid.SplineBackground(InputWorkspace=van_stripped, OutputWorkspace=out_ws_name,
                                                       WorkspaceIndex=i, NCoeff=coeff))
    common.remove_intermediate_workspace(van_stripped)
    return splined_ws_list
Example #4
0
def _spline_new2_background(in_workspace, num_splines, instrument_version):
    # remove bragg peaks before spline
    alg_range, unused = _get_instrument_ranges(instrument_version)
    van_stripped_ws = _strip_peaks_new_inst(in_workspace, alg_range)

    # run twice on low angle as peaks are very broad
    for i in range(0, 2):
        van_stripped_ws = mantid.StripPeaks(InputWorkspace=van_stripped_ws, FWHM=100, Tolerance=10,
                                            WorkspaceIndex=12)
        van_stripped_ws = mantid.StripPeaks(InputWorkspace=van_stripped_ws, FWHM=60, Tolerance=10,
                                            WorkspaceIndex=13)

    van_stripped_ws = mantid.ConvertUnits(InputWorkspace=van_stripped_ws, Target="TOF")

    splined_ws_list = _perform_spline_range(instrument_version, num_splines, van_stripped_ws)
    common.remove_intermediate_workspace(van_stripped_ws)
    return splined_ws_list
Example #5
0
    def stripVanadiumPeaks(self, exp, scan, binparams, vanpeakposlist=None):
        """ Strip vanadium peaks

        Arguments:
         - binparams :: string as the list of xmin, binsize, xmax or just binsize
         - vanpeakposlist :: list of peak positions.  If none, then using default

        Return ::
        """
        # Get reduced workspace
        wsmanager = self.getWorkspace(exp, scan, raiseexception=True)
        wksp = wsmanager.reducedws
        if wksp is None:
            raise NotImplementedError(
                "Unable to rebin the data for exp=%d, scan=%d because either data MD workspace and \
                monitor MD workspace is not present." % (exp, scan))

        # Convert unit to Time-of-flight by rebinning
        xaxis_unit = wksp.getAxis(0).getUnit().unitID()
        if xaxis_unit != 'Degrees':
            wksp = api.ConvertCWPDToSpectra(InputWorkspace=wksp,
                                            OutputWorkspace=wksp.name(),
                                            Params=binparams)

        # Vanadium peaks positions
        if vanpeakposlist is None or len(vanpeakposlist) == 0:
            vanpeakposlist = wsmanager.getVanadiumPeaks()
            if vanpeakposlist is None:
                raise NotImplementedError('No vanadium peaks has been set up.')
        # ENDIF

        outwsname = wksp.name() + "_rmVan"
        wksp = api.StripPeaks(InputWorkspace=wksp,
                              OutputWorkspace=outwsname,
                              PeakPositions=numpy.array(vanpeakposlist))

        # Store
        wsmanager.setProcessedVanadiumData(wksp)

        return True