当前位置: 首页>>代码示例>>Python>>正文


Python api.Progress类代码示例

本文整理汇总了Python中mantid.api.Progress的典型用法代码示例。如果您正苦于以下问题:Python Progress类的具体用法?Python Progress怎么用?Python Progress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Progress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PyExec

    def PyExec(self):
        # Read the state
        state_property_manager = self.getProperty("SANSState").value
        state = create_deserialized_sans_state_from_property_manager(state_property_manager)

        # Run the appropriate SANSLoader and get the workspaces and the workspace monitors
        # Note that cache optimization is only applied to the calibration workspace since it is not available as a
        # return property and it is also something which is most likely not to change between different reductions.
        use_cached = self.getProperty("UseCached").value
        publish_to_ads = self.getProperty("PublishToCache").value

        data = state.data
        progress = self._get_progress_for_file_loading(data)

        # Get the correct SANSLoader from the SANSLoaderFactory
        load_factory = SANSLoadDataFactory()
        loader = load_factory.create_loader(state)

        workspaces, workspace_monitors = loader.execute(data_info=data, use_cached=use_cached,
                                                        publish_to_ads=publish_to_ads, progress=progress,
                                                        parent_alg=self)
        progress.report("Loaded the data.")

        progress_move = Progress(self, start=0.8, end=1.0, nreports=2)
        progress_move.report("Starting to move the workspaces.")
        self._perform_initial_move(workspaces, state)
        progress_move.report("Finished moving the workspaces.")

        # Set output workspaces
        for workspace_type, workspace in workspaces.items():
            self.set_output_for_workspaces(workspace_type, workspace)

        # Set the output monitor workspaces
        for workspace_type, workspace in workspace_monitors.items():
            self.set_output_for_monitor_workspaces(workspace_type, workspace)
开发者ID:mantidproject,项目名称:mantid,代码行数:35,代码来源:SANSLoad.py

示例2: _sample

    def _sample(self):
        sample_prog = Progress(self, start=0.01, end=0.03, nreports=2)
        sample_prog.report('Setting Sample Material for Sample')
        SetSampleMaterial(self._sample_ws_name , ChemicalFormula=self._sample_chemical_formula,
                          SampleNumberDensity=self._sample_number_density)
        sample = mtd[self._sample_ws_name].sample()
        sam_material = sample.getMaterial()
        # total scattering x-section
        self._sig_s = np.zeros(self._number_can)
        self._sig_s[0] = sam_material.totalScatterXSection()
        # absorption x-section
        self._sig_a = np.zeros(self._number_can)
        self._sig_a[0] = sam_material.absorbXSection()
        # density
        self._density = np.zeros(self._number_can)
        self._density[0] = self._sample_number_density

        if self._use_can:
            sample_prog.report('Setting Sample Material for Container')
            SetSampleMaterial(InputWorkspace=self._can_ws_name, ChemicalFormula=self._can_chemical_formula,
                              SampleNumberDensity=self._can_number_density)
            can_sample = mtd[self._can_ws_name].sample()
            can_material = can_sample.getMaterial()
            self._sig_s[1] = can_material.totalScatterXSection()
            self._sig_a[1] = can_material.absorbXSection()
            self._density[1] = self._can_number_density
开发者ID:mducle,项目名称:mantid,代码行数:26,代码来源:CylinderPaalmanPingsCorrection2.py

示例3: _wave_range

    def _wave_range(self):

        if self._emode != 'Elastic':
            self._fixed = math.sqrt(81.787 / self._efixed)

        if self._emode == 'Efixed':
            self._waves.append(self._fixed)
            logger.information('Efixed mode, setting lambda_fixed to {0}'.format(self._fixed))
        else:
            wave_range = '__wave_range'
            ExtractSingleSpectrum(InputWorkspace=self._sample_ws_name, OutputWorkspace=wave_range, WorkspaceIndex=0)

            Xin = mtd[wave_range].readX(0)
            wave_min = mtd[wave_range].readX(0)[0]
            wave_max = mtd[wave_range].readX(0)[len(Xin) - 1]
            number_waves = self._number_wavelengths
            wave_bin = (wave_max - wave_min) / (number_waves-1)

            self._waves = list()
            wave_prog = Progress(self, start=0.07, end = 0.10, nreports=number_waves)
            for idx in range(0, number_waves):
                wave_prog.report('Appending wave data: %i' % idx)
                self._waves.append(wave_min + idx * wave_bin)
            DeleteWorkspace(wave_range, EnableLogging = False)

            if self._emode == 'Elastic':
                self._elastic = self._waves[int(len(self._waves) / 2)]
                logger.information('Elastic lambda : %f' % self._elastic)

            logger.information('Lambda : %i values from %f to %f' % (len(self._waves), self._waves[0], self._waves[-1]))
