• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mtd.doesExist函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testRawWorkspaceOutput

 def testRawWorkspaceOutput(self):
     outWSName = 'outWS'
     rawWSName = 'rawWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'OutputRawWorkspace': rawWSName,
         'rethrow': True
     }
     run_algorithm('DirectILLCollectData', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     inWS = mtd[self._TEST_WS_NAME]
     self.assertTrue(mtd.doesExist(rawWSName))
     rawWS = mtd[rawWSName]
     ys = rawWS.extractY()
     originalYS = inWS.extractY()
     numpy.testing.assert_almost_equal(ys, originalYS[1:, :])
     es = rawWS.extractE()
     originalES = inWS.extractE()
     numpy.testing.assert_almost_equal(es, originalES[1:, :])
     xs = rawWS.extractX()
     outXS = outWS.extractX()
     numpy.testing.assert_almost_equal(xs, outXS)
     Ei = rawWS.getRun().getProperty('Ei').value
     outEi = outWS.getRun().getProperty('Ei').value
     self.assertEqual(Ei, outEi)
     wavelength = outWS.getRun().getProperty('wavelength').value
     outWavelength = outWS.getRun().getProperty('wavelength').value
     self.assertEqual(wavelength, outWavelength)
开发者ID:DanNixon,项目名称:mantid,代码行数:30,代码来源:DirectILLCollectDataTest.py


示例2: test_unary_ops_with_workspaces_not_in_ADS

 def test_unary_ops_with_workspaces_not_in_ADS(self):
     mdws = CreateMDHistoWorkspace(SignalInput=[0], ErrorInput=[0], Dimensionality=1, Extents=[0, 1], NumberOfBins=1, Names=['a'], Units=['TOF'], StoreInADS=False)
     mdws_ads = CreateMDHistoWorkspace(SignalInput=[0], ErrorInput=[0], Dimensionality=1, Extents=[0, 1], NumberOfBins=1, Names=['a'], Units=['TOF'], StoreInADS=True)
     result1 = ~mdws
     self.assertTrue(mtd.doesExist('result1'))
     result2 = ~mdws_ads
     self.assertTrue(mtd.doesExist('result2'))
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:WorkspaceUnaryOpsTest.py


示例3: __setupCalibration

    def __setupCalibration(self, wksp):
        '''Convert whatever calibration/grouping/masking into workspaces that will be passed down'''
        if self.haveDeterminedCalibration:
            return  # nothing to do
        self.haveDeterminedCalibration = True

        # first see if the workspaces have been specified
        # check that the canonical names don't already exist as a backup
        if not self.getProperty('CalibrationWorkspace').isDefault:
            self.__calWksp = self.getPropertyValue('CalibrationWorkspace')
        elif not self.getProperty('OffsetsWorkspace').isDefault:
            self.__calWksp = self.getPropertyValue('OffsetsWorkspace') + '_cal'
            ConvertDiffCal(OffsetsWorkspace=self.getPropertyValue('OffsetsWorkspace'),
                           OutputWorkspace=self.instr + '_cal')
            self.setProperty('CalibrationWorkspace', self.__calWksp)
        elif mtd.doesExist(self.instr + '_cal'):
            self.__calWksp = self.instr + '_cal'

        if not self.getProperty('GroupingWorkspace').isDefault:
            self.__grpWksp = self.getPropertyValue('GroupingWorkspace')
        elif mtd.doesExist(self.instr + '_group'):
            self.__grpWksp = self.instr + '_group'

        if not self.getProperty('MaskWorkspace').isDefault:
            self.__mskWksp = self.getPropertyValue('MaskWorkspace')
        elif mtd.doesExist(self.instr + '_mask'):
            self.__mskWksp = self.instr + '_mask'

        # check that anything was specified
        if self.getProperty('CalFileName').isDefault and self.getProperty('GroupFilename').isDefault:
            self.kwargs = self.__getAlignAndFocusArgs()
            return

        # decide what to load
        loadCalibration = not bool(self.__calWksp)
        loadGrouping = not bool(self.__grpWksp)
        loadMask = not bool(self.__mskWksp)

        # load and update
        if loadCalibration or loadGrouping or loadMask:
            if not wksp:
                raise RuntimeError('Trying to load calibration without a donor workspace')
            LoadDiffCal(InputWorkspace=wksp,
                        Filename=self.getPropertyValue('CalFileName'),
                        GroupFilename=self.getPropertyValue('GroupFilename'),
                        MakeCalWorkspace=loadCalibration,
                        MakeGroupingWorkspace=loadGrouping,
                        MakeMaskWorkspace=loadMask,
                        WorkspaceName=self.instr)
        if loadCalibration:
            self.__calWksp = self.instr + '_cal'
            self.setPropertyValue('CalibrationWorkspace', self.instr + '_cal')
        if loadGrouping:
            self.__grpWksp = self.instr + '_group'
            self.setPropertyValue('GroupingWorkspace', self.instr + '_group')
        if loadMask:
            self.__mskWksp = self.instr + '_mask'
            self.setPropertyValue('MaskWorkspace', self.instr + '_mask')
        self.kwargs = self.__getAlignAndFocusArgs()
开发者ID:mantidproject,项目名称:mantid,代码行数:59,代码来源:AlignAndFocusPowderFromFiles.py


示例4: testOutputIsDistribution

 def testOutputIsDistribution(self):
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'OutputSofThetaEnergyWorkspace': 'SofThetaE',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     ws = mtd[outWSName]
     self.assertTrue(ws.isDistribution())
     self.assertTrue(mtd.doesExist('SofThetaE'))
     ws = mtd['SofThetaE']
     self.assertTrue(ws.isDistribution())
开发者ID:stuartcampbell,项目名称:mantid,代码行数:15,代码来源:DirectILLReductionTest.py


示例5: testSuccessWhenEverythingDisabled

 def testSuccessWhenEverythingDisabled(self):
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'FlatBkg': 'Flat Bkg OFF',
         'IncidentEnergyCalibration': 'Energy Calibration OFF',
         'Normalisation': 'Normalisation OFF',
         'ElasticChannel': 'Default Elastic Channel',
         'rethrow': True
     }
     run_algorithm('DirectILLCollectData', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     inWS = mtd[self._TEST_WS_NAME]
     self.assertEquals(outWS.getNumberHistograms(), inWS.getNumberHistograms() - 1)
     xs = outWS.extractX()
     originalXs = inWS.extractX()
     numpy.testing.assert_almost_equal(xs, originalXs[1:, :])
     ys = outWS.extractY()
     originalYs = inWS.extractY()
     numpy.testing.assert_almost_equal(ys, originalYs[1:, :])
     es = outWS.extractE()
     originalEs = inWS.extractE()
     numpy.testing.assert_almost_equal(es, originalEs[1:, :])
开发者ID:DanNixon,项目名称:mantid,代码行数:25,代码来源:DirectILLCollectDataTest.py


示例6: testMaskedComponents

 def testMaskedComponents(self):
     inWS = mtd[self._RAW_WS_NAME]
     spectraCount = inWS.getNumberHistograms()
     outWSName = 'diagnosticsWS'
     kwargs = {
         'InputWorkspace': self._RAW_WS_NAME,
         'OutputWorkspace': outWSName,
         'ElasticPeakDiagnostics': 'Peak Diagnostics OFF',
         'BkgDiagnostics': 'Bkg Diagnostics OFF',
         'BeamStopDiagnostics': 'Beam Stop Diagnostics OFF',
         'DefaultMask': 'Default Mask OFF',
         'MaskedComponents': 'tube_1',
         'rethrow': True
     }
     run_algorithm('DirectILLDiagnostics', **kwargs)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), spectraCount)
     self.assertEquals(outWS.blocksize(), 1)
     for i in range(spectraCount):
         Ys = outWS.readY(i)
         detector = outWS.getDetector(i)
         componentName = detector.getFullName()
         if 'tube_1' in componentName:
             self.assertEquals(Ys[0], 1)
         else:
             self.assertEquals(Ys[0], 0)
