construction_data_containers.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def _initialize_projected_units(self, fields, chunk):
        for field in self.data_source._determine_fields(fields):
            finfo = self.ds._get_field_info(*field)
            if finfo.units is None:
                # First time calling a units="auto" field, infer units and cache
                # for future field accesses.
                finfo.units = str(chunk[field].units)
            field_unit = Unit(finfo.units, registry=self.ds.unit_registry)
            if self.method == "mip" or self._sum_only:
                path_length_unit = Unit(registry=self.ds.unit_registry)
            else:
                ax_name = self.ds.coordinates.axis_name[self.axis]
                path_element_name = ("index", "path_element_%s" % (ax_name))
                path_length_unit = self.ds.field_info[path_element_name].units
                path_length_unit = Unit(path_length_unit,
                                        registry=self.ds.unit_registry)
                # Only convert to appropriate unit system for path
                # elements that aren't angles
                if not path_length_unit.is_dimensionless:
                    path_length_unit = path_length_unit.get_base_equivalent(
                        unit_system=self.ds.unit_system)
            if self.weight_field is None:
                self._projected_units[field] = field_unit*path_length_unit
            else:
                self._projected_units[field] = field_unit
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号