bin灯光曲线后的Lightkurve nan值

2024-05-16 00:10:01 发布

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

我正在使用Python 3.8.5和astropy 4.2中的lightkurve2.0.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]

Tags: 数量binfoldnan外行星曲线lightlc
1条回答
网友
1楼 · 发布于 2024-05-16 00:10:01

在您的例子中,binning是基于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参数。这意味着,该方法将创建101个宽度为0.5的箱子,从-0.4开始。所以第一个箱子从-0.4到0.1,第二个箱子从0.1到0.6,第三个箱子从0.6到1.1

现在很明显,只有前两个箱子包含数据

使用bins代替n_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

lightkurve2.0.2中没有bins参数,但是在2.0.6中没有(谢谢@Michal)

相关问题 更多 >