开发者ID:mantidproject,项目名称:mantid,代码行数:27,代码来源:DirectILLDiagnosticsTest.py


示例7: testNoOperationClonesInputWorkspace

 def testNoOperationClonesInputWorkspace(self):
     ws = self._cloneTestWorkspace()
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'rethrow': True
     }
     run_algorithm('DirectILLApplySelfShielding', **algProperties)
     # If the previous run didn't clone the input workspace, the two later
     # calls will be triggered to use 'outWS' as the input.
     self.assertTrue(mtd.doesExist(outWSName))
     corrFactor = 0.43
     corrWS = self._cloneTestWorkspace('correctionWS')
     for i in range(corrWS.getNumberHistograms()):
         ys = corrWS.dataY(i)
         ys.fill(corrFactor)
         es = corrWS.dataE(i)
         es.fill(0)
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'SelfShieldingCorrectionWorkspace': corrWS,
         'rethrow': True
     }
     run_algorithm('DirectILLApplySelfShielding', **algProperties)
     run_algorithm('DirectILLApplySelfShielding', **algProperties)
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), ws.getNumberHistograms())
     ys = outWS.extractY()
     originalYs = ws.extractY()
     numpy.testing.assert_almost_equal(ys, originalYs / corrFactor)
     es = outWS.extractE()
     originalEs = ws.extractE()
     numpy.testing.assert_almost_equal(es, originalEs / corrFactor)
