當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。