skifile.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def get_quantity(self, element, name, default_unit=None):

        # Import Astropy here to avoid import errors for this module for users without an Astropy installation
        from astropy.units import Unit

        prop = element.get(name)
        if prop.startswith("[") and prop.endswith("]"): prop = prop[1:-1].split(":")[1]

        splitted = prop.split()
        value = float(splitted[0])
        try: unit = splitted[1]
        except IndexError: unit = default_unit

        # Create a quantity object
        if unit is not None: value = value * Unit(unit)
        return value

    # -----------------------------------------------------------------

    # Overwrite the default implementation in SkiFile to incorporate labeled properties
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号