开发者ID:DanNixon,项目名称:mantid,代码行数:35,代码来源:DirectILLApplySelfShieldingTest.py


示例8: __accumulate

    def __accumulate(self, chunkname, sumname, chunkunfocusname, sumuunfocusname, firstrun, removelogs=False):
        """accumulate newdata `wkspname` into sum `sumwkspname` and delete `wkspname`"""
        # the first call to accumulate to a specific target should be a simple rename
        self.log().debug('__accumulate({}, {}, {}, {}, {})'.format(chunkname, sumname, chunkunfocusname,
                                                                   sumuunfocusname, firstrun))
        if chunkname == sumname:
            return  # there is nothing to be done

        if not firstrun:
            # if the sum workspace doesn't already exist, just rename
            if not mtd.doesExist(sumname):
                firstrun = True

        if firstrun:
            if chunkname != sumname:
                RenameWorkspace(InputWorkspace=chunkname, OutputWorkspace=sumname)
            if chunkunfocusname and chunkunfocusname != sumuunfocusname:
                RenameWorkspace(InputWorkspace=chunkunfocusname, OutputWorkspace=sumuunfocusname)
        else:
            if removelogs:
                RemoveLogs(Workspace=chunkname)  # accumulation has them already
            Plus(LHSWorkspace=sumname, RHSWorkspace=chunkname, OutputWorkspace=sumname,
                 ClearRHSWorkspace=self.kwargs['PreserveEvents'])
            DeleteWorkspace(Workspace=chunkname)
            self.__compressEvents(sumname)  # could be smarter about when to run

            if chunkunfocusname and chunkunfocusname != sumuunfocusname:
                if removelogs:
                    RemoveLogs(Workspace=chunkunfocusname)  # accumulation has them already
                Plus(LHSWorkspace=sumuunfocusname, RHSWorkspace=chunkunfocusname, OutputWorkspace=sumuunfocusname,
                     ClearRHSWorkspace=self.kwargs['PreserveEvents'])
                DeleteWorkspace(Workspace=chunkunfocusname)
                self.__compressEvents(sumuunfocusname)  # could be smarter about when to run
开发者ID:mantidproject,项目名称:mantid,代码行数:33,代码来源:AlignAndFocusPowderFromFiles.py


示例9: testSelfShieldingCorrections

 def testSelfShieldingCorrections(self):
     ws = self._cloneTestWorkspace()
     corrFactor = 0.789
     corrWS = self._cloneTestWorkspace('correctionWS')
     for i in range(corrWS.getNumberHistograms()):
         ys = corrWS.dataY(i)
         ys.fill(corrFactor)
         es = corrWS.dataE(i)
         es.fill(0)
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'SelfShieldingCorrectionWorkspace': corrWS,
         'rethrow': True
     }
     run_algorithm('DirectILLApplySelfShielding', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), ws.getNumberHistograms())
     ys = outWS.extractY()
     originalYs = ws.extractY()
     numpy.testing.assert_almost_equal(ys, originalYs / corrFactor)
     es = outWS.extractE()
     originalEs = ws.extractE()
     numpy.testing.assert_almost_equal(es, originalEs / corrFactor)
开发者ID:DanNixon,项目名称:mantid,代码行数:26,代码来源:DirectILLApplySelfShieldingTest.py


