File size: 16,358 Bytes
ee3406c
a04d0e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770d409
 
 
 
 
 
a04d0e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770d409
 
 
 
 
a04d0e1
 
 
770d409
a04d0e1
770d409
 
a04d0e1
 
 
 
 
 
 
 
770d409
a04d0e1
 
 
 
 
 
 
 
770d409
a04d0e1
770d409
a04d0e1
 
 
 
 
 
 
 
 
 
 
 
 
 
770d409
 
 
 
a04d0e1
 
 
 
770d409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a04d0e1
 
 
 
 
 
 
770d409
a04d0e1
 
 
 
 
770d409
 
a04d0e1
 
 
 
770d409
a04d0e1
 
 
770d409
 
 
 
 
 
 
 
 
 
 
 
 
 
a04d0e1
770d409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a04d0e1
 
ee3406c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NEB chain model · TESS eclipse classifier</title>
<link rel="icon" type="image/png" href="logo-mark.png">
<style>
  @font-face { font-family: 'JetBrains Mono Variable'; src: url(fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2'); font-weight: 100 800; font-display: swap; }
  @font-face { font-family: 'Inter Variable'; src: url(fonts/inter-latin-wght-normal.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
  /* the palette and window of neuralenginebyte.org (neb-web/src/styles.css) */
  :root {
    --bg: #0a0a0a; --panel: #121212; --panel2: #171717; --line: #262626; --line2: #343434;
    --fg: #ffffff; --mid: #bcbcbc; --dim: #808080; --faint: #444444;
    --g: #87ff87; --c: #69d6ff; --r: #ff6b7a;
    --font: 'JetBrains Mono Variable', 'JetBrains Mono', 'Cascadia Mono', ui-monospace, Consolas, monospace;
    --sans: 'Inter Variable', 'Inter', system-ui, 'Segoe UI', sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    min-height: 100dvh;
    background: radial-gradient(900px 520px at 10% -8%, rgba(135, 255, 135, 0.075), transparent 62%),
      radial-gradient(800px 520px at 100% 112%, rgba(105, 214, 255, 0.05), transparent 62%), var(--bg);
    background-attachment: fixed; color: var(--mid); font: 400 14px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  }
  ::selection { background: var(--g); color: #04100a; }
  a { color: var(--c); text-decoration: none; }
  button, input { font: inherit; color: inherit; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

  .stage { min-height: 100dvh; padding: clamp(8px, 2vw, 24px); display: flex; }
  .window { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
    box-shadow: 0 0 0 1px rgba(135, 255, 135, 0.035), 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 120px rgba(135, 255, 135, 0.035); }
  .window::after { content: ''; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px); }
  .titlebar { display: flex; align-items: center; gap: 14px; padding: 0 12px; height: 44px; background: var(--panel2); border-bottom: 1px solid var(--line); }
  .titlebar img { height: 26px; width: 26px; }
  .tab { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; color: var(--fg);
    background: var(--panel); border: 1px solid var(--line2); white-space: nowrap; }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--g); box-shadow: 0 0 8px var(--g); animation: pulse 2.4s ease-in-out infinite; }
  .titlebar .site { margin-left: auto; font-size: 12px; color: var(--dim); }
  .titlebar .site:hover { color: var(--fg); }
  .status { display: flex; gap: 18px; align-items: center; min-height: 28px; padding: 4px 14px; border-top: 1px solid var(--line);
    background: var(--panel2); color: var(--dim); font-size: 11.5px; flex-wrap: wrap; }
  .status .sp { flex: 1; }

  .body { flex: 1; padding: 26px 28px 30px; max-width: 980px; width: 100%; margin: 0 auto; }
  .eyebrow { margin-bottom: 10px; font: 500 10.5px var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: var(--g); }
  h1 { margin-bottom: 10px; font: 600 20px/1.25 var(--sans); letter-spacing: -0.012em; color: var(--fg); }
  .lead { font: 400 13.5px/1.62 var(--sans); max-width: 70ch; }
  .note { margin-top: 8px; font-size: 12px; color: var(--dim); overflow-wrap: anywhere; }
  .star { margin-top: 6px; font-size: 12.5px; color: var(--mid); overflow-wrap: anywhere; }

  .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 22px 0 14px; }
  .btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: var(--mid); font-size: 12.5px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
  .btn:hover { color: var(--fg); border-color: var(--g); }
  .field { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); }
  .field input { width: 90px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line2); background: var(--bg); color: var(--fg); }
  .field input.wide { width: 120px; }
  .sets { display: flex; flex-wrap: wrap; gap: 0; margin-top: 22px; border: 1px solid var(--line2); border-radius: 7px; width: fit-content; max-width: 100%; overflow: hidden; }
  .set { padding: 7px 14px; border: 0; background: var(--panel2); color: var(--dim); font-size: 12.5px; cursor: pointer; }
  .set + .set { border-left: 1px solid var(--line2); }
  .set[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: inset 0 -2px 0 var(--g); }
  .set:hover { color: var(--fg); }

  .views { display: grid; grid-template-columns: 3fr 1fr; gap: 12px; }
  @media (max-width: 640px) { .views { grid-template-columns: 1fr; } .body { padding: 20px 16px; } }
  .pane { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); overflow: hidden; }
  .pane-title { display: flex; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--fg); }
  .pane-title span { margin-left: auto; color: var(--dim); font-size: 11px; }
  svg { display: block; width: 100%; height: 150px; }

  .answer { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
  .answer .big { font-size: 15px; color: var(--fg); }
  .answer b { color: var(--g); font-weight: 600; }
  .ok { color: var(--g); } .no { color: var(--r); }
  .answer .sums { margin-top: 4px; font-size: 12px; color: var(--dim); }

  .score { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
  .score h2 { font: 500 10.5px var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: var(--g); margin-bottom: 10px; }
  .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
  .stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
  .stat .v { font-size: 18px; color: var(--fg); }
  .stat .k { font-size: 11.5px; color: var(--dim); }
  .limits { margin-top: 14px; font: 400 12.5px/1.6 var(--sans); color: var(--dim); max-width: 75ch; }
</style>
</head>
<body>
<div class="stage">
  <div class="window">
    <header class="titlebar">
      <img src="logo-mark.png" alt="NEB">
      <p class="tab"><span class="dot"></span>model · tess</p>
      <a class="site" href="https://neuralenginebyte.org" target="_blank" rel="noopener noreferrer">neuralenginebyte.org ↗</a>
    </header>

    <main class="body">
      <p class="eyebrow">Chain model</p>
      <h1>TESS eclipse classifier</h1>
      <p class="lead">A small convolutional network in 4-bit integers, trained by the miners of the NEB proof-of-work chain:
        each mining attempt is one training step. It reads a folded light curve of a TESS signal and answers
        <b class="ok">eclipse</b> or junk. Everything runs in your browser.</p>
      <p class="note" id="meta">Loading the weights…</p>

      <div class="sets" role="group" aria-label="Signals">
        <button class="set" id="set-test" aria-pressed="true">Test signals · bright stars</button>
        <button class="set" id="set-faint" aria-pressed="false">Known planets · faint stars</button>
      </div>

      <div class="controls">
        <button class="btn" id="eclipse">Random eclipse</button>
        <button class="btn" id="junk">Random junk</button>
        <label class="field">n° <input id="idx" type="number" min="0" value="0"></label>
        <button class="btn" id="go">Show</button>
        <label class="field">TIC <input id="tic" class="wide" type="text" inputmode="numeric" placeholder="star id"></label>
        <button class="btn" id="find">Find</button>
      </div>

      <div class="views">
        <section class="pane"><p class="pane-title">Global view <span>whole folded orbit · 583 bins</span></p>
          <svg id="global" viewBox="0 0 583 100" preserveAspectRatio="none"></svg></section>
        <section class="pane"><p class="pane-title">Local view <span>201 bins</span></p>
          <svg id="local" viewBox="0 0 201 100" preserveAspectRatio="none"></svg></section>
      </div>
      <p class="note" id="views-note"></p>

      <div class="answer">
        <p class="big" id="verdict"></p>
        <p class="star" id="star"></p>
        <p class="sums" id="sums"></p>
      </div>

      <section class="score">
        <h2 id="score-title"></h2>
        <div class="grid" id="stats"><div class="stat"><p class="v">…</p><p class="k">scoring</p></div></div>
        <p class="limits" id="limits"></p>
      </section>
    </main>

    <footer class="status">
      <span id="status-block">block …</span>
      <span class="sp"></span>
      <span>integer forward pass, checked bit for bit against the node's C code</span>
    </footer>
  </div>
</div>
<script type="module">
import { unpackWeights, predict, readDataset } from "./neb-model.js";

const $ = (id) => document.getElementById(id);
const get = (f, kind) => fetch(f).then((r) => (kind === "json" ? r.json() : r.arrayBuffer()));
const [meta, packed, testBin, testInfo, faintBin, faintInfo] = await Promise.all([
  get("meta.json", "json"), get("slot1.bin"), get("tess-test-q8.bin"), get("signals.json", "json"),
  get("faint-planets-q8.bin"), get("faint-planets.json", "json"),
]);
const w = unpackWeights(new Uint8Array(packed));
const s = meta.slots["1"];
$("meta").textContent = `Weights of block ${meta.height}. Weights hash ${s.weightshash}.`;

const exofop = (tic) => `<a href="https://exofop.ipac.caltech.edu/tess/target.php?id=${tic}" target="_blank" rel="noopener noreferrer">TIC ${tic}</a>`;
const name = (c) => (c ? "eclipse" : "junk");
const pct = (a, b) => `${(100 * a / b).toFixed(1)}%`;
const stat = (v, k) => `<div class="stat"><p class="v">${v}</p><p class="k">${k}</p></div>`;
// the flipped light curves are not on this page: their count comes from the Python run (tools/faint_planets.py)
const FLIPPED = { called: 9, of: 261 };

const SETS = {
  test: {
    rows: readDataset(new Uint8Array(testBin)), info: testInfo, both: true,
    status: (n) => `${n.toLocaleString("en-US")} test signals`,
    viewsNote: "Real TESS data: the Quick-Look Pipeline light curve of the star below, folded on the period the catalog found. Brightness drops downward, in 8 steps of depth (0 to 7), as the chain sees it.",
    verdict: (i, r, p) => `Test signal n° ${i}: the model says <b>${name(p.label)}</b>. The catalog says ${name(r.label)}.`,
    star: (st) => `Star ${exofop(st.tic)} · period ${st.period} d · transit ${st.duration_h} h · depth ${st.depth_ppm} ppm${st.tmag ? ` · Tmag ${st.tmag} (catalog)` : ""} · TESS year ${st.year}`,
    title: "Held-out test signals · bright stars",
    limits: "These signals were kept out of the chain: the model never trained on them. The labels come from the Astronet-Triage-v2 catalog (Tey et al. 2023, CC BY 4.0), where people classified each signal. All these stars are brighter than T = 13.6, like the stars the model learned on.",
    stats(rows, said) {
      let right = 0, found = 0, eclipses = 0, yes = 0;
      rows.forEach((r, i) => { right += said[i] === r.label; eclipses += r.label; found += said[i] & r.label; yes += said[i]; });
      return stat(`${found} / ${eclipses}`, "eclipses found") + stat(pct(found, yes), `of the ${yes} "eclipse" answers are eclipses`) +
        stat(pct(right, rows.length), "right answers") + stat(pct(rows.length - eclipses, rows.length), 'if it always said "junk"');
    },
  },
  faint: {
    rows: readDataset(new Uint8Array(faintBin)), info: faintInfo, both: false,
    status: (n) => `${n} light curves of known planets`,
    viewsNote: "Real TESS data from another pipeline: the TGLC light curve (Han & Brandt 2023) of a star fainter than all the stars the model learned on, folded on the known period of its planet. Brightness drops downward, in 8 steps of depth (0 to 7).",
    verdict: (i, r, p, st) => `Planet n° ${i}, TOI ${st.toi}: the model says <b>${name(p.label)}</b>. It is a known planet.`,
    star: (st) => `Star ${exofop(st.tic)} · Tmag ${st.tmag} · sector ${st.sector} · period ${st.period} d · transit ${st.duration_h} h · depth ${st.depth_ppm} ppm · ${st.transits} transits · signal-to-noise in transit ${st.snr.toFixed(1)}`,
    title: "Known planets · faint stars",
    limits: `Planets confirmed or known before TESS (TOI disposition CP or KP, NASA Exoplanet Archive) around stars from T = 13.5 to 15.6, fainter than the training stars. Up to three sectors per star, light curves with at least two transits. How often the model says "eclipse" follows how clearly the transit stands out of the noise. The same light curves flipped hold no eclipse: the model called ${FLIPPED.called} of ${FLIPPED.of} an eclipse. In a blind search of faint stars, where most dips are noise, the model does not sort.`,
    stats(rows, said, info) {
      const band = (lo, hi) => { const ids = info.flatMap((st, i) => (st.snr >= lo && st.snr < hi ? [i] : [])); return `${ids.filter((i) => said[i]).length} / ${ids.length}`; };
      const yes = said.reduce((a, b) => a + b, 0);
      return stat(`${yes} / ${rows.length}`, "planets called an eclipse") + stat(band(10, Infinity), "transit signal-to-noise 10 or more") +
        stat(band(5, 10), "signal-to-noise 5 to 10") + stat(band(-Infinity, 5), "signal-to-noise below 5");
    },
  },
};
for (const set of Object.values(SETS)) set.said = set.rows.map((r) => predict(w, r.x).label);

let cur = SETS.test;

function plot(svg, values) {
  const pts = Array.from(values, (v, i) => `${i},${8 + (v / 7) * 84}`).join(" ");
  svg.innerHTML = `<polyline points="${pts}" fill="none" stroke="#87ff87" stroke-width="1.4" vector-effect="non-scaling-stroke"/>`;
}

function show(i) {
  const r = cur.rows[i], st = cur.info[i];
  $("idx").value = i;
  plot($("global"), r.x.subarray(0, 583));
  plot($("local"), r.x.subarray(583, 784));
  const p = predict(w, r.x);
  const right = p.label === r.label;
  $("verdict").innerHTML = `${cur.verdict(i, r, p, st)} <span class="${right ? "ok" : "no"}">${right ? "✓ match" : "✗ miss"}</span>`;
  $("star").innerHTML = st ? cur.star(st) : "";
  $("sums").textContent = `raw output sums · junk ${p.sums[0]} · eclipse ${p.sums[1]}`;
}

function pick(label) {
  const ids = cur.rows.flatMap((r, i) => (r.label === label ? [i] : []));
  show(ids[Math.floor(Math.random() * ids.length)]);
}

function use(key) {
  cur = SETS[key];
  $("set-test").setAttribute("aria-pressed", key === "test");
  $("set-faint").setAttribute("aria-pressed", key === "faint");
  $("eclipse").textContent = cur.both ? "Random eclipse" : "Random planet";
  $("junk").hidden = !cur.both;
  $("idx").max = cur.rows.length - 1;
  $("views-note").textContent = cur.viewsNote;
  $("score-title").textContent = cur.title;
  $("stats").innerHTML = cur.stats(cur.rows, cur.said, cur.info);
  $("limits").textContent = cur.limits + " An answer of the model is a hint for a human, not a planet confirmation. The model changes with every block; this page uses the one snapshot named above.";
  $("status-block").textContent = `block ${meta.height} · ${cur.status(cur.rows.length)}`;
  $("tic").value = "";
  pick(1);
}

$("set-test").onclick = () => use("test");
$("set-faint").onclick = () => use("faint");
$("eclipse").onclick = () => pick(1);
$("junk").onclick = () => pick(0);
$("go").onclick = () => show(Math.max(0, Math.min(cur.rows.length - 1, Number($("idx").value) || 0)));
$("find").onclick = () => {
  const tic = $("tic").value.replace(/\D/g, "");
  const i = cur.info.findIndex((st) => String(st.tic) === tic);
  if (i >= 0) return show(i);
  $("verdict").textContent = tic ? `TIC ${tic} is not in this set.` : "Type a TIC number.";
  $("star").textContent = ""; $("sums").textContent = "";
};
$("tic").onkeydown = (e) => { if (e.key === "Enter") $("find").onclick(); };
$("idx").onkeydown = (e) => { if (e.key === "Enter") $("go").onclick(); };
use("test");
</script>
</body>
</html>