开发者ID:samueljackson92,项目名称:mantid,代码行数:30,代码来源:CylinderPaalmanPingsCorrection2.py

示例4: PyExec

 def PyExec(self):
     error = self.getProperty("Error").value
     if error:
         raise RuntimeError('Error in algorithm')
     progress = Progress(self, 0.0, 1.0, 2)
     progress.report('Half way')
     progress.report()
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:test_algorithm_observer.py

示例5: _setup

    def _setup(self):
        setup_prog = Progress(self, start=0.00, end=0.01, nreports=2)
        setup_prog.report('Obtaining input properties')
        self._sample_ws_name = self.getPropertyValue('SampleWorkspace')
        self._sample_density_type = self.getPropertyValue('SampleDensityType')
        self._sample_density = self.getProperty('SampleDensity').value
        self._sample_inner_radius = self.getProperty('SampleInnerRadius').value
        self._sample_outer_radius = self.getProperty('SampleOuterRadius').value
        self._number_can = 1

        self._can_ws_name = self.getPropertyValue('CanWorkspace')
        self._use_can = self._can_ws_name != ''
        self._can_density_type = self.getPropertyValue('CanDensityType')
        self._can_density = self.getProperty('CanDensity').value
        self._can_outer_radius = self.getProperty('CanOuterRadius').value
        if self._use_can:
            self._number_can = 2

        self._step_size = self.getProperty('StepSize').value
        self._radii = np.zeros(self._number_can +1)
        self._radii[0] = self._sample_inner_radius
        self._radii[1] = self._sample_outer_radius
        if (self._radii[1] - self._radii[0]) < 1e-4:
            raise ValueError('Sample outer radius not > inner radius')
        else:
            logger.information('Sample : inner radius = %f ; outer radius = %f' % (self._radii[0], self._radii[1]))
            self._ms = int((self._radii[1] - self._radii[0] + 0.0001)/self._step_size)
            if self._ms < 20:
                raise ValueError('Number of steps ( %i ) should be >= 20' % self._ms)
            else:
                if self._ms < 1:
                    self._ms = 1
                logger.information('Sample : ms = %i ' % self._ms)
        if self._use_can:
            self._radii[2] = self._can_outer_radius
            if (self._radii[2] - self._radii[1]) < 1e-4:
                raise ValueError('Can outer radius not > sample outer radius')
            else:
                logger.information('Can : inner radius = %f ; outer radius = %f' % (self._radii[1], self._radii[2]))
        setup_prog.report('Obtaining beam values')
        beam_width = self.getProperty('BeamWidth').value
        beam_height = self.getProperty('BeamHeight').value
        self._beam = [beam_height,
                      0.5 * beam_width,
                      -0.5 * beam_width,
                      (beam_width / 2),
                      -(beam_width / 2),
                      0.0,
                      beam_height,
                      0.0,
                      beam_height]

        self._interpolate = self.getProperty('Interpolate').value
        self._number_wavelengths = self.getProperty('NumberWavelengths').value

        self._emode = self.getPropertyValue('Emode')
        self._efixed = self.getProperty('Efixed').value

        self._output_ws_name = self.getPropertyValue('OutputWorkspace')
开发者ID:rosswhitfield,项目名称:mantid,代码行数:59,代码来源:CylinderPaalmanPingsCorrection2.py

