本文整理汇总了Python中astropy.nddata.ccddata.CCDData.add方法的典型用法代码示例。如果您正苦于以下问题:Python CCDData.add方法的具体用法?Python CCDData.add怎么用?Python CCDData.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.nddata.ccddata.CCDData
的用法示例。
在下文中一共展示了CCDData.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_arithmetic_add_with_array
# 需要导入模块: from astropy.nddata.ccddata import CCDData [as 别名]
# 或者: from astropy.nddata.ccddata.CCDData import add [as 别名]
def test_arithmetic_add_with_array():
ccd = CCDData(np.ones((3, 3)), unit='')
res = ccd.add(np.arange(3))
np.testing.assert_array_equal(res.data, [[1, 2, 3]] * 3)
ccd = CCDData(np.ones((3, 3)), unit='adu')
with pytest.raises(ValueError):
ccd.add(np.arange(3))
示例2: test_arithmetic_with_wcs_compare_fail
# 需要导入模块: from astropy.nddata.ccddata import CCDData [as 别名]
# 或者: from astropy.nddata.ccddata.CCDData import add [as 别名]
def test_arithmetic_with_wcs_compare_fail():
def return_diff_smaller_1(first, second):
return abs(first - second) <= 1
ccd1 = CCDData(np.ones((10, 10)), unit='', wcs=2)
ccd2 = CCDData(np.ones((10, 10)), unit='', wcs=5)
with pytest.raises(ValueError):
ccd1.add(ccd2, compare_wcs=return_diff_smaller_1).wcs
with pytest.raises(ValueError):
ccd1.subtract(ccd2, compare_wcs=return_diff_smaller_1).wcs
with pytest.raises(ValueError):
ccd1.multiply(ccd2, compare_wcs=return_diff_smaller_1).wcs
with pytest.raises(ValueError):
ccd1.divide(ccd2, compare_wcs=return_diff_smaller_1).wcs
示例3: test_arithmetic_with_wcs_compare
# 需要导入模块: from astropy.nddata.ccddata import CCDData [as 别名]
# 或者: from astropy.nddata.ccddata.CCDData import add [as 别名]
def test_arithmetic_with_wcs_compare():
def return_diff_smaller_3(first, second):
return abs(first - second) <= 3
ccd1 = CCDData(np.ones((10, 10)), unit='', wcs=2)
ccd2 = CCDData(np.ones((10, 10)), unit='', wcs=5)
assert ccd1.add(ccd2, compare_wcs=return_diff_smaller_3).wcs == 2
assert ccd1.subtract(ccd2, compare_wcs=return_diff_smaller_3).wcs == 2
assert ccd1.multiply(ccd2, compare_wcs=return_diff_smaller_3).wcs == 2
assert ccd1.divide(ccd2, compare_wcs=return_diff_smaller_3).wcs == 2
示例4: test_arithmetic_overload_differing_units
# 需要导入模块: from astropy.nddata.ccddata import CCDData [as 别名]
# 或者: from astropy.nddata.ccddata.CCDData import add [as 别名]
def test_arithmetic_overload_differing_units():
a = np.array([1, 2, 3]) * u.m
b = np.array([1, 2, 3]) * u.cm
ccddata = CCDData(a)
# TODO: Could also be parametrized.
res = ccddata.add(b)
np.testing.assert_array_almost_equal(res.data, np.add(a, b).value)
assert res.unit == np.add(a, b).unit
res = ccddata.subtract(b)
np.testing.assert_array_almost_equal(res.data, np.subtract(a, b).value)
assert res.unit == np.subtract(a, b).unit
res = ccddata.multiply(b)
np.testing.assert_array_almost_equal(res.data, np.multiply(a, b).value)
assert res.unit == np.multiply(a, b).unit
res = ccddata.divide(b)
np.testing.assert_array_almost_equal(res.data, np.divide(a, b).value)
assert res.unit == np.divide(a, b).unit
示例5: test_arithmetic_no_wcs_compare
# 需要导入模块: from astropy.nddata.ccddata import CCDData [as 别名]
# 或者: from astropy.nddata.ccddata.CCDData import add [as 别名]
def test_arithmetic_no_wcs_compare():
ccd = CCDData(np.ones((10, 10)), unit='')
assert ccd.add(ccd, compare_wcs=None).wcs is None
assert ccd.subtract(ccd, compare_wcs=None).wcs is None
assert ccd.multiply(ccd, compare_wcs=None).wcs is None
assert ccd.divide(ccd, compare_wcs=None).wcs is None