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


Python QTable.meta["keywords"]方法代码示例

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


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

示例1: build_data_table

# 需要导入模块: from astropy.table import QTable [as 别名]
# 或者: from astropy.table.QTable import meta["keywords"] [as 别名]
def build_data_table(
    energy,
    flux,
    flux_error=None,
    flux_error_lo=None,
    flux_error_hi=None,
    energy_width=None,
    energy_lo=None,
    energy_hi=None,
    ul=None,
    cl=None,
):
    """
    Read data into data dict.

    Parameters
    ----------

    energy : :class:`~astropy.units.Quantity` array instance
        Observed photon energy array [physical type ``energy``]

    flux : :class:`~astropy.units.Quantity` array instance
        Observed flux array [physical type ``flux`` or ``differential flux``]

    flux_error, flux_error_hi, flux_error_lo : :class:`~astropy.units.Quantity` array instance
        68% CL gaussian uncertainty of the flux [physical type ``flux`` or
        ``differential flux``]. Either ``flux_error`` (symmetrical uncertainty)
        or ``flux_error_hi`` and ``flux_error_lo`` (asymmetrical uncertainties)
        must be provided.

    energy_width, energy_lo, energy_hi : :class:`~astropy.units.Quantity` array instance, optional
        Width of the energy bins [physical type ``energy``]. Either
        ``energy_width`` (bin width) or ``energy_lo`` and ``energy_hi``
        (Energies of the lower and upper bin edges) can be provided. If none
        are provided, ``generate_energy_edges`` will be used.

    ul : boolean or int array, optional
        Boolean array indicating which of the flux values given in ``flux``
        correspond to upper limits.

    cl : float, optional
        Confidence level of the flux upper limits given by ``ul``.

    Returns
    -------
    data : :class:`astropy.table.QTable`
        Data stored in an astropy Table.
    """
    table = QTable()

    if cl is not None:
        cl = validate_scalar("cl", cl)
        table.meta["keywords"] = {"cl": {"value": cl}}

    table["energy"] = energy

    if energy_width is not None:
        table["energy_width"] = energy_width
    elif energy_lo is not None and energy_hi is not None:
        table["energy_lo"] = energy_lo
        table["energy_hi"] = energy_hi

    table["flux"] = flux

    if flux_error is not None:
        table["flux_error"] = flux_error
    elif flux_error_lo is not None and flux_error_hi is not None:
        table["flux_error_lo"] = flux_error_lo
        table["flux_error_hi"] = flux_error_hi
    else:
        raise TypeError("Flux error not provided!")

    if ul is not None:
        ul = np.array(ul, dtype=np.int)
        table["ul"] = ul

    table.meta["comments"] = ["Table generated with naima.build_data_table"]

    # test table units, format, etc
    validate_data_table(table)

    return table
开发者ID:zblz,项目名称:naima,代码行数:84,代码来源:utils.py


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