Repository navigation
v0.2.0
Version 0.2.0 introduces the scene grammar, i.e. a general vocabulary from which a visualization is declared. The packages at this version write and read scene format 0.2, which may still change incompatibly until 1.0, and data container version 1.
Added
- TyCHO describes each scene in a scene grammar. A scene is two files, which a Python script writes from NumPy arrays and the browser interprets. The grammar covers track sets (collections of trajectories) with per-sample channels (numbers stored at every sample, such as the time), bodies (named points), a tree of reference frames, variables, one clock, views with layers, panels, controls, and readouts. The rules of the grammar are numbered in
spec/tycho-scene.md, andspec/scene.schema.jsongives its structure. The conformance corpus inspec/conformance/holds scenes with the answers an evaluator must give, and both the Python and the TypeScript evaluators pass it. - Two files store a scene. The scene document
scene.tysis JSON that refers to the arrays by name and specifies what they are. The data containerdata.tydholds aTYCDmagic number, a JSON header, and named little-endian typed arrays. Each array is stored raw or, when this is smaller, compressed without loss in chunks of about 1 MiB. The compression takes the bit pattern of each number, replaces each row by its difference from the row before (delta coding), groups the bytes by their position within each number (byte shuffling), and deflates the result. A browser inflates, i.e. decompresses, these chunks with its nativeDecompressionStream, and a reader can decode one chunk at a time. The input of the Broucke example takes 60 percent of its raw size, and its page takes 12.7 MB, against 22.1 MB with the whole container gzipped. - pytycho provides the
Scenebuilder, thinning, andevaluate. The builder checks every call, then checks the whole scene for every value its variables can take, and reports each failure with the number of the rule it breaks. Thinning keeps a subset of the stored samples, selected by arclength, measured in the frames listed in the call, by default the frame of the set. The functionevaluatereturns what the browser draws for a frame index, so that a test can check what a scene draws without a browser. - The runtime provides the
<tycho-viewer>element, which draws any scene in panels that can be rearranged by drag and drop. Each panel keeps separate values of the panel-scoped variables, e.g. the frame that it shows. The element draws sliders, tabs, toggles, a transport (the controls that play and pause the clock and switch its active channel), and readouts. - Playback runs at the refresh rate of the display. Every refresh draws at the progress given by the wall time, i.e. the real time elapsed, and this progress may lie between two frame indices. The layers under the first layer that takes a clock reading do not move with the animation. They are drawn once per panel, until the camera or these layers change, and copied back every frame. Body trails are read from positions kept per lap, so that a frame copies a trail instead of computing it. The frame rate shown counts the frames drawn in the last second. The script
web/scripts/frame-profile.mjsmeasures what a frame of an example page costs, in headless Chrome. - The viewer exports an MP4 video of its current state, from its controls or through
exportVideo. The video is encoded in the browser itself, with the WebCodecs API and the mp4-muxer library. - The npm package ships type declarations, which let TypeScript check code that uses the package.
- A track set stores its positions and channels as float32 by default. pytycho now stores a clock channel as float64 in a float32 set when float32 would round the ends of a step between samples by more than 1% of the step, or would make the channel nonmonotone. A nonmonotone channel would break rule T3, under which a clock channel increases or decreases strictly along every track. The argument
track_set(channel_dtypes=)sets the stored dtype of a channel by hand. build_htmlembeds the container as base64 text without further compression, since its arrays are already compressed. It rejects a scene or data whose base64 is longer than 536,870,888 characters, the most that Chrome holds in one string, since a longer text would leave the page empty.- Both container readers reject a view key or an encoding they do not know (rule D2), since a reader that ignored either could read the bytes wrongly. Section 1 of the spec specifies which changes bump the container version (rule D3).
Container.parsein the runtime and theloadmethod of the element return promises, since they inflate the encoded views, which the browser does asynchronously. - The Broucke example reads its trajectories from
broucke-input.tyd, a data container attached to each GitHub Release. It imports only NumPy, pytycho, and the standard library, hence it runs without PyDyLAN. - An agent skill,
skills/tycho/SKILL.md, sets out the scene grammar for a coding agent. It can be installed as a Claude Code plugin from this repository or withnpx skills add beeson-group/tycho. - The npm package bundles three.js and mp4-muxer, and it does not have any runtime dependencies, hence installing it does not install any other package.
- Both packages declare the license
Apache-2.0 AND MIT, since the bundle carries MIT-licensed code, and they shipNOTICEandTHIRD_PARTY_NOTICES.md. Every bundle starts with a comment listing the bundled packages. Every page that pytycho writes inlines the bundle, and thus carries the same comment.