def Find_Peaks(rnum, long_cell, threshold, MaxPeaks, centroid_radius, edge_pixel):
    mantid.PeakDistanceThreshold = 0.9 * 3.14 / long_cell
    mantid.FindPeaksMD(InputWorkspace='WISH000' + str(rnum) + '_MD', PeakDistanceThreshold=PeakDistanceThreshold,
                       MaxPeaks=MaxPeaks, DensityThresholdFactor=threshold,
                       OutputWorkspace='WISH000' + str(rnum) + '_find_peaks', EdgePixels=edge_pixel)
    mantid.CentroidPeaksMD(InputWorkspace='WISH000' + str(rnum) + '_MD', PeakRadius=centroid_radius,
                           PeaksWorkspace='WISH000' + str(rnum) + '_find_peaks',
                           OutputWorkspace='WISH000' + str(rnum) + '_find_peaks')
Esempio n. 2
0
# Spherical Absorption and Lorentz Corrections
ws = mantid.AnvredCorrection(InputWorkspace=ws,
                             LinearScatteringCoef=0.451,
                             LinearAbsorptionCoef=0.993,
                             Radius=0.14)

# Convert to Q space
LabQ = mantid.ConvertToDiffractionMDWorkspace(InputWorkspace=ws,
                                              LorentzCorrection='0',
                                              OutputDimensions='Q (lab frame)',
                                              SplitInto=2,
                                              SplitThreshold=150)

# Find peaks
PeaksLattice = mantid.FindPeaksMD(InputWorkspace=LabQ, MaxPeaks=100)

# 3d integration to centroid peaks
PeaksLattice = mantid.CentroidPeaksMD(InputWorkspace=LabQ,
                                      PeakRadius=0.12,
                                      PeaksWorkspace=PeaksLattice)

# Find the UB matrix using the peaks and known lattice parameters
mantid.FindUBUsingLatticeParameters(PeaksWorkspace=PeaksLattice,
                                    a=10.3522,
                                    b=6.0768,
                                    c=4.7276,
                                    alpha=90,
                                    beta=90,
                                    gamma=90,
                                    NumInitial=20,
Esempio n. 3
0
    def find_peak(self, exp_number, scan_number, pt_number):
        """ Find 1 peak in sample Q space for UB matrix
        :param scan_number:
        :param pt_number:
        :return:tuple as (boolean, object) such as (false, error message) and (true, PeakInfo object)

        This part will be redo as 11847_Load_HB3A_Experiment
        """
        # Check
        assert isinstance(exp_number, int)
        assert isinstance(scan_number, int)
        assert isinstance(pt_number, int)

        # Download or make sure data are there
        status_sp, err_msg_sp = self.download_spice_file(exp_number,
                                                         scan_number,
                                                         over_write=False)
        status_det, err_msg_det = self.download_spice_xml_file(scan_number,
                                                               pt_number,
                                                               exp_number,
                                                               overwrite=False)
        if status_sp is False or status_det is False:
            return False, 'Unable to access data (1) %s (2) %s' % (err_msg_sp,
                                                                   err_msg_det)

        # Collect reduction information: example
        exp_info_ws_name = get_pt_info_ws_name(exp_number, scan_number)
        virtual_instrument_info_table_name = get_virtual_instrument_table_name(
            exp_number, scan_number, pt_number)
        api.CollectHB3AExperimentInfo(
            ExperimentNumber=exp_number,
            GenerateVirtualInstrument=False,
            ScanList=[scan_number],
            PtLists=[-1, pt_number],
            DataDirectory=self._dataDir,
            GetFileFromServer=False,
            Detector2ThetaTolerance=0.01,
            OutputWorkspace=exp_info_ws_name,
            DetectorTableWorkspace=virtual_instrument_info_table_name)

        # Load XML file to MD
        pt_md_ws_name = get_single_pt_md_name(exp_number, scan_number,
                                              pt_number)
        api.ConvertCWSDExpToMomentum(InputWorkspace=exp_info_ws_name,
                                     CreateVirtualInstrument=False,
                                     OutputWorkspace=pt_md_ws_name,
                                     Directory=self._dataDir)

        # Find peak in Q-space
        pt_peak_ws_name = get_single_pt_peak_ws_name(exp_number, scan_number,
                                                     pt_number)
        api.FindPeaksMD(InputWorkspace=pt_md_ws_name,
                        MaxPeaks=10,
                        DensityThresholdFactor=0.01,
                        OutputWorkspace=pt_peak_ws_name)
        peak_ws = AnalysisDataService.retrieve(pt_peak_ws_name)
        pt_md_ws = AnalysisDataService.retrieve(pt_md_ws_name)
        self._myPtMDDict[(exp_number, scan_number, pt_number)] = pt_md_ws

        num_peaks = peak_ws.getNumberPeaks()
        if num_peaks != 1:
            err_msg = 'Find %d peak from scan %d pt %d.  ' \
                      'For UB matrix calculation, 1 and only 1 peak is allowed' % (num_peaks, scan_number, pt_number)
            return False, err_msg
        else:
            self._add_ub_peak_ws(exp_number, scan_number, pt_number, peak_ws)
            status, ret_obj = self.add_peak_info(exp_number, scan_number,
                                                 pt_number)
            if status is True:
                pass
                # peak_info = ret_obj
                # peak_info.set_md_ws(pt_md_ws)
            else:
                err_msg = ret_obj
                return False, err_msg

        return True, ''
Esempio n. 4
0
#
# A lower SplitThreshold, with a reasonable bound on the recursion depth, helps find weaker peaks at higher Q.
#
QLab = mantid.ConvertToDiffractionMDWorkspace(InputWorkspace='SXD23767',
                                              OutputDimensions='Q (lab frame)',
                                              SplitThreshold=50,
                                              LorentzCorrection='1',
                                              MaxRecursionDepth='13',
                                              Extents='-15,15,-15,15,-15,15')

#
#  NaCl has a relatively small unit cell, so the distance between peaks is relatively large.  Setting the PeakDistanceThreshold
#  higher avoids finding high count regions on the sides of strong peaks as separate peaks.
#
peaks_qLab = mantid.FindPeaksMD(InputWorkspace='QLab',
                                MaxPeaks=300,
                                DensityThresholdFactor=10,
                                PeakDistanceThreshold=1.0)

#
#  Fewer peaks index if Centroiding is used.  This indicates that there may be an error in the centroiding algorithm,
#  since the peaks seem to be less accurate.
#
# peaks_qLab = CentroidPeaksMD(InputWorkspace='QLab',PeaksWorkspace=peaks_qLab)

use_fft = True
use_cubic_lat_par = False
use_Niggli_lat_par = False

#
# Note: Reduced tolerance on  FindUBUsingFFT will omit peaks not near the lattice.  This seems to help
# find the Niggli cell correctly, with all angle 60 degrees, and all sides 3.99