lightku中使用方块最小二乘法的误差

2024-09-29 23:17:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用那个密码

```
periods = np.linspace(0.5, 20, 10)
durations = np.linspace(0.05, 0.2, 10)

from astropy.stats import BoxLeastSquares
bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
bls.power(periods, durations)
```

但它返回了一个错误

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-d582b87a594f> in <module>()
      2 durations = np.linspace(0.05, 0.2, 10)
      3 
----> 4 from astropy.stats import BoxLeastSquares
      5 bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
      6 bls.power(periods, durations)

ImportError: cannot import name 'BoxLeastSquares'

---------------------------------------------------------------------------

我不知道该如何更正,它发生在lightkurve模块的新更新之前 我使用的是3.0.5版


Tags: fromimporttimestatsnperrpowerbls
1条回答
网友
1楼 · 发布于 2024-09-29 23:17:24

你使用的是什么版本的Astropy?根据these docs

This class has been deprecated and will be removed in a future version. Use astropy.timeseries.BoxLeastSquares instead.

这在最新版本中适用于我:

>>> import astropy
>>> astropy.__version__
'3.2.3'
>>> from astropy.timeseries import BoxLeastSquares

一般来说,如果您在Astropy之类的库中为函数或类获得了一个ImportError,而您认为它应该在那里,这仅仅意味着它不存在,因此您应该通过查看astropy.__version__仔细检查您的版本,并将其与该版本的API文档进行比较,以确保您尝试导入的内容实际存在

相关问题 更多 >

    热门问题