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


Python table.Table方法代码示例

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


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

示例1: setup

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def setup(self):
        """ setup function, called before `start()` """

        if self.infile == "":
            raise ToolConfigurationError("No 'infile' parameter was specified. ")

        self.events = Table(
            names=["EVENT_ID", "T_REL", "DELTA_T", "N_TRIG", "TRIGGERED_TELS"],
            dtype=[np.int64, np.float64, np.float64, np.int32, np.uint8],
        )

        self.events["TRIGGERED_TELS"].shape = (0, MAX_TELS)
        self.events["T_REL"].unit = u.s
        self.events["T_REL"].description = "Time relative to first event"
        self.events["DELTA_T"].unit = u.s
        self.events.meta["INPUT"] = self.infile

        self._current_trigpattern = np.zeros(MAX_TELS)
        self._current_starttime = None
        self._prev_time = None 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:22,代码来源:dump_triggers.py

示例2: bench_report

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def bench_report(results):
    """Print a report for given benchmark results to the console."""

    table = Table(names=['function', 'nest', 'nside', 'size',
                         'time_healpy', 'time_self', 'ratio'],
                  dtype=['S20', bool, int, int, float, float, float], masked=True)
    for row in results:
        table.add_row(row)

    table['time_self'].format = '10.7f'

    if HEALPY_INSTALLED:
        table['ratio'] = table['time_self'] / table['time_healpy']
        table['time_healpy'].format = '10.7f'
        table['ratio'].format = '7.2f'

    table.pprint(max_lines=-1) 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:19,代码来源:bench.py

示例3: __call__

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def __call__(self, *args, **kwargs):
        """
        creates an astropy table of the cut names, counted events and
        selection efficiencies
        prints the instance name and the astropy table

        Parameters
        ----------
        kwargs : keyword arguments
            arguments to be passed to the `get_table` function; see there

        Returns
        -------
        t : `astropy.table.Table`
            the table containing the cut names, counted events and
            efficiencies -- sorted in the order the cuts were added if not
            specified otherwise
        """
        print(self.name)
        t = self.get_table(*args, **kwargs)
        print(t)
        return t 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:24,代码来源:CutFlow.py

示例4: test_transform_johnson_to_jwst

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def test_transform_johnson_to_jwst():
    jcat = Table()
    jcat['V'] = [10, 10, 10, 10]
    jcat['J'] = [10, 11, 12, 13]
    jcat['H'] = [10, 12, 14, 16]
    jcat['K'] = [10, 13, 16, 19]
    jcat['Av'] = [0.05, 0.05, 0.05, 0.05]

    filters = ['nircam_f090w_clear_magnitude', 'niriss_f090w_magnitude', 'fgs_guider1_magnitude']
    transform = create_catalog.transform_johnson_to_jwst(jcat, filters)

    truth = copy.deepcopy(jcat)
    truth['nircam_f090w_clear_magnitude'] = [10.015026, 11.381326, 12.881326, 14.381326]
    truth['niriss_f090w_magnitude'] = [10.016299, 11.379, 12.879, 14.379]

    assert jcat.colnames == truth.colnames
    assert np.allclose(jcat['nircam_f090w_clear_magnitude'], truth['nircam_f090w_clear_magnitude'])
    assert np.allclose(jcat['niriss_f090w_magnitude'], truth['niriss_f090w_magnitude']) 
开发者ID:spacetelescope,项目名称:mirage,代码行数:20,代码来源:test_catalog_generation.py

示例5: get_2MASS_ptsrc_catalog

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def get_2MASS_ptsrc_catalog(ra, dec, box_width):
    """Wrapper around 2MASS query and creation of mirage-formatted catalog

    Parameters
    ----------
    ra : float or str
        Right ascention of the center of the catalog. Can be decimal degrees or HMS string

    dec : float or str
        Declination of the center of the catalog. Can be decimal degrees of DMS string

    box_width : float
        Width of the box in arcseconds containing the catalog.

    Returns
    -------
    twomass : tup
        2-element tuple. The first is a PointSourceCatalog object containing
        the 2MASS source information. The second is an astropy.table.Table
        object containing the exact query results from 2MASS. Note that these
        outputs will contain only JHK magnitudes for the returned sources.
    """
    twomass_cat, twomass_mag_cols = query_2MASS_ptsrc_catalog(ra, dec, box_width)
    twomass_mirage = mirage_ptsrc_catalog_from_table(twomass_cat, '2MASS', twomass_mag_cols)
    return twomass_mirage, twomass_cat 
