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


Python QTable.replace_column方法代码示例

本文整理汇总了Python中astropy.table.QTable.replace_column方法的典型用法代码示例。如果您正苦于以下问题:Python QTable.replace_column方法的具体用法?Python QTable.replace_column怎么用?Python QTable.replace_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astropy.table.QTable的用法示例。


在下文中一共展示了QTable.replace_column方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_source_catalog

# 需要导入模块: from astropy.table import QTable [as 别名]
# 或者: from astropy.table.QTable import replace_column [as 别名]

#.........这里部分代码省略.........
        The type of pixel connectivity used in determining how pixels
        are grouped into a detected source.  The options are 4 or 8
        (default).  4-connected pixels touch along their edges.
        8-connected pixels touch along their edges or corners.  For
        reference, SExtractor uses 8-connected pixels.

    deblend : bool, optional
        Whether to deblend overlapping sources.  Source deblending
        requires scikit-image.

    Returns
    -------
    catalog : `~astropy.Table`
        An astropy Table containing the source photometry and
        morphologies.
    """

    if not isinstance(model, DrizProductModel):
        raise ValueError('The input model must be an DrizProductModel.')

    # Remove until model.wht contains an IVM map
    # Calculate "background-only" error assuming the weight image is an
    # inverse-variance map (IVM).  The weight image is clipped because it
    # may contain zeros.
    # bkg_error = np.sqrt(1.0 / np.clip(model.wht, 1.0e-20, 1.0e20))
    # threshold = snr_threshold * bkg_error

    # Estimate the 1-sigma noise in the image empirically because model.wht
    # does not yet contain an IVM map
    mask = (model.wht == 0)
    data_mean, data_median, data_std = sigma_clipped_stats(
        model.data, mask=mask, sigma=3.0, iters=10)
    threshold = data_median + (data_std * snr_threshold)

    sigma = kernel_fwhm * gaussian_fwhm_to_sigma
    kernel = Gaussian2DKernel(sigma, x_size=kernel_xsize, y_size=kernel_ysize)
    kernel.normalize()

    segm = photutils.detect_sources(model.data, threshold, npixels=npixels,
                                    filter_kernel=kernel,
                                    connectivity=connectivity)

    # source deblending requires scikit-image
    if deblend:
        segm = photutils.deblend_sources(model.data, segm, npixels=npixels,
                                         filter_kernel=kernel,
                                         nlevels=deblend_nlevels,
                                         contrast=deblend_contrast,
                                         mode=deblend_mode,
                                         connectivity=connectivity,
                                         relabel=True)

    # Calculate total error, including source Poisson noise.
    # This calculation assumes that the data and bkg_error images are in
    # units of electron/s.  Poisson noise is not included for pixels
    # where data < 0.
    exptime = model.meta.resample.product_exposure_time    # total exptime
    #total_error = np.sqrt(bkg_error**2 + np.maximum(model.data / exptime, 0))
    total_error = np.sqrt(data_std**2 + np.maximum(model.data / exptime, 0))

    wcs = model.get_fits_wcs()
    source_props = photutils.source_properties(
        model.data, segm, error=total_error, filter_kernel=kernel, wcs=wcs)

    columns = ['id', 'xcentroid', 'ycentroid', 'ra_icrs_centroid',
               'dec_icrs_centroid', 'area', 'source_sum',
               'source_sum_err', 'semimajor_axis_sigma',
               'semiminor_axis_sigma', 'orientation']
    catalog = photutils.properties_table(source_props, columns=columns)

    # convert orientation to degrees
    catalog = QTable(catalog)
    orient_deg = catalog['orientation'].to(u.deg)
    catalog.replace_column('orientation', orient_deg)

    # define orientation position angle
    rot = _get_rotation(wcs)
    catalog['orientation_sky'] = ((270. - rot +
                                   catalog['orientation'].value) * u.deg)

    # define AB mag and AB mag error
    pixelarea = model.meta.photometry.pixelarea_arcsecsq
    if pixelarea is None:
        micro_Jy = 0.0
    else:
        micro_Jy = (catalog['source_sum'] *
                    model.meta.photometry.conversion_microjanskys *
                    model.meta.photometry.pixelarea_arcsecsq)
    if micro_Jy > 0.0:
        abmag = -2.5 * np.log10(micro_Jy) + 23.9
    else:
        abmag = 0.
    catalog['abmag'] = abmag

    # assuming SNR >> 1 (otherwise abmag_error is asymmetric):
    catalog['abmag_error'] = (2.5 * np.log10(np.e) *
                              catalog['source_sum_err'] /
                              catalog['source_sum'])

    return catalog
开发者ID:nden,项目名称:jwst,代码行数:104,代码来源:source_catalog.py


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