当前位置: 首页>>代码示例>>Python>>正文


Python Angle.reshape方法代码示例

本文整理汇总了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)
开发者ID:JouvinLea,项目名称:gammapy,代码行数:77,代码来源:cube_background.py


注:本文中的astropy.coordinates.Angle.reshape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。