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


Python table.Column方法代码示例

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


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

示例1: add_detector_to_zeropoints

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def add_detector_to_zeropoints(detector, zeropoint_table):
    """Manually add detector dependence to the zeropoint table for
    NIRCam and NIRISS simualtions. This is being done as a placeholder
    for the future, where we expect zeropoints to be detector-dependent.

    Parameters
    ----------
    detector : str
        Name of detector to add to the table

    zeropoint_table : astropy.table.Table
        Table of filter zeropoint information

    Returns
    -------
    base_table : astropy.table.Table
        Copy of ``zeropoint_table`` with Detector column added
    """
    # Add "Detector" to the list of column names
    base_table = copy.deepcopy(zeropoint_table)
    num_entries = len(zeropoint_table)
    det_column = Column(np.repeat(detector, num_entries), name="Detector")
    base_table.add_column(det_column, index=0)
    return base_table 
开发者ID:spacetelescope,项目名称:mirage,代码行数:26,代码来源:flux_cal.py

示例2: create_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def create_table(self):
        """Create an astropy table containing the catalog
        """
        tab = create_basic_table(self._ra, self._dec, self.magnitudes, self.location_units)

        # Add morphology columns
        for key in self._morphology:
            values = self._morphology[key]
            col = Column(values, name=key)
            tab.add_column(col, index=3)

        # Add magnitude system and position units as metadata
        tab.meta['comments'].append("radius_{}".format(self.radius_units))

        # Make sure there are at least 4 comment lines at the top
        self.table = pad_table_comments(tab) 
开发者ID:spacetelescope,项目名称:mirage,代码行数:18,代码来源:catalog_generator.py