示例10: __determineCharacterizations

    def __determineCharacterizations(self, filename, wkspname):
        useCharac = bool(self.charac is not None)
        loadFile = not mtd.doesExist(wkspname)

        # input workspace is only needed to find a row in the characterizations table
        tempname = None
        if loadFile:
            if useCharac:
                tempname = '__%s_temp' % wkspname
                # set the loader for this file
                loader = self.__createLoader(filename, tempname)
                loader.setProperty('MetaDataOnly', True)  # this is only supported by LoadEventNexus
                loader.execute()

                # get the underlying loader name if we used the generic one
                if self.__loaderName == 'Load':
                    self.__loaderName = loader.getPropertyValue('LoaderName')
        else:
            tempname = wkspname  # assume it is already loaded

        # put together argument list
        args = dict(ReductionProperties=self.getProperty('ReductionProperties').valueAsStr)
        for name in PROPS_FOR_PD_CHARACTER:
            prop = self.getProperty(name)
            if not prop.isDefault:
                args[name] = prop.value
        if tempname is not None:
            args['InputWorkspace'] = tempname
        if useCharac:
            args['Characterizations'] = self.charac

        PDDetermineCharacterizations(**args)

        if loadFile and useCharac:
            DeleteWorkspace(Workspace=tempname)
开发者ID:samueljackson92,项目名称:mantid,代码行数:35,代码来源:AlignAndFocusPowderFromFiles.py


示例11: test_monitors_loaded_into_ADS_when_monitor_load_is_true_for_back_scattering

 def test_monitors_loaded_into_ADS_when_monitor_load_is_true_for_back_scattering(self):
     diff_mode = "SingleDifference"
     self._run_load("14188", "3-134", diff_mode, load_mon=True)
     self.assertTrue(mtd.doesExist('evs_raw_monitors'))
     monitor_ws = mtd['evs_raw_monitors']
     self.assertTrue(isinstance(monitor_ws, MatrixWorkspace))
     self.assertEqual(monitor_ws.readX(0)[0], 5)
     self.assertEqual(monitor_ws.readX(0)[-1], 19990)
开发者ID:DanNixon,项目名称:mantid,代码行数:8,代码来源:LoadVesuvioTest.py


示例12: PyExec

    def PyExec(self):
        self._loadCharacterizations()
        charac = ""
        if mtd.doesExist("characterizations"):
            charac = "characterizations"

        # arguments for both AlignAndFocusPowder and AlignAndFocusPowderFromFiles
        self._alignArgs['OutputWorkspace'] = self.getPropertyValue("OutputWorkspace")
        self._alignArgs['RemovePromptPulseWidth'] = self.getProperty("RemovePromptPulseWidth").value
        self._alignArgs['CompressTolerance'] = COMPRESS_TOL_TOF
        self._alignArgs['PreserveEvents'] = True
        self._alignArgs['CalFileName'] = self.getProperty("CalibrationFile").value
        self._alignArgs['Params']=self.getProperty("Binning").value
        self._alignArgs['ResampleX']=self.getProperty("ResampleX").value
        self._alignArgs['Dspacing']=True
        self._alignArgs['CropWavelengthMin'] = self.getProperty('CropWavelengthMin').value
        self._alignArgs['CropWavelengthMax'] = self.getProperty('CropWavelengthMax').value
        self._alignArgs['ReductionProperties'] = '__snspowderreduction'

        wksp = self.getProperty("InputWorkspace").value
        if wksp is None:  # run from file with caching
            wksp = AlignAndFocusPowderFromFiles(Filename=self.getProperty("Filename").value,
                                                CacheDir=self.getProperty("CacheDir").value,
                                                MaxChunkSize=self.getProperty("MaxChunkSize").value,
                                                FilterBadPulses=self.getProperty("FilterBadPulses").value,
                                                Characterizations=charac,
                                                FrequencyLogNames=self.getProperty("FrequencyLogNames").value,
                                                WaveLengthLogNames=self.getProperty("WaveLengthLogNames").value,
                                                **(self._alignArgs))
        else:  # process the input workspace
            self.log().information("Using input workspace. Ignoring properties 'Filename', " +
                                   "'OutputWorkspace', 'MaxChunkSize', and 'FilterBadPulses'")

            # get the correct row of the table
            PDDetermineCharacterizations(InputWorkspace=wksp,
                                         Characterizations=charac,
                                         ReductionProperties="__snspowderreduction",
                                         FrequencyLogNames=self.getProperty("FrequencyLogNames").value,
                                         WaveLengthLogNames=self.getProperty("WaveLengthLogNames").value)

            wksp = AlignAndFocusPowder(InputWorkspace=wksp,
                                       **(self._alignArgs))

        wksp = NormaliseByCurrent(InputWorkspace=wksp, OutputWorkspace=wksp)
        wksp.getRun()['gsas_monitor'] = 1
        if self._iparmFile is not None:
            wksp.getRun()['iparm_file'] = self._iparmFile

        wksp = SetUncertainties(InputWorkspace=wksp, OutputWorkspace=wksp,
                                SetError="sqrtOrOne")
        SaveGSS(InputWorkspace=wksp,
                Filename=self.getProperty("PDFgetNFile").value,
                SplitFiles=False, Append=False,
                MultiplyByBinWidth=False,
                Bank=mantid.pmds["__snspowderreduction"]["bank"].value,
                Format="SLOG", ExtendedHeader=True)

        self.setProperty("OutputWorkspace", wksp)