示例6: PyExec

    def PyExec(self):

        setup_prog = Progress(self, start=0.05, end=0.95, nreports=3)

        self._tmp_fit_name = "__fit_ws"
        self._crop_ws(self._sample_ws, self._tmp_fit_name, self._e_min, self._e_max)

        convert_to_hist_alg = self.createChildAlgorithm("ConvertToHistogram", enableLogging=False)
        convert_to_hist_alg.setProperty("InputWorkspace", self._tmp_fit_name)
        convert_to_hist_alg.setProperty("OutputWorkspace", self._tmp_fit_name)
        convert_to_hist_alg.execute()
        mtd.addOrReplace(self._tmp_fit_name, convert_to_hist_alg.getProperty("OutputWorkspace").value)

        self._convert_to_elasticQ(self._tmp_fit_name)

        num_hist = self._sample_ws.getNumberHistograms()
        if self._hist_max is None:
            self._hist_max = num_hist - 1

        setup_prog.report('Fitting 1 peak')
        self._fit(1)
        setup_prog.report('Fitting 2 peaks')
        self._fit(2)
        self._delete_ws(self._tmp_fit_name)
		
        chi_group = self._output_name + '_ChiSq'
        chi_ws1 = self._output_name + '_1L_ChiSq'
        chi_ws2 = self._output_name + '_2L_ChiSq'
        self._clone_ws(chi_ws1, chi_group)
        self._append(chi_group, chi_ws2, chi_group)
        ws = mtd[chi_group]
        ax = TextAxis.create(2)
        for i, x in enumerate(['1 peak', '2 peaks']):
            ax.setLabel(i, x)
        ws.replaceAxis(1, ax)
        self._delete_ws(chi_ws1)
        self._delete_ws(chi_ws2)

        res_group = self._output_name + '_Result'
        res_ws1 = self._output_name + '_1L_Result'
        res_ws2 = self._output_name + '_2L_Result'
        self._extract(res_ws1, res_group, 1)
        self._extract(res_ws2, '__spectrum', 1)
        self._append(res_group, '__spectrum', res_group)
        self._extract(res_ws2, '__spectrum', 3)
        self._append(res_group, '__spectrum', res_group)
        ws = mtd[res_group]
        ax = TextAxis.create(3)
        for i, x in enumerate(['fwhm.1', 'fwhm.2.1', 'fwhm.2.2']):
            ax.setLabel(i, x)
        ws.replaceAxis(1, ax)
        self._delete_ws(res_ws1)
        self._delete_ws(res_ws2)
        self._delete_ws(self._output_name + '_1L_Parameters')
        self._delete_ws(self._output_name + '_2L_Parameters')
开发者ID:mantidproject,项目名称:scriptrepository,代码行数:55,代码来源:IndirectTwoPeakFit.py

示例7: PyExec

    def PyExec(self):
        """Executes the data reduction workflow."""
        progress = Progress(self, 0.0, 1.0, 4)
        subalgLogging = False
        if self.getProperty(common.PROP_SUBALG_LOGGING).value == common.SUBALG_LOGGING_ON:
            subalgLogging = True
        wsNamePrefix = self.getProperty(common.PROP_OUTPUT_WS).valueAsStr
        cleanupMode = self.getProperty(common.PROP_CLEANUP_MODE).value
        wsNames = common.NameSource(wsNamePrefix, cleanupMode)
        wsCleanup = common.IntermediateWSCleanup(cleanupMode, subalgLogging)

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

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

        progress.report('Subtracting EC')
        mainWS, subtracted = self._subtractEC(mainWS, wsNames, wsCleanup, subalgLogging)

        if not applied and not subtracted:
            mainWS = self._cloneOnly(mainWS, wsNames, wsCleanup, subalgLogging)

        self._finalize(mainWS, wsCleanup)
        progress.report('Done')
开发者ID:stuartcampbell,项目名称:mantid,代码行数:25,代码来源:DirectILLApplySelfShielding.py

