本文整理汇总了Python中astropy.units.Quantity.sum方法的典型用法代码示例。如果您正苦于以下问题:Python Quantity.sum方法的具体用法?Python Quantity.sum怎么用?Python Quantity.sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.units.Quantity
的用法示例。
在下文中一共展示了Quantity.sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reproject_cube
# 需要导入模块: from astropy.units import Quantity [as 别名]
# 或者: from astropy.units.Quantity import sum [as 别名]
def test_reproject_cube():
# TODO: a better test can probably be implemented here to avoid
# repeating code
filenames = FermiGalacticCenter.filenames()
spectral_cube = SpectralCube.read(filenames['diffuse_model'])
exposure_cube = SpectralCube.read(filenames['exposure_cube'])
original_cube = Quantity(np.nan_to_num(spectral_cube.data.value),
spectral_cube.data.unit)
spectral_cube = spectral_cube.reproject_to(exposure_cube)
reprojected_cube = Quantity(np.nan_to_num(spectral_cube.data.value),
spectral_cube.data.unit)
# 0.5 degrees per pixel in diffuse model
# 2 degrees in reprojection reference
# sum of reprojected should be 1/16 of sum of original if flux-preserving
expected = 0.0625 * original_cube.sum()
actual = reprojected_cube.sum()
assert_quantity_allclose(actual, expected, rtol=1e-2)