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


Python mtd.doesExist函数代码示例

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


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


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