示例8: PyExec

    def PyExec(self):
        """ Main execution body
        """

        self.vanaws = self.getProperty("VanadiumWorkspace").value       # returns workspace instance
        outws_name = self.getPropertyValue("OutputWorkspace")           # returns workspace name (string)
        eppws = self.getProperty("EPPTable").value
        nhist = self.vanaws.getNumberHistograms()
        prog_reporter = Progress(self, start=0.0, end=1.0, nreports=nhist+1)

        # calculate array of Debye-Waller factors
        dwf = self.calculate_dwf()

        # for each detector: fit gaussian to get peak_centre and fwhm
        # sum data in the range [peak_centre - 3*fwhm, peak_centre + 3*fwhm]
        dataX = self.vanaws.readX(0)
        coefY = np.zeros(nhist)
        coefE = np.zeros(nhist)
        instrument = self.vanaws.getInstrument()
        detID_offset = self.get_detID_offset()
        peak_centre = eppws.column('PeakCentre')
        sigma = eppws.column('Sigma')

        for idx in range(nhist):
            prog_reporter.report("Setting %dth spectrum" % idx)
            dataY = self.vanaws.readY(idx)
            det = instrument.getDetector(idx + detID_offset)
            if np.max(dataY) == 0 or det.isMasked():
                coefY[idx] = 0.
                coefE[idx] = 0.
            else:
                dataE = self.vanaws.readE(idx)
                fwhm = sigma[idx]*2.*np.sqrt(2.*np.log(2.))
                idxmin = (np.fabs(dataX-peak_centre[idx]+3.*fwhm)).argmin()
                idxmax = (np.fabs(dataX-peak_centre[idx]-3.*fwhm)).argmin()
                coefY[idx] = dwf[idx]*sum(dataY[idxmin:idxmax+1])
                coefE[idx] = dwf[idx]*sum(dataE[idxmin:idxmax+1])

        # create X array, X data are the same for all detectors, so
        coefX = np.zeros(nhist)
        coefX.fill(dataX[0])

        create = self.createChildAlgorithm("CreateWorkspace")
        create.setPropertyValue('OutputWorkspace', outws_name)
        create.setProperty('ParentWorkspace', self.vanaws)
        create.setProperty('DataX', coefX)
        create.setProperty('DataY', coefY)
        create.setProperty('DataE', coefE)
        create.setProperty('NSpec', nhist)
        create.setProperty('UnitX', 'TOF')
        create.execute()
        outws = create.getProperty('OutputWorkspace').value

        self.setProperty("OutputWorkspace", outws)
开发者ID:liyulun,项目名称:mantid,代码行数:54,代码来源:ComputeCalibrationCoefVan.py

示例9: _get_angles

 def _get_angles(self):
     num_hist = mtd[self._sample_ws_name].getNumberHistograms()
     angle_prog = Progress(self, start=0.03, end=0.07, nreports=num_hist)
     source_pos = mtd[self._sample_ws_name].getInstrument().getSource().getPos()
     sample_pos = mtd[self._sample_ws_name].getInstrument().getSample().getPos()
     beam_pos = sample_pos - source_pos
     self._angles = list()
     for index in range(0, num_hist):
         angle_prog.report('Obtaining data for detector angle %i' % index)
         detector = mtd[self._sample_ws_name].getDetector(index)
         two_theta = detector.getTwoTheta(sample_pos, beam_pos) * 180.0 / math.pi
         self._angles.append(two_theta)
     logger.information('Detector angles : %i from %f to %f ' % (len(self._angles), self._angles[0], self._angles[-1]))
开发者ID:rosswhitfield,项目名称:mantid,代码行数:13,代码来源:CylinderPaalmanPingsCorrection2.py

示例10: PyExec

    def PyExec(self):
        use_zero_error_free = self.getProperty("UseZeroErrorFree").value
        file_formats = self._get_file_formats()
        file_name = self.getProperty("Filename").value
        workspace = self.getProperty("InputWorkspace").value

        if use_zero_error_free:
            workspace = get_zero_error_free_workspace(workspace)
        progress = Progress(self, start=0.0, end=1.0, nreports=len(file_formats) + 1)
        for file_format in file_formats:
            progress_message = "Saving to {0}.".format(SaveType.to_string(file_format.file_format))
            progress.report(progress_message)
            save_to_file(workspace, file_format, file_name)
        progress.report("Finished saving workspace to files.")