示例3: create_basic_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [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

示例4: query

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def query(self, query):
        """
        query the entire VO table for the given logical argument. Queries are in the form of pandas
        queries: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.query.html

        To obtain a preview of the availble columns, try catalog.variables


        :param query: pandas style query string
        :return:
        """

        assert type(query) == str, "query must be a string"

        query_results = self._vo_dataframe.query(query)

        table = astro_table.Table.from_pandas(query_results)
        name_column = astro_table.Column(name="name", data=query_results.index)
        table.add_column(name_column, index=0)

        out = self.apply_format(table)

        self._last_query_results = query_results

        return out 
开发者ID:threeML,项目名称:threeML,代码行数:27,代码来源:VirtualObservatoryCatalog.py

示例5: test_table_to_coord

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_table_to_coord():
    """
    Checks "end-to-end" use of `Table` with `SkyCoord` - the `Quantity`
    initializer is the intermediary that translate the table columns into
    something coordinates understands.

    (Regression test for #1762 )
    """
    from astropy.table import Table, Column

    t = Table()
    t.add_column(Column(data=[1, 2, 3], name='ra', unit=u.deg))
    t.add_column(Column(data=[4, 5, 6], name='dec', unit=u.deg))

    c = SkyCoord(t['ra'], t['dec'])

    assert allclose(c.ra.to(u.deg), [1, 2, 3] * u.deg)
    assert allclose(c.dec.to(u.deg), [4, 5, 6] * u.deg) 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:test_sky_coord.py

示例6: test_filled_column

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_filled_column(self):
        f = self.a.filled()
        assert np.all(f == [10, 2, 3])
        assert isinstance(f, Column)
        assert not isinstance(f, MaskedColumn)

        # Confirm copy, not ref
        assert f.meta['a'] == 1
        f.meta['a'] = 2
        f[1] = 100
        assert self.a[1] == 2
        assert self.a.meta['a'] == 1

        # Fill with arg fill_value not column fill_value
        f = self.a.filled(20)
        assert np.all(f == [20, 2, 3])

        f = self.b.filled()
        assert np.all(f == [10.0, 5.0, 6.0])
        assert isinstance(f, Column)

        f = self.c.filled()
        assert np.all(f == ['1', '8', '9'])
        assert isinstance(f, Column) 
开发者ID:holzschu,项目名称:Carnets,代码行数:26,代码来源:test_masked.py

示例7: test_add_masked_row_to_non_masked_table_iterable

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_add_masked_row_to_non_masked_table_iterable(self):
        t = Table(masked=False)
        t['a'] = [1]
        t['b'] = [4]
        t['c'] = Time([1], format='cxcsec')

        tm = Time(2, format='cxcsec')
        assert not t.masked
        t.add_row([2, 5, tm])
        assert not t.masked
        t.add_row([3, 6, tm], mask=[0, 1, 1])
        assert not t.masked

        assert type(t['a']) is Column
        assert type(t['b']) is MaskedColumn
        assert type(t['c']) is Time

        assert np.all(t['a'] == [1, 2, 3])
        assert np.all(t['b'].data == [4, 5, 6])
        assert np.all(t['b'].mask == [False, False, True])
        assert np.all(t['c'][:2] == Time([1, 2], format='cxcsec'))
        assert np.all(t['c'].mask == [False, False, True]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:test_masked.py

示例8: test_setting_from_masked_column

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_setting_from_masked_column():
    """Test issue in #2997"""
    mask_b = np.array([True, True, False, False])
    for select in (mask_b, slice(0, 2)):
        t = Table(masked=True)
        t['a'] = Column([1, 2, 3, 4])
        t['b'] = MaskedColumn([11, 22, 33, 44], mask=mask_b)
        t['c'] = MaskedColumn([111, 222, 333, 444], mask=[True, False, True, False])

        t['b'][select] = t['c'][select]
        assert t['b'][1] == t[1]['b']
        assert t['b'][0] is np.ma.masked  # Original state since t['c'][0] is masked
        assert t['b'][1] == 222  # New from t['c'] since t['c'][1] is unmasked
        assert t['b'][2] == 33
        assert t['b'][3] == 44
        assert np.all(t['b'].mask == t.mask['b'])  # Avoid t.mask in general, this is for testing

        mask_before_add = t.mask.copy()
        t['d'] = np.arange(len(t))
        assert np.all(t.mask['b'] == mask_before_add['b']) 
开发者ID:holzschu,项目名称:Carnets,代码行数:22,代码来源:test_masked.py

示例9: test_data_info_subclass

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_data_info_subclass():
    class Column(table.Column):
        """
        Confusingly named Column on purpose, but that is legal.
        """
        pass
    for data in ([], [1, 2]):
        c = Column(data, dtype='int64')
        cinfo = c.info(out=None)
        assert cinfo == OrderedDict([('dtype', 'int64'),
                                     ('shape', ''),
                                     ('unit', ''),
                                     ('format', ''),
                                     ('description', ''),
                                     ('class', 'Column'),
                                     ('n_bad', 0),
                                     ('length', len(data))]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:test_info.py

示例10: table_types

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def table_types(request):
    class TableTypes:
        def __init__(self, request):
            if request.param == 'unmasked':
                self.Table = table.Table
                self.Column = table.Column
            elif request.param == 'masked':
                self.Table = MaskedTable
                self.Column = table.MaskedColumn
            elif request.param == 'subclass':
                self.Table = MyTable
                self.Column = MyColumn
    return TableTypes(request)


# Fixture to run all the Column tests for both an unmasked (ndarray)
# and masked (MaskedArray) column. 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:conftest.py

示例11: test_pickle_masked_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def test_pickle_masked_table(protocol):
    a = Column(data=[1, 2], name='a', format='%05d', description='col a', unit='cm', meta={'a': 1})
    b = Column(data=[3.0, 4.0], name='b', format='%05d', description='col b', unit='cm',
               meta={'b': 1})
    t = Table([a, b], meta={'a': 1}, masked=True)
    t['a'].mask[1] = True
    t['a'].fill_value = -99

    ts = pickle.dumps(t)
    tp = pickle.loads(ts)

    for colname in ('a', 'b'):
        for attr in ('_data', 'mask', 'fill_value'):
            assert np.all(getattr(tp[colname], attr) == getattr(tp[colname], attr))

    assert tp['a'].attrs_equal(t['a'])
    assert tp['b'].attrs_equal(t['b'])
    assert tp.meta == t.meta 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:test_pickle.py

示例12: test_override_name

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

        # Check that we can override the name of the input column in the Table
        t.add_column(self.a, name='b')
        t.add_column(self.b, name='a')
        assert t.columns.keys() == ['b', 'a']
        # Check that we did not change the name of the input column
        assert self.a.info.name == 'a'
        assert self.b.info.name == 'b'

        # Now test with an input column from another table
        t2 = table_types.Table()
        t2.add_column(t['a'], name='c')
        assert t2.columns.keys() == ['c']
        # Check that we did not change the name of the input column
        assert t.columns.keys() == ['b', 'a']

        # Check that we can give a name if none was present
        col = table_types.Column([1, 2, 3])
        t.add_column(col, name='c')
        assert t.columns.keys() == ['b', 'a', 'c'] 
开发者ID:holzschu,项目名称:Carnets,代码行数:25,代码来源:test_table.py

示例13: create_bands_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [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

示例14: create_ebounds_table

# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import Column [as 别名]
def create_ebounds_table(emin, emax):

    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')]
    return Table(cols,meta={'EXTNAME' : 'EBOUNDS'}) 
开发者ID:open-gamma-ray-astro,项目名称:gamma-astro-data-formats,代码行数:8,代码来源:make_wcs_files.py

示例15: create_bands_table

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

    cols = [Column(name='CHANNEL', data=np.arange(len(nside)), dtype='i8'),
            Column(name='NSIDE', data=nside, dtype='i8'),
            Column(name='NPIX', data=npix, dtype='i8'),
            Column(name='E_MIN', data=emin, dtype='f8', unit='keV'),
            Column(name='E_MAX', data=emax, dtype='f8', unit='keV')]
    return Table(cols,meta={'EXTNAME' : 'BANDS', 'AXCOLS1' : 'E_MIN,E_MAX'}) 
开发者ID:open-gamma-ray-astro,项目名称:gamma-astro-data-formats,代码行数:10,代码来源:make_hpx_files.py


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