本文整理汇总了Python中astropy.units.Quantity.decompose方法的典型用法代码示例。如果您正苦于以下问题:Python Quantity.decompose方法的具体用法?Python Quantity.decompose怎么用?Python Quantity.decompose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.units.Quantity
的用法示例。
在下文中一共展示了Quantity.decompose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_image
# 需要导入模块: from astropy.units import Quantity [as 别名]
# 或者: from astropy.units.Quantity import decompose [as 别名]
def make_image():
table = Table.read('acceptance_curve.fits')
table.pprint()
center = SkyCoord(83.63, 22.01, unit='deg').galactic
counts_image = make_empty_image(nxpix=1000, nypix=1000, binsz=0.01, xref=center.l.deg, yref=center.b.deg,
proj='TAN')
bkg_image = counts_image.copy()
data_store = DataStore.from_dir('$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2')
for events in data_store.load_all("events"):
center = events.pointing_radec.galactic
livetime = events.observation_live_time_duration
solid_angle = Angle(0.01, "deg") ** 2
counts_image.data += bin_events_in_image(events, counts_image).data
#interp_param = dict(bounds_error=False, fill_value=None)
acc_hdu = fill_acceptance_image(bkg_image.header, center, table["offset"], table["Acceptance"])
acc = Quantity(acc_hdu.data, table["Acceptance"].unit) * solid_angle * livetime
bkg_image.data += acc.decompose()
print(acc.decompose().sum())
counts_image.writeto("counts_image.fits", clobber=True)
bkg_image.writeto("bkg_image.fits", clobber=True)
示例2: make_bkg_cube
# 需要导入模块: from astropy.units import Quantity [as 别名]
# 或者: from astropy.units.Quantity import decompose [as 别名]
def make_bkg_cube(self, bkg_norm=True):
"""
Make the background image for one observation from a bkg model.
Parameters
----------
bkg_norm : bool
If true, apply the scaling factor from the number of counts
outside the exclusion region to the bkg image
"""
for i_E in range(len(self.energy_reco) - 1):
energy_band = Energy(
[self.energy_reco[i_E].value, self.energy_reco[i_E + 1].value],
self.energy_reco.unit)
table = self.bkg.acceptance_curve_in_energy_band(
energy_band=energy_band)
center = self.obs_center.galactic
bkg_hdu = fill_acceptance_image(self.header, center,
table["offset"],
table["Acceptance"],
self.offset_band[1])
bkg_image = Quantity(bkg_hdu.data, table[
"Acceptance"].unit) * self.bkg_cube.sky_image_ref.solid_angle() * self.livetime
self.bkg_cube.data[i_E, :, :] = bkg_image.decompose().value
if bkg_norm:
scale = self.background_norm_factor()
self.bkg_cube.data = scale * self.bkg_cube.data
if self.save_bkg_scale:
self.table_bkg_scale.add_row([self.obs_id, scale])