开发者ID:samueljackson92,项目名称:mantid,代码行数:14,代码来源:SANSSave.py

示例11: PyExec

    def PyExec(self):

        self.setUp()

        # total number of (unsummed) runs
        total = self._sample_files.count(',')+self._background_files.count(',')+self._calibration_files.count(',')

        self._progress = Progress(self, start=0.0, end=1.0, nreports=total)

        self._reduce_multiple_runs(self._sample_files, self._SAMPLE)

        if self._background_files:

            self._reduce_multiple_runs(self._background_files, self._BACKGROUND)

            back_ws = self._red_ws + '_' + self._BACKGROUND

            Scale(InputWorkspace=back_ws, Factor=self._back_scaling, OutputWorkspace=back_ws)

            if self._back_option == 'Sum':
                self._integrate(self._BACKGROUND, self._SAMPLE)
            else:
                self._interpolate(self._BACKGROUND, self._SAMPLE)

            self._subtract_background(self._BACKGROUND, self._SAMPLE)

            DeleteWorkspace(back_ws)

        if self._calibration_files:

            self._reduce_multiple_runs(self._calibration_files, self._CALIBRATION)

            if self._background_calib_files:
                self._reduce_multiple_runs(self._background_calib_files, self._BACKCALIB)

                back_calib_ws = self._red_ws + '_' + self._BACKCALIB

                Scale(InputWorkspace=back_calib_ws, Factor=self._back_calib_scaling, OutputWorkspace=back_calib_ws)

                if self._back_calib_option == 'Sum':
                    self._integrate(self._BACKCALIB, self._CALIBRATION)
                else:
                    self._interpolate(self._BACKCALIB, self._CALIBRATION)

                self._subtract_background(self._BACKCALIB, self._CALIBRATION)

                DeleteWorkspace(back_calib_ws)

            if self._calib_option == 'Sum':
                self._integrate(self._CALIBRATION, self._SAMPLE)
            else:
                self._interpolate(self._CALIBRATION, self._SAMPLE)

            self._calibrate()

            DeleteWorkspace(self._red_ws + '_' + self._CALIBRATION)

        self.log().debug('Run files map is :'+str(self._all_runs))

        self.setProperty('OutputWorkspace',self._red_ws)
开发者ID:stuartcampbell,项目名称:mantid,代码行数:60,代码来源:IndirectILLReductionFWS.py

示例12: PyExec

    def PyExec(self):

        self.setUp()

        self._filter_all_input_files()

        if self._background_file:
            background = '__background_'+self._red_ws
            IndirectILLEnergyTransfer(Run = self._background_file, OutputWorkspace = background, **self._common_args)
            Scale(InputWorkspace=background ,Factor=self._back_scaling,OutputWorkspace=background)

        if self._calibration_file:
            calibration = '__calibration_'+self._red_ws
            IndirectILLEnergyTransfer(Run = self._calibration_file, OutputWorkspace = calibration, **self._common_args)

            if self._background_calib_files:
                back_calibration = '__calibration_back_'+self._red_ws
                IndirectILLEnergyTransfer(Run = self._background_calib_files, OutputWorkspace = back_calibration, **self._common_args)
                Scale(InputWorkspace=back_calibration, Factor=self._back_calib_scaling, OutputWorkspace=back_calibration)
                Minus(LHSWorkspace=calibration, RHSWorkspace=back_calibration, OutputWorkspace=calibration)

            # MatchPeaks does not play nicely with the ws groups
            for ws in mtd[calibration]:
                MatchPeaks(InputWorkspace=ws.getName(), OutputWorkspace=ws.getName(), MaskBins=True, BinRangeTable = '')

            Integration(InputWorkspace=calibration,RangeLower=self._peak_range[0],RangeUpper=self._peak_range[1],
                        OutputWorkspace=calibration)
            self._warn_negative_integral(calibration,'in calibration run.')

        if self._unmirror_option == 5 or self._unmirror_option == 7:
            alignment = '__alignment_'+self._red_ws
            IndirectILLEnergyTransfer(Run = self._alignment_file, OutputWorkspace = alignment, **self._common_args)

        runs = self._sample_file.split(',')

        self._progress = Progress(self, start=0.0, end=1.0, nreports=len(runs))

        for run in runs:
            self._reduce_run(run)

        if self._background_file:
            DeleteWorkspace(background)

        if self._calibration_file:
            DeleteWorkspace(calibration)

        if self._background_calib_files:
            DeleteWorkspace(back_calibration)

        if self._unmirror_option == 5 or self._unmirror_option == 7:
            DeleteWorkspace(alignment)

        GroupWorkspaces(InputWorkspaces=self._ws_list,OutputWorkspace=self._red_ws)

        # unhide the final workspaces, i.e. remove __ prefix
        for ws in mtd[self._red_ws]:
            RenameWorkspace(InputWorkspace=ws,OutputWorkspace=ws.getName()[2:])

        self.setProperty('OutputWorkspace',self._red_ws)