开发者ID:DanNixon,项目名称:mantid,代码行数:58,代码来源:PDToPDFgetN.py


示例13: testSuccessfulRun

 def testSuccessfulRun(self):
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'SubalgorithmLogging': 'Logging ON',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
开发者ID:DanNixon,项目名称:mantid,代码行数:10,代码来源:DirectILLReductionTest.py


示例14: _delete

 def _delete(self, ws):
     """Delete the given workspace in ws if it is not protected, and
     deletion is actually turned on.
     """
     if not self._doDelete:
         return
     try:
         ws = str(ws)
     except RuntimeError:
         return
     if ws not in self._protected and mtd.doesExist(ws):
         DeleteWorkspace(Workspace=ws, EnableLogging=self._deleteAlgorithmLogging)
开发者ID:DanNixon,项目名称:mantid,代码行数:12,代码来源:DirectILL_common.py


示例15: _createDiagnosticsReportTable

def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLogging):
    """Return a table workspace for detector diagnostics reporting."""
    if mtd.doesExist(reportWSName):
        reportWS = mtd[reportWSName]
    else:
        reportWS = CreateEmptyTableWorkspace(OutputWorkspace=reportWSName,
                                             EnableLogging=algorithmLogging)
    existingColumnNames = reportWS.getColumnNames()
    if 'WorkspaceIndex' not in existingColumnNames:
        reportWS.addColumn('int', 'WorkspaceIndex', _PLOT_TYPE_X)
    reportWS.setRowCount(numberHistograms)
    for i in range(numberHistograms):
        reportWS.setCell('WorkspaceIndex', i, i)
    return reportWS
开发者ID:DanNixon,项目名称:mantid,代码行数:14,代码来源:DirectILLDiagnostics.py


示例16: test_binary_ops_with_workspaces_not_in_ADS

 def test_binary_ops_with_workspaces_not_in_ADS(self):
     ws = CreateSampleWorkspace(StoreInADS=False)
     initialY = ws.readY(0)[0]
     ws_ads = CreateSampleWorkspace(StoreInADS=True)
     result1 = ws + ws
     self.assertTrue(mtd.doesExist('result1'))
     result2 = ws + ws_ads
     self.assertTrue(mtd.doesExist('result2'))
     result3 = ws_ads + ws
     self.assertTrue(mtd.doesExist('result3'))
     result4 = ws_ads + ws_ads
     self.assertTrue(mtd.doesExist('result4'))
     result5 = ws + 1
     self.assertTrue(mtd.doesExist('result5'))
     result6 = 1 + ws
     self.assertTrue(mtd.doesExist('result6'))
     result7 = ws_ads + 1
     self.assertTrue(mtd.doesExist('result7'))
     result8 = 1 + ws_ads
     self.assertTrue(mtd.doesExist('result8'))
     ws += 1
     self.assertFalse(mtd.doesExist('ws'))
     ws_ads += 1
     self.assertTrue(mtd.doesExist('ws_ads'))
开发者ID:DanNixon,项目名称:mantid,代码行数:24,代码来源:WorkspaceBinaryOpsTest.py


