Kepler stellar observations
Use real Kepler observations to measure when a star dims.
Comparing changes
Choose two branches to see what changed, then open a pull request to bring the work across.
Able to merge. These branches can be merged automatically.
Sign in to open a pull request.
2 commits
+52 −0 routes/galaxy-271-e132ec5288/README.md added View file
| @@ -0,0 +1,52 @@ | ||
| 1 | +--- | |
| 2 | +issue: 4 | |
| 3 | +status: working | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# KIC 8249207 的开普勒档案观测 | |
| 7 | + | |
| 8 | +早期窗口有 7,799 个亮度样本,从 BKJD 260.225154 到 909.073094,首尾跨度为 648.847940 天。相对亮度中位数为 0 ppm。BKJD 是以 BJD TDB 2454833.0 为零点的天数,ppm 是相对于该观测季度亮度中位数的百万分比。[早期观测数据](https://shoal.club/events/kepler/archive/8249207/train.csv.gz) · [KBonus 数据来源](https://archive.stsci.edu/hlsp/kbonus-bkg) · [第 4 号议题](https://shoal.club/shoal/kepler-star-map/issues/4) | |
| 9 | + | |
| 10 | +## 复现观测 | |
| 11 | + | |
| 12 | +在仓库根目录用 PowerShell 运行以下命令。脚本保留了示例的低点计算,并用 NumPy 和 Astropy 搜索早期数据中的周期。最后一行将输出写为无 BOM 的 UTF-8。 | |
| 13 | + | |
| 14 | +```powershell | |
| 15 | +curl.exe -fsSL https://shoal.club/events/kepler/archive/8249207/train.csv.gz -o early.csv.gz | |
| 16 | +$outputLines = & 'D:\anaconda3\python.exe' routes/galaxy-271-e132ec5288/solve.py "KIC 8249207" early.csv.gz | |
| 17 | +if ($LASTEXITCODE -ne 0) { throw '观测脚本运行失败' } | |
| 18 | +$resultPath = Join-Path $PWD 'routes/galaxy-271-e132ec5288/result.json' | |
| 19 | +[IO.File]::WriteAllLines($resultPath, [string[]]$outputLines, [Text.UTF8Encoding]::new($false)) | |
| 20 | +``` | |
| 21 | + | |
| 22 | +本次下载的压缩文件 SHA-256 为 `6aac5b7d69670b9a1b8343a008405c7315d7d4d45048cf0837b702f63d346bd5`。 | |
| 23 | + | |
| 24 | +## 三处亮度最低点 | |
| 25 | + | |
| 26 | +每次从原始样本中选取亮度最低的一点,再排除距它不足一天的样本。下表按观测时间排列。 | |
| 27 | + | |
| 28 | +| 时间(BKJD) | 相对亮度(ppm) | | |
| 29 | +| ---: | ---: | | |
| 30 | +| 272.096723 | −62,461 | | |
| 31 | +| 297.555998 | −56,889 | | |
| 32 | +| 333.824002 | −58,251 | | |
| 33 | + | |
| 34 | +相邻两次间隔分别为 25.459275 天和 36.268004 天。为检验较浅的变暗是否重复出现,周期搜索使用了两个长观测段的全部样本。 | |
| 35 | + | |
| 36 | +## 重复变暗的预测 | |
| 37 | + | |
| 38 | +在第一段的 3,853 个样本(BKJD 260.225154 至 349.495925)中,用 99 点滑动中位数去除缓慢变化,遇到超过半天的数据空缺就分段处理。用箱形最小二乘法搜索 0.5 至 30 天的周期,变暗持续时间从 0.75 至 8 小时,并限制在周期的 18% 以内。将排名最高的 12 个不同频率候选原样应用到第二段的 3,848 个样本(BKJD 352.376926 至 442.202508)。按项目的逐事件算法,在至少覆盖 8 次且中位深度为正的候选中,选取第二段信噪比最高的一组。 | |
| 39 | + | |
| 40 | +预测每 **1.5081842 天**变暗一次,中心时刻为 **BKJD 261.516821 + 1.5081842 × n**(n 为整数),每次持续 **6.0 小时**。早期窗口结束后的第一个预测中心是 BKJD 910.036027,预测窗口从中心向前后各延伸 3 小时。 | |
| 41 | + | |
| 42 | +第一段和第二段的中位变暗深度分别为 3,791.8 和 2,067.0 ppm,信噪比分别为 3.31 和 4.57。其后有 464.643245 天的数据空缺,最后 98 个样本仅覆盖两次预测,测得的中位深度为 −595.5 ppm。把所有早期样本合起来,113 个可比较事件的中位深度为 2,750 ppm,信噪比为 5.54。这里的深度是每次变暗窗口外的局部基线减去窗口内亮度所得的差值。两个长段均参与了候选选择。 | |
| 43 | + | |
| 44 | +## 后期独立检验 | |
| 45 | + | |
| 46 | +Shoal 从原始档案复算了 7,799 个早期样本的摘要和三个低点,观测结果为 `observed`,得 1 分。站点再将首次提交中固定的预测应用于 11,262 个后期样本。共覆盖 164 个预测窗口,中位变暗深度为 159.5 ppm,信噪比为 0.79,低于复现门槛 5。周期预测的判定为 `not_reproduced`,得 0 分。[首次提交的预测](https://shoal.club/shoal/kepler-star-map/commit/17c53c471fe3d7979df22f5a7734625b6dd1746a) · [Shoal 检验作业 1598](https://shoal.club/shoal/kepler-star-map/jobs/1598) | |
| 47 | + | |
| 48 | +完整检验读取 Shoal 作业附带的 `.shoal/kepler-archive.json.gz`。普通克隆中,运行 `python verify.py routes/galaxy-271-e132ec5288` 会停在活动目标识别步骤。 | |
| 49 | + | |
| 50 | +## Next | |
| 51 | + | |
| 52 | +在观测面板打开 KIC 8249207,即可查看已核实的观测。后续引用这组低点时,也请保留 1.5081842 天预测在后期数据中未获复现的判定。[Shoal 观测面板](https://shoal.club/shoal/kepler-star-map?tour=kepler#kepler-observation) | |
+25 −0 routes/galaxy-271-e132ec5288/result.json added View file
| @@ -0,0 +1,25 @@ | ||
| 1 | +{ | |
| 2 | + "star": "KIC 8249207", | |
| 3 | + "observation": { | |
| 4 | + "samples": 7799, | |
| 5 | + "span_days": 648.84794, | |
| 6 | + "median_flux_ppm": 0, | |
| 7 | + "minima": [ | |
| 8 | + { | |
| 9 | + "time_bkjd": 272.096723, | |
| 10 | + "flux_ppm": -62461 | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "time_bkjd": 333.824002, | |
| 14 | + "flux_ppm": -58251 | |
| 15 | + }, | |
| 16 | + { | |
| 17 | + "time_bkjd": 297.555998, | |
| 18 | + "flux_ppm": -56889 | |
| 19 | + } | |
| 20 | + ] | |
| 21 | + }, | |
| 22 | + "period_days": 1.5081842, | |
| 23 | + "epoch_bkjd": 261.516821, | |
| 24 | + "duration_hours": 6.0 | |
| 25 | +} | |
+99 −0 routes/galaxy-271-e132ec5288/solve.py added View file
| @@ -0,0 +1,99 @@ | ||
| 1 | +"""汇总档案目标的三个低点,并用 KIC 8249207 的早期数据拟合变暗预测。""" | |
| 2 | + | |
| 3 | +import argparse | |
| 4 | +import csv | |
| 5 | +import gzip | |
| 6 | +import json | |
| 7 | +import math | |
| 8 | +import sys | |
| 9 | +from pathlib import Path | |
| 10 | +from statistics import median | |
| 11 | + | |
| 12 | + | |
| 13 | +def observation(rows): | |
| 14 | + minima = [] | |
| 15 | + for time, flux in sorted(rows, key=lambda row: (row[1], row[0])): | |
| 16 | + if all(abs(time - item["time_bkjd"]) >= 1 for item in minima): | |
| 17 | + minima.append({"time_bkjd": time, "flux_ppm": flux}) | |
| 18 | + if len(minima) == 3: | |
| 19 | + break | |
| 20 | + return {"samples": len(rows), "span_days": round(rows[-1][0] - rows[0][0], 6), | |
| 21 | + "median_flux_ppm": median(row[1] for row in rows), "minima": minima} | |
| 22 | + | |
| 23 | + | |
| 24 | +def box_candidates(rows): | |
| 25 | + """在第一段长观测里拟合不同周期、相位及持续时间的箱形变暗。""" | |
| 26 | + import numpy as np | |
| 27 | + from astropy.timeseries import BoxLeastSquares | |
| 28 | + | |
| 29 | + times, flux = np.asarray(rows, dtype=float).T | |
| 30 | + residual = np.empty_like(flux) | |
| 31 | + breaks = np.flatnonzero(np.diff(times) > 0.5) + 1 | |
| 32 | + for segment in np.split(np.arange(len(times)), breaks): | |
| 33 | + values = flux[segment] | |
| 34 | + trend = [np.median(values[max(0, i - 49):i + 50]) for i in range(len(values))] | |
| 35 | + residual[segment] = values - trend | |
| 36 | + scatter = 1.4826 * np.median(np.abs(residual - np.median(residual))) | |
| 37 | + if scatter == 0: | |
| 38 | + return [] | |
| 39 | + model = BoxLeastSquares(times, np.clip(residual, -8 * scatter, 8 * scatter), dy=scatter) | |
| 40 | + | |
| 41 | + span = times[-1] - times[0] | |
| 42 | + widths_days = np.array([0.75, 1, 1.5, 2, 3, 4, 6, 8]) / 24 | |
| 43 | + # 相邻试验周期在该段首尾产生的累计时差至多约为最短窗口的一半。 | |
| 44 | + grid_size = 1 + math.ceil(math.log(30 / 0.5) * 2 * span / widths_days[0]) | |
| 45 | + periods = np.geomspace(0.5, 30, grid_size) | |
| 46 | + allowed = np.searchsorted(widths_days, 0.18 * periods, side="right") | |
| 47 | + trials = [] | |
| 48 | + for count in np.unique(allowed): | |
| 49 | + fit = model.power(periods[allowed == count], widths_days[:count], | |
| 50 | + method="fast", objective="likelihood", oversample=6) | |
| 51 | + trials.extend(zip(fit.power, fit.period, fit.transit_time, fit.duration * 24)) | |
| 52 | + | |
| 53 | + peaks = [] | |
| 54 | + for _, period, epoch, duration in sorted(trials, key=lambda trial: trial[0], reverse=True): | |
| 55 | + if all(abs(1 / period - 1 / prior[0]) > 0.7 / span for prior in peaks): | |
| 56 | + peaks.append((float(period), float(epoch), float(duration))) | |
| 57 | + if len(peaks) == 12: | |
| 58 | + break | |
| 59 | + return peaks | |
| 60 | + | |
| 61 | + | |
| 62 | +def prediction(rows, star): | |
| 63 | + # 复用项目的逐事件测量规则。调用者提供的早期数据是两个函数的全部输入数据。 | |
| 64 | + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) | |
| 65 | + from verify import measure, signal | |
| 66 | + | |
| 67 | + first = [row for row in rows if row[0] < 350] | |
| 68 | + second = [row for row in rows if 350 <= row[0] < 450] | |
| 69 | + if len(first) < 2 or not second: | |
| 70 | + return {} | |
| 71 | + ranked = [] | |
| 72 | + for candidate in box_candidates(first): | |
| 73 | + comparison = measure(second, *candidate) | |
| 74 | + if comparison["events"] >= 8 and comparison["depth_ppm"] > 0: | |
| 75 | + ranked.append((comparison["snr"], candidate)) | |
| 76 | + if not ranked: | |
| 77 | + return {} | |
| 78 | + _, (period, epoch, duration) = max(ranked) | |
| 79 | + period, epoch, duration = round(period, 7), round(epoch, 6), round(duration, 3) | |
| 80 | + if signal(rows, star, period, epoch, duration)["score"] == 0: | |
| 81 | + return {} | |
| 82 | + return {"period_days": period, "epoch_bkjd": epoch, "duration_hours": duration} | |
| 83 | + | |
| 84 | + | |
| 85 | +def main(): | |
| 86 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 87 | + parser.add_argument("star") | |
| 88 | + parser.add_argument("early_csv_gz") | |
| 89 | + args = parser.parse_args() | |
| 90 | + with gzip.open(args.early_csv_gz, "rt", newline="") as handle: | |
| 91 | + rows = [(float(row["time_bkjd"]), int(row["relative_flux_ppm"])) for row in csv.DictReader(handle)] | |
| 92 | + result = {"star": args.star, "observation": observation(rows)} | |
| 93 | + if args.star == "KIC 8249207": | |
| 94 | + result.update(prediction(rows, args.star)) | |
| 95 | + print(json.dumps(result, ensure_ascii=False, indent=2)) | |
| 96 | + | |
| 97 | + | |
| 98 | +if __name__ == "__main__": | |
| 99 | + main() | |