开发者ID:spacetelescope,项目名称:mirage,代码行数:27,代码来源:create_catalog.py

示例6: filter_bad_ra_dec

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def filter_bad_ra_dec(table_data):
    """Remove targets with bad RA and/or Dec values from the input table.
    Use the column masks to find which entries have bad RA or Dec values.
    These will be excluded from the Mirage catalog.

    Parameters
    ----------
    table_data : astropy.table.Table
        Input table from e.g. 2MASS query

    Returns
    -------
    position_mask : np.ndarray
        1D boolean array. True for good sources, False for bad.
    """
    ra_mask = ~table_data['ra'].data.mask
    dec_mask = ~table_data['dec'].data.mask
    position_mask = ra_mask & dec_mask
    return position_mask 
开发者ID:spacetelescope,项目名称:mirage,代码行数:21,代码来源:create_catalog.py

示例7: create_basic_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def create_basic_table(ra_values, dec_values, magnitudes, location_units, minimum_index=1):
    """Create astropy table containing the basic catalog info
    NOTE THAT THIS IS OUTSIDE CLASSES
    """
    basic_table = Table()

    # Add index, filename, RA, Dec or x, y columns
    index_col = Column(np.arange(minimum_index, minimum_index + len(ra_values)), name='index')
    ra_col = Column(ra_values, name='x_or_RA')
    dec_col = Column(dec_values, name='y_or_Dec')
    basic_table.add_columns([index_col, ra_col, dec_col])

    # Add magnitude columns
    for key in magnitudes:
        mag_values = magnitudes[key][1]
        mag_sys = magnitudes[key][0]
        mag_column = Column(mag_values, name=key)
        basic_table.add_column(mag_column)

    # Add magnitude system and position units as metadata
    basic_table.meta['comments'] = [location_units, mag_sys]
    return basic_table 
开发者ID:spacetelescope,项目名称:mirage,代码行数:24,代码来源:catalog_generator.py

示例8: jsonTable

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def jsonTable(jsonObj):
    """Converts JSON return type object into an astropy Table.

    Parameters
    ----------
    jsonObj :
        Output data from `mastQuery`.

    Returns
    ----------
    dataTable : astropy.table.Table
    """
    dataTable = Table()
    for col,atype in [(x['name'],x['type']) for x in jsonObj['fields']]:
        if atype=='string':
            atype='str'
        if atype=='boolean':
            atype='bool'
        if atype=='int':
            atype='float'
        dataTable[col] = np.array([x.get(col,None) for x in jsonObj['data']],dtype=atype)
    return dataTable 
开发者ID:afeinstein20,项目名称:eleanor,代码行数:24,代码来源:mast.py

示例9: cone_search

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def cone_search(pos, r, service):
    """Completes a cone search in the Gaia DR2 or TIC catalog.

    Parameters
    ----------
    r : float
        Radius of cone search [deg]
    service : str
        MAST service to use. Either 'Mast.Catalogs.GaiaDR2.Cone'
        or 'Mast.Catalogs.Tic.Cone' are acceptable inputs.

    Returns
    ----------
    table : astropy.table.Table
        Sources found within cone of radius r.
        See the Gaia & TIC field documentation for more information
        on returned columns.
    """
    request = {'service': service,
               'params': {'ra':pos[0], 'dec':pos[1], 'radius':r},
               'format':'json', 'removecache':True}
    headers, outString = mastQuery(request)
    return jsonTable(json.loads(outString)) 
开发者ID:afeinstein20,项目名称:eleanor,代码行数:25,代码来源:mast.py

示例10: __init__

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def __init__(self, *args, **kwargs):
        self.name = args[0]

        try:
            self.comment = IdiComment(kwargs.pop("comment"))
        except KeyError:
            self.comment = None
        try:
            self.history = IdiHistory(kwargs.pop("history"))
        except KeyError:
            self.history = None
        try:
            self.header = IdiHeader(kwargs.pop("header"))
        except KeyError:
            self.header = IdiHeader()
        super(IdiTableHdu, self).__init__(*args[1:], **kwargs)

        # # Add self.data item, which is missing in Table()
        # self.data = None 
