parti-wave commited on
Commit
0d2fa14
·
verified ·
1 Parent(s): 69cc954

Upload N4_slice.py

Browse files

Loading Script for the canonical Tav RGC N4 Run Slices

Files changed (1) hide show
  1. N4_slice.py +68 -0
N4_slice.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Loading script for parti-wave/N4_slice — lattice CSVs only by default."""
2
+ import datasets
3
+
4
+ _DESCRIPTION = "RGC N4 logistic lattice slices (49-core) with paired session logs."
5
+ _CITATION = """@misc{gatlin_rgc_2026,
6
+ author = {Gatlin III, Ernest C.},
7
+ title = {Resonance Graph Core (RGC) Architecture},
8
+ year = {2026},
9
+ doi = {10.5281/zenodo.20111854}
10
+ }"""
11
+
12
+ class N4Slice(datasets.GeneratorBasedBuilder):
13
+ BUILDER_CONFIGS = [
14
+ datasets.BuilderConfig(name="lattice", version=datasets.Version("1.0.0"),
15
+ description="253 prospect-named logistic lattice windows"),
16
+ ]
17
+ DEFAULT_CONFIG_NAME = "lattice"
18
+
19
+ def _info(self):
20
+ return datasets.DatasetInfo(
21
+ description=_DESCRIPTION,
22
+ citation=_CITATION,
23
+ features=datasets.Features({
24
+ "timestamp_iso": datasets.Value("string"),
25
+ "elapsed_sec": datasets.Value("float32"),
26
+ "core_id": datasets.Value("int32"),
27
+ "x_norm": datasets.Value("float32"),
28
+ "x_raw24": datasets.Value("int64"),
29
+ "n": datasets.Value("int64"),
30
+ "delta_n": datasets.Value("int32"),
31
+ "slice_id": datasets.Value("string"), # optional: filename stem
32
+ }),
33
+ )
34
+
35
+ def _split_generators(self, dl_manager):
36
+ # Hub layout: all n4_slice_*.csv at repo root
37
+ files = dl_manager.download_and_extract({
38
+ "files": "n4_slice_*.csv",
39
+ })
40
+ # Fallback: list via pattern after download
41
+ import glob, os
42
+ root = dl_manager.manual_dir or "."
43
+ paths = sorted(glob.glob(os.path.join(root, "n4_slice_*.csv")))
44
+ if not paths:
45
+ paths = dl_manager.download([f"n4_slice_{i:03d}_*.csv" for i in range(253)])
46
+ return [
47
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": paths}),
48
+ ]
49
+
50
+ def _generate_examples(self, files):
51
+ import csv, os
52
+ key = 0
53
+ for path in files:
54
+ slice_id = os.path.basename(path).replace(".csv", "")
55
+ with open(path, newline="", encoding="utf-8") as f:
56
+ reader = csv.DictReader(f)
57
+ for row in reader:
58
+ yield key, {
59
+ "timestamp_iso": row["timestamp_iso"],
60
+ "elapsed_sec": float(row["elapsed_sec"]),
61
+ "core_id": int(row["core_id"]),
62
+ "x_norm": float(row["x_norm"]),
63
+ "x_raw24": int(row["x_raw24"]),
64
+ "n": int(row["n"]),
65
+ "delta_n": int(row["delta_n"]),
66
+ "slice_id": slice_id,
67
+ }
68
+ key += 1