开发者ID:stuartcampbell,项目名称:mantid,代码行数:59,代码来源:IndirectILLReductionQENS.py

示例13: PyExec

    def PyExec(self):
        from IndirectCommon import getWSprefix
        if self._create_output:
            self._out_ws_table = self.getPropertyValue('OutputWorkspaceTable')

        # Process vanadium workspace
        van_ws = ConvertSpectrumAxis(InputWorkspace=self._van_ws,
                                     OutputWorkspace='__ResNorm_vanadium',
                                     Target='ElasticQ',
                                     EMode='Indirect')

        num_hist = van_ws.getNumberHistograms()

        v_values = van_ws.getAxis(1).extractValues()
        v_unit = van_ws.getAxis(1).getUnit().unitID()

        # Process resolution workspace
        padded_res_ws = self._process_res_ws(num_hist)
        prog_namer = Progress(self, start=0.0, end=0.02, nreports=num_hist)
        input_str = ''
        for idx in range(num_hist):
            input_str += '%s,i%d;' % (padded_res_ws, idx)
            prog_namer.report('Generating PlotPeak input string')

        out_name = getWSprefix(self._res_ws) + 'ResNorm_Fit'
        function = 'name=TabulatedFunction,Workspace=%s,Scaling=1,Shift=0,XScaling=1,ties=(Shift=0)' % self._van_ws

        plot_peaks = self.createChildAlgorithm(name='PlotPeakByLogValue', startProgress=0.02, endProgress=0.94, enableLogging=True)
        plot_peaks.setProperty('Input', input_str)
        plot_peaks.setProperty('OutputWorkspace', out_name)
        plot_peaks.setProperty('Function', function)
        plot_peaks.setProperty('FitType', 'Individual')
        plot_peaks.setProperty('PassWSIndexToFunction', True)
        plot_peaks.setProperty('CreateOutput', self._create_output)
        plot_peaks.setProperty('StartX', self._e_min)
        plot_peaks.setProperty('EndX', self._e_max)
        plot_peaks.execute()
        fit_params = plot_peaks.getProperty('OutputWorkspace').value

        params = {'XScaling':'Stretch', 'Scaling':'Intensity'}
        result_workspaces = []
        prog_process = Progress(self, start=0.94, end=1.0, nreports=3)
        for param_name, output_name in params.items():
            result_workspaces.append(self._process_fit_params(fit_params, param_name, v_values, v_unit, output_name))
            prog_process.report('Processing Fit data')

        GroupWorkspaces(InputWorkspaces=result_workspaces,
                        OutputWorkspace=self._out_ws)
        self.setProperty('OutputWorkspace', self._out_ws)

        DeleteWorkspace(van_ws)
        DeleteWorkspace(padded_res_ws)
        prog_process.report('Deleting workspaces')

        if self._create_output:
            self.setProperty('OutputWorkspaceTable', fit_params)
开发者ID:spaceyatom,项目名称:mantid,代码行数:56,代码来源:ResNorm2.py

