A tool to load, visualize, edit, and save logic trees for probabilistic tsunami hazard analysis (PTHA). JSON is the source of truth for loading, visualizing, and saving. Designed to handle very complex (deep, wide) trees.
A weighted epistemic-uncertainty hierarchy. Each node is a branch point — one
choice over a parameter (source geometry, Mmax, scaling relation, rigidity,
recurrence model, …). Each branch carries a weight, a selected value, and an
optional child node. A branch with no child is a leaf. One root→leaf path is a model
realization whose weight is the product of its branch weights. Sibling weights
must sum to 1 at every branch point.
schema/logic-tree.schema.json JSON Schema — the single source of truth for the format
examples/ simple.tree.json, cascadia.tree.json (illustrative)
web/ Vite + React + TypeScript app
pyendor/ Python companion package (same JSON format)
Local-first: load and save real .json files via the File System Access API — no
backend, nothing leaves your machine.
- Stack: Vite + React + TypeScript, React Flow (
@xyflow/react) canvas,@dagrejs/dagretop-down auto-layout, Zod runtime validation, Zustand state. - Source of truth is the nested
LogicTreeFilein the Zustand store (web/src/store.ts). The React Flow graph is a one-way projection derived from it (web/src/model/graph.ts) with path-based node ids (root,root/0,root/0/1) so identity/collapse/layout survive edits. - Editing: the Inspector panel supports rename parameter/label; add/delete/reorder branches; edit weights & values; grow/prune subtrees; a live sum-to-1 check with "Normalize to 1"; selected-node highlight; dirty tracking; and save in place.
npm --prefix web install # first time only
npm --prefix web run dev # → http://localhost:5173npm --prefix web run buildReads and writes the identical JSON format, so trees authored in the GUI drop straight into a tsunami-hazard pipeline.
endor.LogicTree:load/save,realizations()(generator of weighted root→leaf paths),count_realizations().endor.validate: checks sibling weight sums.
cd pyendor && PYTHONPATH=. python3 -m pytest -q- Phase 1 (done): schema + Zod types + examples; load → dagre auto-layout → render → collapse/expand → save. Python companion with load/validate/enumerate.
- Phase 2 (done): interactive editing via the Inspector — rename, add/delete/reorder branches, edit weights & values, grow/prune subtrees, live sum-to-1 check + "Normalize to 1", selected-node highlight, dirty tracking, save in place.
- Phase 3 (planned): enumerate-paths panel in the UI + export weighted realizations
(CSV/JSON). Enumeration logic already exists in
web/src/ops/operations.ts(enumerate) andpyendor/endor/tree.py(realizations). - Phase 4 (planned): load two trees side by side and diff structure + weights.
- Later:
$ref-style subtree reuse for the common PTHA case where the same sub-logic-tree repeats under every source (keeps complex trees DRY).