本文整理汇总了Python中astropy.coordinates.Angle.reshape方法的典型用法代码示例。如果您正苦于以下问题:Python Angle.reshape方法的具体用法?Python Angle.reshape怎么用?Python Angle.reshape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.coordinates.Angle
的用法示例。
在下文中一共展示了Angle.reshape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_bg_observation_list
# 需要导入模块: from astropy.coordinates import Angle [as 别名]
# 或者: from astropy.coordinates.Angle import reshape [as 别名]
def create_bg_observation_list(indir, scheme, outdir, overwrite, test):
"""Make total observation list and filter the observations.
In a first version, all obs taken within 3 deg of a known source
will be rejected. If a source is extended, twice the extension is
added to the corresponding exclusion region radius of 3 deg.
Parameters
----------
indir : str
Input directory (that contains the event lists)
scheme : str
Scheme of file naming.
outdir : str
Dir path to store the results.
overwrite : bool
If true, run fast (not recommended for analysis).
test : bool
If true, run fast: skip many runs and catalog sources.
"""
log.info(' ')
log.info("#######################################")
log.info("# Starting create_bg_observation_list #")
log.info("#######################################")
# get full list of observations
data_store = DataStore(dir=indir, scheme=scheme)
observation_table = data_store.make_observation_table()
# for testing, only process a small subset of observations
if test and len(observation_table) > 100:
observation_table = observation_table.select_linspace_subset(num=100)
log.debug(' ')
log.debug("Full observation table:")
log.debug(observation_table)
# filter observations: load catalog and reject obs too close to sources
# load catalog: TeVCAT (no H.E.S.S. catalog)
catalog = load_catalog_tevcat()
# for testing, only process a small subset of sources
if test:
catalog = catalog[:5]
# sources coordinates
sources_coord = SkyCoord(catalog['coord_ra'], catalog['coord_dec'])
# sources sizes (x, y): radius
sources_size = Angle([catalog['size_x'], catalog['size_y']])
sources_size = sources_size.reshape(len(catalog), 2)
# substitute nan with 0
sources_size[np.isnan(sources_size)] = 0
# sources max size
sources_max_size = np.amax(sources_size, axis=1)
# sources exclusion radius = 2x max size + 3 deg (fov + 0.5 deg?)
sources_excl_radius = 2 * sources_max_size + Angle(3., 'deg')
# mask all obs taken within the excl radius of any of the sources
# loop over sources
obs_coords = SkyCoord(observation_table['RA'], observation_table['DEC'])
for i_source in range(len(catalog)):
selection = dict(type='sky_circle', frame='icrs',
lon=sources_coord[i_source].ra,
lat=sources_coord[i_source].dec,
radius=sources_excl_radius[i_source],
inverted=True,
border=Angle(0., 'deg'))
observation_table = observation_table.select_observations(selection)
# save the bg observation list to a fits file
outfile = Path(outdir) / 'bg_observation_table.fits.gz'
log.info("Writing {}".format(outfile))
observation_table.write(str(outfile), overwrite=overwrite)