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


Python XSpectrum1D.from_file方法代码示例

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


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

示例1: test_get_local_s2n

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
def test_get_local_s2n():
    spec = XSpectrum1D.from_file(data_path('UM184_nF.fits'))
    wv0 = 4000 * u.AA
    s2n, sig_s2n = spec.get_local_s2n(wv0, 20, flux_th=0.9)
    np.testing.assert_allclose(s2n, 9.30119800567627, rtol=1e-5)
    np.testing.assert_allclose(sig_s2n, 1.0349911451339722, rtol=1e-5)
    # test with continuum
    spec.co = np.ones_like(spec.flux)
    s2n, sig_s2n = spec.get_local_s2n(wv0, 20, flux_th=0.9)
    np.testing.assert_allclose(s2n, 10.330545425415039, rtol=1e-5)
    np.testing.assert_allclose(sig_s2n, 0.4250050187110901, rtol=1e-5)
    # test errors
    # out of range
    with pytest.raises(IOError):
        spec.get_local_s2n(1215*u.AA, 20)
    # sig not defined
    spec = XSpectrum1D.from_tuple((spec.wavelength, spec.flux))
    with pytest.raises(ValueError):
        spec.get_local_s2n(wv0, 20)
    # bad shape for flux_th
    with pytest.raises(ValueError):
        spec.get_local_s2n(wv0, 20, flux_th=np.array([1,2,3,4,5]))
    # npix too big
    with pytest.raises(ValueError):
        spec.get_local_s2n(wv0, 1 + len(spec.wavelength))
开发者ID:lwymarie,项目名称:linetools,代码行数:27,代码来源:test_xspec_methods.py

示例2: test_from_file

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
def test_from_file():
    spec = XSpectrum1D.from_file(data_path('UM184_nF.fits'))
    idl = ascii.read(data_path('UM184.dat.gz'), names=['wave', 'flux', 'sig'])

    np.testing.assert_allclose(spec.dispersion.value, idl['wave'])
    np.testing.assert_allclose(spec.sig, idl['sig'], atol=2e-3, rtol=0)

    assert spec.dispersion.unit == u.Unit('AA')
开发者ID:MSeifert04,项目名称:linetools,代码行数:10,代码来源:test_xspec_init.py

示例3: load_spec

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
 def load_spec(self):
     '''Input the Spectrum
     '''
     from linetools.spectra.xspectrum1d import XSpectrum1D
     if self._specfil is None:
         self.get_specfil()
     #
     if self.verbose:
         print('SdssQso: Loading spectrum from {:s}'.format(self._specfil))
     self.spec = XSpectrum1D.from_file(self._specfil)
开发者ID:banados,项目名称:xastropy,代码行数:12,代码来源:qso.py

示例4: test_addmask

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
def test_addmask():
    spec = XSpectrum1D.from_file(data_path('UM184_nF.fits'))
    assert not spec.data['flux'][0].mask[100]
    mask = spec.data['flux'][0].mask.copy()
    mask[100:110] = True
    spec.add_to_mask(mask)
    assert spec.data['flux'][0].mask[100]
    # Compressed
    badp = spec.flux < 0.1
    spec.add_to_mask(badp, compressed=True)
    assert np.sum(spec.data['flux'][0].mask) > 3000
开发者ID:lwymarie,项目名称:linetools,代码行数:13,代码来源:test_xspec_methods.py

示例5: test_unmask

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
def test_unmask():
    spec = XSpectrum1D.from_file(data_path('UM184_nF.fits'))
    assert np.sum(spec.data['wave'].mask) > 0
    spec.unmask()
    assert np.sum(spec.data['wave'].mask) == 0
开发者ID:lwymarie,项目名称:linetools,代码行数:7,代码来源:test_xspec_methods.py

示例6: test_co_kludges

# 需要导入模块: from linetools.spectra.xspectrum1d import XSpectrum1D [as 别名]
# 或者: from linetools.spectra.xspectrum1d.XSpectrum1D import from_file [as 别名]
def test_co_kludges():
    spec = XSpectrum1D.from_file(data_path('SDSSJ220248.31+123656.3.fits'), masking='edges')
    assert spec.co.size == 4599
开发者ID:linetools,项目名称:linetools,代码行数:5,代码来源:test_xspec_init.py


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