skifile.py 文件源码

python
阅读 24 收藏 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

        splitted = element.get(name).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

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

    ## This function sets the value of a certain parameter of the specified tree element from an Astropy quantity.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号