示例17: testDirectBeamMasking

 def testDirectBeamMasking(self):
     beamWSName = 'beam_masking_ws'
     kwargs = {
         'OutputWorkspace': beamWSName,
         'Function': 'One Peak',
         'rethrow': True
     }
     run_algorithm('CreateSampleWorkspace', **kwargs)
     kwargs = {
         'Workspace': beamWSName,
         'ParameterName': 'beam_stop_diagnostics_spectra',
         'ParameterType': 'String',
         'Value': '43-57, 90-110, 145-155', # Spectrum numbers.
         'rethrow': True
     }
     run_algorithm('SetInstrumentParameter', **kwargs)
     beamWS = mtd[beamWSName]
     # From now on, we work on workspace indices.
     # First range is fully covered by the beam stop.
     for i in range(42, 57):
         ys = beamWS.dataY(i)
         ys *= 0.0
     # Second range is partially covered by the beam stop.
     # Actually, only this range will be recongnized as beam stop's shadow.
     for i in range(92, 105):
         ys = beamWS.dataY(i)
         ys *= 0.0
     # The third range is not covered by the beam stop at all.
     outWSName = 'diagnosticsWS'
     kwargs = {
         'InputWorkspace': beamWSName,
         'OutputWorkspace': outWSName,
         'ElasticPeakDiagnostics': 'Peak Diagnostics OFF',
         'BkgDiagnostics': 'Bkg Diagnostics OFF',
         'DefaultMask': 'Default Mask OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLDiagnostics', **kwargs)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), beamWS.getNumberHistograms())
     self.assertEquals(outWS.blocksize(), 1)
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         if i >= 92 and i < 105:
             self.assertEquals(ys[0], 1)
         else:
             self.assertEquals(ys[0], 0)
开发者ID:mantidproject,项目名称:mantid,代码行数:48,代码来源:DirectILLDiagnosticsTest.py


示例18: testOutputHasCommonBinningWithInput

 def testOutputHasCommonBinningWithInput(self):
     self._setDefaultSample(self._TEST_WS_NAME)
     outWSName = 'correctionWS'
     kwargs = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'rethrow': True
     }
     run_algorithm('DirectILLSelfShielding', **kwargs)
     self.assertTrue(mtd.doesExist(outWSName))
     inWS = mtd[self._TEST_WS_NAME]
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), inWS.getNumberHistograms())
     xs = outWS.extractX()
     originalXs = inWS.extractX()
     numpy.testing.assert_almost_equal(xs, originalXs[:, :])
开发者ID:DanNixon,项目名称:mantid,代码行数:16,代码来源:DirectILLSelfShieldingTest.py


示例19: testQRebinning

 def testQRebinning(self):
     outWSName = 'outWS'
     Q0 = 2.3
     dQ = 0.1
     Q1 = 2.7
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'QBinningParams': [Q0, dQ, Q1],
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     ws = mtd[outWSName]
     self.assertEqual(ws.getAxis(0).getUnit().unitID(), 'MomentumTransfer')
     xs = ws.readX(0)
     numpy.testing.assert_almost_equal(xs, numpy.arange(Q0, Q1, dQ))
开发者ID:samueljackson92,项目名称:mantid,代码行数:17,代码来源:DirectILLReductionTest.py


示例20: __determineCharacterizations

    def __determineCharacterizations(self, filename, wkspname):
        useCharTable = self.__isCharacterizationsNeeded()
        needToLoadCal = self.__needToLoadCal()

        # something needs to use the workspace and it needs to not already be in memory
        loadFile = (useCharTable or needToLoadCal) and (not mtd.doesExist(wkspname))

        # input workspace is only needed to find a row in the characterizations table
        tempname = None
        if loadFile:
            if useCharTable or needToLoadCal:
                tempname = '__%s_temp' % wkspname
                # set the loader for this file
                try:
                    # MetaDataOnly=True is only supported by LoadEventNexus
                    loader = self.__createLoader(filename, tempname, MetaDataOnly=True)
                    loader.execute()

                    # get the underlying loader name if we used the generic one
                    if self.__loaderName == 'Load':
                        self.__loaderName = loader.getPropertyValue('LoaderName')
                except RuntimeError:
                    # give up and load the whole file - this can be expensive
                    Load(OutputWorkspace=tempname, Filename=filename)
        else:
            tempname = wkspname  # assume it is already loaded

        # some bit of data has been loaded so use it to get the characterizations
        self.__setupCalibration(tempname)

        # put together argument list for determining characterizations
        args = dict(ReductionProperties=self.getProperty('ReductionProperties').valueAsStr)
        for name in PROPS_FOR_PD_CHARACTER:
            prop = self.getProperty(name)
            if not prop.isDefault:
                args[name] = prop.value
        if tempname is not None:
            args['InputWorkspace'] = tempname
        if useCharTable:
            args['Characterizations'] = self.charac

        if useCharTable:
            PDDetermineCharacterizations(**args)

        if loadFile and (useCharTable or needToLoadCal):
            DeleteWorkspace(Workspace=tempname)
开发者ID:mantidproject,项目名称:mantid,代码行数:46,代码来源:AlignAndFocusPowderFromFiles.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mtd.remove函数代码示例发布时间:2022-05-27
下一篇:
Python api.WorkspaceFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap