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


Python EDUtilsUnit.getValueLength方法代码示例

本文整理汇总了Python中EDUtilsUnit.EDUtilsUnit.getValueLength方法的典型用法代码示例。如果您正苦于以下问题:Python EDUtilsUnit.getValueLength方法的具体用法?Python EDUtilsUnit.getValueLength怎么用?Python EDUtilsUnit.getValueLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EDUtilsUnit.EDUtilsUnit的用法示例。


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

示例1: unitTestGetValueSILength

# 需要导入模块: from EDUtilsUnit import EDUtilsUnit [as 别名]
# 或者: from EDUtilsUnit.EDUtilsUnit import getValueLength [as 别名]
 def unitTestGetValueSILength(self):
     """
     Test sub method specific to length: GetValueLength
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSILength")
     EDAssert.equal(1.54E-10, EDUtilsUnit.getValueLength(1.54, "A"), "Length Conversion A -> m ")
开发者ID:gbourgh,项目名称:edna,代码行数:8,代码来源:EDTestCaseEDUtilsUnit.py

示例2: readArrayFromFile

# 需要导入模块: from EDUtilsUnit import EDUtilsUnit [as 别名]
# 或者: from EDUtilsUnit.EDUtilsUnit import getValueLength [as 别名]
    def readArrayFromFile(self, _filename):
        """
        Populate self.inputArray for a given filename and extracts as well 
        self.fPixelSize
        self.fDistance
        self.fRadOffset
        self.wavelength ...
        """

        image = openimage(_filename)
        self.inputArray = image.data
        self.dHeader = image.header
        if "Offset_1" in self.dHeader:
            offset, unit = self.dHeader["Offset_1"].split(None, 1)
            if unit.lower() != "pixel":
                EDVerbose.WARNING("I got a strange unit for offset: %s, I expected pixel." % self.dHeader["Offset_1"])
            try:
                self.fRadOffset = float(offset)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize this offset and convert it to float: %s" % self.dHeader["Offset_1"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                raise ValueError, strErrorMessage

        if "Offset_2" in self.dHeader:
            offset, unit = self.dHeader["Offset_2"].split(None, 1)
            if unit.lower() != "pixel":
                EDVerbose.WARNING("I got a strange unit for offset: %s, I expected pixel." % self.dHeader["Offset_2"])
            try:
                self.fAzimOffset = float(offset)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize this offset and convert it to float: %s" % self.dHeader["Offset_2"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                raise ValueError, strErrorMessage

        if "PSize_1" in self.dHeader:
            psize, unit = self.dHeader["PSize_1"].split(None, 1)
            try:
                fPixelSize = float(psize)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize the radial pixel size and convert it to float: %s" % self.dHeader["PSize_1"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
            else:
                self.fPixelSize = EDUtilsUnit.getValueLength(fPixelSize, unit)

        if "PSize_2" in self.dHeader:
            psize, unit = self.dHeader["PSize_2"].split(None, 1)
            try:
                fPixelSize = float(psize)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize the azimuthal pixel size and convert it to float: %s" % self.dHeader["PSize_2"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
            else:
                self.fAzimSize = EDUtilsUnit.getValueAngle(fPixelSize, unit)


        if ("SampleDistance" in self.dHeader):
            distance, unit = self.dHeader["SampleDistance"].split(None, 1)
            try:
                fDistance = float(distance)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize the Sample Distance is and convert it to float: %s" % self.dHeader["SampleDistance"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                raise ValueError, strErrorMessage
            self.fDistance = EDUtilsUnit.getValueLength(fDistance, unit)

        if ("WaveLength" in self.dHeader):
            wavelenth, unit = self.dHeader["WaveLength"].split(None, 1)
            try:
                fWavelength = float(wavelenth)
            except ValueError:
                strErrorMessage = "EDPluginExportAsciiPowderv1_0.process: Unable to recognize the wavelength is and convert it to float: %s" % self.dHeader["WaveLength"]
                EDVerbose.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                raise ValueError, strErrorMessage
            self.fWavelength = EDUtilsUnit.getValueLength(fWavelength, unit)

        if ("Dummy" in self.dHeader):
            self.fDummy = float(self.dHeader.get("Dummy", 0))

        if ("DDummy" in self.dHeader):
            self.fDeltaDummy = float(self.dHeader.get("DDummy", 0.1))
开发者ID:gbourgh,项目名称:edna,代码行数:94,代码来源:EDPluginExportAsciiPowderv1_0.py


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