--- pretty_name: TSAM preprocessed MAST tags: - fusion - tokamak - MAST - time-series --- # TSAM preprocessed MAST The exact MAST data used to pretrain the MASTER masked auto-encoder tokenizer: the MASTER signal cache, its camera targets, and the TokaMark task 1 windows the model is trained and scored on. Files are byte-identical to the training inputs; nothing was converted for upload. ## Use as is The data was built with, and is read by, commit `c06b314` of the code repository [lucas-maes/nuclear](https://github.com/lucas-maes/nuclear) (private: ask the author for access). 1. Get the code at that commit and install it with [uv](https://docs.astral.sh/uv/): ```sh git clone https://github.com/lucas-maes/nuclear && cd nuclear git checkout c06b314 uv sync ``` 2. From the repository root, download into `data/` (148 GB), the location the code reads by default: ```sh uv run hf download lmil/tsam_preprocessed --repo-type dataset --local-dir data ``` 3. Move the shots out of their split folders. The Hub allows at most 10,000 files per folder, so they are stored as `master/shots//.bin`; the code reads `master/shots/.bin`: ```sh for split in train val test; do mv data/master/shots/$split/*.bin data/master/shots/ && rmdir data/master/shots/$split; done ``` 4. Train the masked auto-encoder on the three task 1 tasks (it reads `data/master` and `data/tokamark`): ```sh uv run python -m methods.MASTER.mae task_1-1 task_1-2 task_1-3 ``` On Slurm, `methods/MASTER/slurm/mae.sh` takes the same arguments, copies the cache to the node's local disk first, and requeues itself before the time limit: ```sh mkdir -p logs && sbatch methods/MASTER/slurm/mae.sh task_1-1 task_1-2 task_1-3 ``` To read the data directly: ```python from pathlib import Path from methods.MASTER.cameras import CameraTransform from methods.MASTER.dataset import Transform, Windows windows = Windows(Path("data/master"), "train", chunks=4, cameras=("rba", "rbb")) item = windows[0] # item["values"][name]: (chunks, samples, channels), physical units normalized, used = Transform(Path("data/master"))(item["values"], item["states"], unrated=True) # item["cameras"][name]: frames (chunks, 224, 224), count, padding, tokens, bounds ``` ## Layout | Path | Content | | --- | --- | | `master/shots//.bin` | 11,177 shots, 40 signals at native rate in physical units: a JSON header, then one LZ4 block per 10 ms piece with float32 values and a state byte per value | | `master/meta.json` | Schema, j_tor cells the model reads, and the shots of each split (train 8,954, val 1,114, test 1,109) | | `master/stats.npz` | Normalization center, scale and count per channel, fitted on observed training values | | `master/audit.json` | Spread of each signal after its transform, and how many values each rejection rule removed | | `master/cameras/.bin` | 8,387 shots: per piece and camera (`rba`, `rbb`, `rbc`, `rgb`, `rgc`) the two 5 ms chunk-mean 224 x 224 canvases and frame counts, on the piece grid of `master/shots` | | `master/cameras/meta.json` | Canvas geometry and the vocabulary of each camera token field | | `tokamark/task_1-{1,2,3}/{train,val,test}.npz` | TokaMark task 1 windows exported by `methods.tokamind.export` | EFIT equilibrium samples that have no rating are kept under their own state, `UNRATED` (7): their values are finite and the masked auto-encoder uses them (`unrated=True`, its default), but they are excluded from the normalization statistics.