bin 光照曲线后的 Lightkurve nan 值
Lightkurve nan values after bin light curve
我正在使用 lightkurve 2.0.2 库与 Python 3.8.5 和 astropy 4.2 来处理系外行星凌日。但是,当我想将光曲线分类为固定数量的点时,light_curve.flux
中除前两个之外的所有值都是 nan。我做错了什么?
import lightkurve as lk
tp = lk.search_targetpixelfile("Kepler-10", mission="Kepler", exptime="long", quarter=1).download()
lc = tp.to_lightcurve().flatten().remove_outliers()
fold = lc.fold(0.837)
bin = fold.bin(n_bins=101)
print(bin.flux) # [0.99999749 0.99999977 nan nan nan nan nan nan nan ... nan nan nan nan]
在您的例子中,分箱是根据 fold
变量的时间数据完成的。我们来看看数据:
print(fold)
# => time flux ...
# electron / s ...
# -------------------- ------------------ ...
# -0.41839904743025785 0.9999366372082438 ...
# -0.41790346068516393 0.9999900469016064 ...
# -0.41710349403700253 1.000098604170269 ...
# ... ... ...
# 0.41749621545238175 1.0000351718333538 ...
# 0.4178061659377394 1.0000272820282354 ...
# 0.41829640771343823 1.0000199004079346 ...
这意味着我们有大约 -0.4 天到 0.4 天的数据。
然后使用 bin = fold.bin(n_bins=101)
完成装箱。关于 bin
方法参数的文档(截断):
time_bin_size : `~astropy.units.Quantity`, float
The time interval for the binned time series.
(Default: 0.5 days; default unit: days.)
time_bin_start : `~astropy.time.Time`, optional
The start time for the binned time series. Defaults to the first
time in the sampled time series.
n_bins : int, optional
The number of bins to use. Defaults to the number needed to fit all
the original points. Note that this will create this number of bins
of length ``time_bin_size`` independent of the lightkurve length.
您只传递了n_bins
参数。这意味着,该方法将从 -0.4 开始创建 101 个宽度为 0.5 的 bin。所以第一个 bin 从 -0.4 到 0.1,第二个从 0.1 到 0.6,第三个从 0.6 到 1.1,...
现在很明显只有前两个 bin 包含数据。
而不是 n_bins
,使用 bins
:
bins : int
The number of bins to divide the lightkurve into. In contrast to
``n_bins`` this sets the length of ``time_bin_size`` accordingly.
这是结果:
bin = fold.bin(bins=101)
print(bin.flux)
# => [1.0000268 1.00003322 1.00001914 1.00001018 1.00000905 1.00002073
# 0.99999502 1.00000155 1.0000071 0.99999901 1.000028 0.99998768
# 0.99998992 1.00003623 1.00001132 1.00005118 0.99998819 1.00001886
# ...
# 1.00001082 1.00004898 1.0000009 1.00001234 1.00000681] electron / s
bins
参数在 lightkurve 2.0.2 中不可用,但在 2.0.6 中可用(感谢@Michal)。
我正在使用 lightkurve 2.0.2 库与 Python 3.8.5 和 astropy 4.2 来处理系外行星凌日。但是,当我想将光曲线分类为固定数量的点时,light_curve.flux
中除前两个之外的所有值都是 nan。我做错了什么?
import lightkurve as lk
tp = lk.search_targetpixelfile("Kepler-10", mission="Kepler", exptime="long", quarter=1).download()
lc = tp.to_lightcurve().flatten().remove_outliers()
fold = lc.fold(0.837)
bin = fold.bin(n_bins=101)
print(bin.flux) # [0.99999749 0.99999977 nan nan nan nan nan nan nan ... nan nan nan nan]
在您的例子中,分箱是根据 fold
变量的时间数据完成的。我们来看看数据:
print(fold)
# => time flux ...
# electron / s ...
# -------------------- ------------------ ...
# -0.41839904743025785 0.9999366372082438 ...
# -0.41790346068516393 0.9999900469016064 ...
# -0.41710349403700253 1.000098604170269 ...
# ... ... ...
# 0.41749621545238175 1.0000351718333538 ...
# 0.4178061659377394 1.0000272820282354 ...
# 0.41829640771343823 1.0000199004079346 ...
这意味着我们有大约 -0.4 天到 0.4 天的数据。
然后使用 bin = fold.bin(n_bins=101)
完成装箱。关于 bin
方法参数的文档(截断):
time_bin_size : `~astropy.units.Quantity`, float The time interval for the binned time series. (Default: 0.5 days; default unit: days.) time_bin_start : `~astropy.time.Time`, optional The start time for the binned time series. Defaults to the first time in the sampled time series. n_bins : int, optional The number of bins to use. Defaults to the number needed to fit all the original points. Note that this will create this number of bins of length ``time_bin_size`` independent of the lightkurve length.
您只传递了n_bins
参数。这意味着,该方法将从 -0.4 开始创建 101 个宽度为 0.5 的 bin。所以第一个 bin 从 -0.4 到 0.1,第二个从 0.1 到 0.6,第三个从 0.6 到 1.1,...
现在很明显只有前两个 bin 包含数据。
而不是 n_bins
,使用 bins
:
bins : int The number of bins to divide the lightkurve into. In contrast to ``n_bins`` this sets the length of ``time_bin_size`` accordingly.
这是结果:
bin = fold.bin(bins=101)
print(bin.flux)
# => [1.0000268 1.00003322 1.00001914 1.00001018 1.00000905 1.00002073
# 0.99999502 1.00000155 1.0000071 0.99999901 1.000028 0.99998768
# 0.99998992 1.00003623 1.00001132 1.00005118 0.99998819 1.00001886
# ...
# 1.00001082 1.00004898 1.0000009 1.00001234 1.00000681] electron / s
bins
参数在 lightkurve 2.0.2 中不可用,但在 2.0.6 中可用(感谢@Michal)。