示例14: _rebin_result

    def _rebin_result(self):                    #apply rebinning
        rebin_prog = Progress(self, start=0.0, end=0.8, nreports=3)
        rebin_prog.report('Rebin result ')

        logger.information('Rebin option : ' + self._rebin_option)
        qrange = ''
        if mtd.doesExist(self._sofq):                  #check if S(Q) WS exists
		    logger.information('Sofq data from Workspace : %s' % self._sofq)
        else:                                    #read from nxs file
            sofq_path = FileFinder.getFullPath(self._sofq + '.nxs')
            LoadNexusProcessed(Filename=sofq_path,
                               OutputWorkspace=self._sofq,
                               EnableLogging=False)
            logger.information('Sq data from File : %s' % sofq_path)
        rebin_logs = [('rebin_option', self._rebin_option)]
        if self._rebin_option != 'None':          #rebin to be applied
            rebin_logs.append(('rebin_qrange', self._rebin_qrange))
            logger.information('Rebin qrange : %s' % self._rebin_qrange)
            if self._rebin_qrange == 'New':          #new Q range
                mtd[self._final_q].setDistribution(True)
                xs = mtd[self._final_q].readX(0)
                new_dq = float(self._rebin_qinc)       #increment in Q
                xmax = (int(xs[len(xs) -1 ] / new_dq) + 1) * new_dq    #find number of points & Q max
                qrange = '0.0, %f, %f' % (new_dq, xmax)   #create Q range
                self._rebin(self._final_q, self._final_q, qrange)
                x = mtd[self._final_q].readX(0)
                xshift = 0.5 * (x[0] - x[1])
                self._scale_x(self._final_q, self._final_q, xshift)
                logger.information('Output S(Q) rebinned for range : %s' % qrange)
            if self._rebin_qrange == 'Snap':         #use input Q range
                gR = mtd[self._sofq].getRun()      #input S(Q) WS
                stype = gR.getLogData('input_type').value
                logger.information('Rebin option : %s' % self._rebin_option)
                if stype != 'Q':             #check input was in Q
                    raise ValueError('Input type must be Q for Snap option')
                if self._rebin_option == 'Interpolate':
                    self._rebin_ws(self._final_q, self._sofq, self._final_q)
                    logger.information('Output S(Q) interpolated to input S(Q) : %s' % self._sofq)
                if self._rebin_option == 'Spline':
                    self._spline_interp(self._sofq, self._final_q, self._final_q, '', 2)
                    logger.information('Output S(Q) spline interpolated to input S(Q) :%s ' % self._sofq)
                    rebin_logs.append(('rebin_Q_file', self._sofq))
        log_names = [item[0] for item in rebin_logs]
        log_values = [item[1] for item in rebin_logs]
#        self._add_sample_log_mult(self._final_q, log_names, log_values)
        logger.information('Corrected WS created : %s' % self._final_q)
开发者ID:mantidproject,项目名称:scriptrepository,代码行数:46,代码来源:DeconD4Result.py

示例15: PyExec

    def PyExec(self):
        # Read the state
        state_property_manager = self.getProperty("SANSState").value
        state = create_deserialized_sans_state_from_property_manager(state_property_manager)

        progress = Progress(self, start=0.0, end=1.0, nreports=3)
        input_workspace = self.getProperty("InputWorkspace").value

        data_type_as_string = self.getProperty("DataType").value
        data_type = DataType.from_string(data_type_as_string)

        slicer = SliceEventFactory.create_slicer(state, input_workspace, data_type)
        slice_info = state.slice

        # Perform the slicing
        progress.report("Starting to slice the workspace.")
        sliced_workspace, slice_factor = slicer.create_slice(input_workspace, slice_info)

        # Scale the monitor accordingly
        progress.report("Scaling the monitors.")
        self.scale_monitors(slice_factor)

        # Set the outputs
        append_to_sans_file_tag(sliced_workspace, "_sliced")
        self.setProperty("OutputWorkspace", sliced_workspace)
        self.setProperty("SliceEventFactor", slice_factor)
        progress.report("Finished slicing.")
开发者ID:DanNixon,项目名称:mantid,代码行数:27,代码来源:SANSSliceEvent.py


注:本文中的mantid.api.Progress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。