开发者ID:telegraphic,项目名称:fits2hdf,代码行数:21,代码来源:idi.py

示例11: add_table_hdu

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def add_table_hdu(self, name, header=None, data=None, history=None, comment=None):
        """
        Add a Table HDU to HDU list

        Parameters
        ----------
        name: str
            Name for table HDU
        header=None: dict
            Header keyword:value pairs dictionary. optional
        data=None: IdiTableHdu
            IdiTableHdu that contains the data
        history=None: list
            list of history data
        comment=None: list
            list of comments
        """
        self[name] = IdiTableHdu(name, header=header, data=data,
                              history=history, comment=comment) 
开发者ID:telegraphic,项目名称:fits2hdf,代码行数:21,代码来源:idi.py

示例12: test_regression_6446

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def test_regression_6446():
    # this succeeds even before 6446:
    sc1 = SkyCoord([1, 2], [3, 4], unit='deg')
    t1 = Table([sc1])
    sio1 = io.StringIO()
    t1.write(sio1, format='ascii.ecsv')

    # but this fails due to the 6446 bug
    c1 = SkyCoord(1, 3, unit='deg')
    c2 = SkyCoord(2, 4, unit='deg')
    sc2 = SkyCoord([c1, c2])
    t2 = Table([sc2])
    sio2 = io.StringIO()
    t2.write(sio2, format='ascii.ecsv')

    assert sio1.getvalue() == sio2.getvalue() 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_regression.py

示例13: test_conversion_qtable_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def test_conversion_qtable_table():
    """
    Test that a table round trips from QTable => Table => QTable
    """
    qt = QTable(MIXIN_COLS)
    names = qt.colnames
    for name in names:
        qt[name].info.description = name

    t = Table(qt)
    for name in names:
        assert t[name].info.description == name
        if name == 'quantity':
            assert np.all(t['quantity'] == qt['quantity'].value)
            assert np.all(t['quantity'].unit is qt['quantity'].unit)
            assert isinstance(t['quantity'], t.ColumnClass)
        else:
            assert_table_name_col_equal(t, name, qt[name])

    qt2 = QTable(qt)
    for name in names:
        assert qt2[name].info.description == name
        assert_table_name_col_equal(qt2, name, qt[name]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:25,代码来源:test_mixin.py

示例14: test_convert_numpy_array

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def test_convert_numpy_array(self, table_types):
        self._setup(table_types)
        d = self.t[1]

        np_data = np.array(d)
        if table_types.Table is not MaskedTable:
            assert np.all(np_data == d.as_void())
        assert np_data is not d.as_void()
        assert d.colnames == list(np_data.dtype.names)

        np_data = np.array(d, copy=False)
        if table_types.Table is not MaskedTable:
            assert np.all(np_data == d.as_void())
        assert np_data is not d.as_void()
        assert d.colnames == list(np_data.dtype.names)

        with pytest.raises(ValueError):
            np_data = np.array(d, dtype=[('c', 'i8'), ('d', 'i8')]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:test_row.py

示例15: create_bands_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Table [as 别名]
def create_bands_table(emin, emax, npix=None, cdelt=None, crpix=None):

    cols = [Column(name='CHANNEL', data=np.arange(len(emin)), dtype='i8'),            
            Column(name='E_MIN', data=emin, dtype='f8', unit='keV'),
            Column(name='E_MAX', data=emax, dtype='f8', unit='keV')]
    if npix is not None:
        cols += [Column(name='NPIX', data=npix, dtype='i8'),
                 Column(name='CDELT', data=cdelt, dtype='f8'),
                 Column(name='CRPIX', data=crpix, dtype='f8'),]
            
    return Table(cols,meta={'EXTNAME' : 'BANDS', 'AXCOLS1' : 'E_MIN,E_MAX'}) 
开发者ID:open-gamma-ray-astro,项目名称:gamma-astro-data-formats,代码行数:13,代码来源:make_wcs_files.py


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