本文整理汇总了Python中astropy.table.vstack方法的典型用法代码示例。如果您正苦于以下问题:Python table.vstack方法的具体用法?Python table.vstack怎么用?Python table.vstack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.table
的用法示例。
在下文中一共展示了table.vstack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stitch
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def stitch(self, corrector_func=lambda x:x.normalize()):
""" Stitch all light curves in the collection into a single lk.LightCurve
Any function passed to `corrector_func` will be applied to each light curve
before stitching. For example, passing "lambda x: x.normalize().flatten()"
will normalize and flatten each light curve before stitching.
Parameters
----------
corrector_func : function
Function that accepts and returns a `~lightkurve.lightcurve.LightCurve`.
This function is applied to each light curve in the collection
prior to stitching. The default is to normalize each light curve.
Returns
-------
lc : `~lightkurve.lightcurve.LightCurve`
Stitched light curve.
"""
if corrector_func is None:
corrector_func = lambda x: x
lcs = [corrector_func(lc) for lc in self]
# Need `join_type='inner'` until AstroPy supports masked Quantities
return vstack(lcs, join_type='inner', metadata_conflicts='silent')
示例2: append
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def append(self, others: Iterable[LightCurve], inplace=False) -> LightCurve:
"""Append one or more other `LightCurve` object(s) to this one.
Parameters
----------
others : `LightCurve`, or list of `LightCurve`
Light curve(s) to be appended to the current one.
inplace : bool
If True, change the current `LightCurve` instance in place instead
of creating and returning a new one. Defaults to False.
Returns
-------
new_lc : `LightCurve`
Light curve which has the other light curves appened to it.
"""
if inplace:
raise ValueError("the `inplace` parameter is no longer supported "
"as of Lightkurve v2.0")
if not hasattr(others, '__iter__'):
others = (others,)
# Need `join_type='inner'` until AstroPy supports masked Quantities
return vstack((self, *others), join_type='inner', metadata_conflicts='silent')
示例3: test_stack_incompatible
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stack_incompatible(self, operation_table_type):
self._setup(operation_table_type)
with pytest.raises(TableMergeError) as excinfo:
table.vstack([self.t1, self.t3], join_type='inner')
assert ("The 'b' columns have incompatible types: {}"
.format([self.t1['b'].dtype.name, self.t3['b'].dtype.name])
in str(excinfo.value))
with pytest.raises(TableMergeError) as excinfo:
table.vstack([self.t1, self.t3], join_type='outer')
assert "The 'b' columns have incompatible types:" in str(excinfo.value)
with pytest.raises(TableMergeError):
table.vstack([self.t1, self.t2], join_type='exact')
t1_reshape = self.t1.copy()
t1_reshape['b'].shape = [2, 1]
with pytest.raises(TableMergeError) as excinfo:
table.vstack([self.t1, t1_reshape])
assert "have different shape" in str(excinfo.value)
示例4: test_masking_required_exception
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_masking_required_exception():
"""
Test that outer join, hstack and vstack fail for a mixin column which
does not support masking.
"""
col = [1, 2, 3, 4] * u.m
t1 = table.QTable([[1, 2, 3, 4], col], names=['a', 'b'])
t2 = table.QTable([[1, 2], col[:2]], names=['a', 'c'])
with pytest.raises(NotImplementedError) as err:
table.vstack([t1, t2], join_type='outer')
assert 'vstack requires masking' in str(err.value)
with pytest.raises(NotImplementedError) as err:
table.hstack([t1, t2], join_type='outer')
assert 'hstack requires masking' in str(err.value)
with pytest.raises(NotImplementedError) as err:
table.join(t1, t2, join_type='outer')
assert 'join requires masking' in str(err.value)
示例5: get_data
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def get_data(input_files):
"""read in data from one or more files. In the case that there are multiple files, the data from all files
will be combined into a single CI vs FWHM dataset.
Parameters
----------
input_files : list
list of CI vs. FWHM .csv files to process
Returns
-------
data_table: : numpy.ndarray
A 2 x n sized numpy array. Column 1: CI values; Column 2: FWHM values
"""
data_table = Table()
for filename in input_files:
if filename.endswith(".csv"):
data_table = vstack([data_table,Table.read(filename,format='ascii.csv')])
if filename.endswith(".json"):
json_data = read_json_file(filename)
data_table = vstack([data_table, json_data['data']['CI_FWHM']])
return data_table
# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
示例6: test_stacking
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stacking(self):
ts = vstack([self.series, self.series])
assert isinstance(ts, self.series.__class__)
示例7: test_required_after_stacking
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_required_after_stacking(self):
# When stacking, we have to temporarily relax the checking of the
# columns in the time series, but we need to make sure that the
# checking works again afterwards
ts = vstack([self.series, self.series])
with pytest.raises(ValueError) as exc:
ts.remove_columns(ts.colnames)
assert 'TimeSeries object is invalid' in exc.value.args[0]
示例8: test_stack_rows
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stack_rows(self, operation_table_type):
self._setup(operation_table_type)
t2 = self.t1.copy()
t2.meta.clear()
out = table.vstack([self.t1, t2[1]])
assert type(out['a']) is type(self.t1['a'])
assert type(out['b']) is type(self.t1['b'])
assert out.pformat() == [' a b ',
'--- ---',
'0.0 foo',
'1.0 bar',
'1.0 bar']
示例9: test_stack_table_column
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stack_table_column(self, operation_table_type):
self._setup(operation_table_type)
t2 = self.t1.copy()
t2.meta.clear()
out = table.vstack([self.t1, t2['a']])
assert out.masked is False
assert out.pformat() == [' a b ',
'--- ---',
'0.0 foo',
'1.0 bar',
'0.0 --',
'1.0 --']
示例10: test_table_meta_merge
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_table_meta_merge(self, operation_table_type):
self._setup(operation_table_type)
out = table.vstack([self.t1, self.t2, self.t4], join_type='inner')
assert out.meta == self.meta_merge
示例11: test_bad_input_type
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_bad_input_type(self, operation_table_type):
self._setup(operation_table_type)
with pytest.raises(ValueError):
table.vstack([])
with pytest.raises(TypeError):
table.vstack(1)
with pytest.raises(TypeError):
table.vstack([self.t2, 1])
with pytest.raises(ValueError):
table.vstack([self.t1, self.t2], join_type='invalid join type')
示例12: test_stack_basic_inner
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stack_basic_inner(self, operation_table_type):
self._setup(operation_table_type)
t1 = self.t1
t2 = self.t2
t4 = self.t4
t12 = table.vstack([t1, t2], join_type='inner')
assert t12.masked is False
assert type(t12) is operation_table_type
assert type(t12['a']) is type(t1['a'])
assert type(t12['b']) is type(t1['b'])
assert t12.pformat() == [' a b ',
'--- ---',
'0.0 foo',
'1.0 bar',
'2.0 pez',
'3.0 sez']
t124 = table.vstack([t1, t2, t4], join_type='inner')
assert type(t124) is operation_table_type
assert type(t12['a']) is type(t1['a'])
assert type(t12['b']) is type(t1['b'])
assert t124.pformat() == [' a b ',
'--- ---',
'0.0 foo',
'1.0 bar',
'2.0 pez',
'3.0 sez',
'0.0 foo',
'1.0 bar']
示例13: test_stack_basic_outer
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_stack_basic_outer(self, operation_table_type):
if operation_table_type is QTable:
pytest.xfail('Quantity columns do not support masking.')
self._setup(operation_table_type)
t1 = self.t1
t2 = self.t2
t4 = self.t4
t12 = table.vstack([t1, t2], join_type='outer')
assert t12.masked is False
assert t12.pformat() == [' a b c ',
'--- --- ---',
'0.0 foo --',
'1.0 bar --',
'2.0 pez 4',
'3.0 sez 5']
t124 = table.vstack([t1, t2, t4], join_type='outer')
assert t124.masked is False
assert t124.pformat() == [' a b c ',
'--- --- ---',
'0.0 foo --',
'1.0 bar --',
'2.0 pez 4',
'3.0 sez 5',
'0.0 foo --',
'1.0 bar --']
示例14: test_vstack_one_masked
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_vstack_one_masked(self, operation_table_type):
if operation_table_type is QTable:
pytest.xfail('Quantity columns do not support masking.')
self._setup(operation_table_type)
t1 = self.t1
t4 = self.t4
t4['b'].mask[1] = True
t14 = table.vstack([t1, t4])
assert t14.masked is False
assert t14.pformat() == [' a b ',
'--- ---',
'0.0 foo',
'1.0 bar',
'0.0 foo',
'1.0 --']
示例15: test_vstack_one_table
# 需要导入模块: from astropy import table [as 别名]
# 或者: from astropy.table import vstack [as 别名]
def test_vstack_one_table(self, operation_table_type):
self._setup(operation_table_type)
"""Regression test for issue #3313"""
assert (self.t1 == table.vstack(self.t1)).all()
assert (self.t1 == table.vstack([self.t1])).all()