ψ Vikshep
← Back to recipes

Recipe 03

General Feature Extraction

Cosmology, plasma, GW, hydrodynamics.

When to use this

Use this recipe when you need translation- and rotation-invariant, multiscale, deformation-stable features for any tensor-valued scientific data — and you do not want to train a model to produce them. The scattering transform is a fixed, analytic feature extractor: no training, no data-hungry fitting, no hyperparameter search beyond the wavelet bank geometry.

First-order coefficients S₁ recover power-spectrum-like information (second-order statistics). Second-order coefficients S₂ recover bispectrum-like structure — the non-Gaussian information that the power spectrum is blind to and that distinguishes physically different fields with identical two-point functions. This has been validated in weak-lensing cosmology (Cheng & Ménard, 2021), molecule property prediction (Eickenberg et al., 2018), and plasma turbulence.

The engine is runtime-configurable: pass (dim, group, J, Q, L) as flags and the same binary handles 1-D gravitational-wave strain, 2-D CMB patches, and 3-D density fields. No recompilation, no model retraining, no rebuild per domain.

What it needs

Any tensor data. The engine accepts 1-D arrays, 2-D images, and 3-D volumes from ROOT, HDF5, NumPy, VTK, and FITS sources. Provide the path, the dataset name (for HDF5/ROOT), and the (dim, group) config; the engine handles the rest.

# 1-D: gravitational-wave strain / time series strain.h5 # dataset "strain", shape (N_segments, T) # 2-D: weak-lensing convergence maps / CMB patches kappa_maps.fits # shape (N_patches, 512, 512) # 2-D: jet images (use hep-tagging recipe for mass decorrelation) jet_images.h5 # shape (N_events, 64, 64) # 3-D: density field / plasma simulation / nuclear structure density.h5 # shape (N_snapshots, 128, 128, 128) field.vtk # VTK UnstructuredGrid or ImageData # NumPy arrays — any shape matching dim data.npy # shape (..., *spatial_dims)

How it works

MCP tool call sequence

01

vikshep/ingest

Loader reads the tensor from the source format, applies any requested pre-processing (normalisation, patching, mean subtraction), writes the result to POSIX shared memory, and returns a 28-char OID with an attached shape metadata record. The ingest step handles format detection automatically based on the file extension.
in: file path + dataset name + pre-processing configout: 28-hex OID + shape tuple + dtype
02

vikshep/compute_scattering

Runs the scattering engine with caller-supplied (dim, group, J, Q, L). The engine selects the appropriate filter bank at runtime:
  • dim=1, group=trivial → 1-D Morlet wavelets
  • dim=2, group=so2 → oriented 2-D Morlet bank (SE(2))
  • dim=3, group=so3 → solid-harmonic wavelets (SO(3))
The C++/CUDA kernel is compiled once; the (dim, group) selection is a dispatch over a templated engine class — no runtime branching in the hot path.
in: data OID + (dim, group, J, Q, L)out: coefficient OID · shape depends on (dim, J, L, order)
03

vikshep/reduce_scattering

Reduces the full coefficient tensor to a fixed-length feature vector per sample. Reduction methods: mean (spatial average), std (spatial standard deviation, captures texture scale), log_mean (log-space averaging, recommended for scale-spanning data), ratio (S₂/S₁, for dimensionless comparison). Multiple methods can be concatenated by passing a comma-separated list.
in: coefficient OID + method(s)out: feature OID · shape (N_samples, D_features)
04

(export)

Exports the feature matrix to HDF5 or NumPy. Includes provenance metadata: the (dim, group, J, Q, L) configuration, the reduction method, the source OID, and a SHA3-256 hash of the engine version used to produce the features. Features exported with the same config and engine version are bit-reproducible across runs and machines with the same CUDA version.
in: feature OID + output formatout: features.h5 (or .npy) + provenance.json

What you get

  • features.h5 — feature matrix, shape (N_samples, D_features), with provenance metadata
  • provenance.json — { dim, group, J, Q, L, reduction, engine_version, source_oid_hash }
  • feature_oids.txt — SHA3-256 OIDs of intermediate tensors (reusable without recompute)
  • coefficient_shapes.json — shape and dtype of each intermediate coefficient tensor

Configure it

paramdefaultdescription
dim2Spatial dimensionality of the input tensor
groupso2so2 for 2-D roto-translation; so3 for 3-D rotation; trivial for 1-D
J4–8Scales. GW strain: J=8. Lensing maps: J=6. Density fields: J=4
Q1–8Voices per octave. Q=8 for fine-grained spectral resolution (GW, audio)
L8Orientations (ignored for dim=1 and group=trivial)
L_max3Max spherical-harmonic order ℓ for SO(3). L_max=2 captures most non-Gaussianity
reductionlog_meanFeature reduction method
order2Maximum scattering order. order=2 for most applications
normalisetrueNormalise input to unit variance before scattering
output_formathdf5Output format: hdf5, numpy, or oid_only

Run it — CLI

# Weak-lensing maps bun run main.ts process \ --input kappa_maps.fits \ --recipe feature-extract \ --dim 2 --group so2 --J 6 --L 8 \ --output results/lensing-features/ # 3-D density field bun run main.ts process \ --input density.h5 --dataset density \ --recipe feature-extract \ --dim 3 --group so3 --J 4 --L-max 3 \ --output results/density-features/ # Gravitational-wave strain bun run main.ts process \ --input strain.h5 --dataset strain \ --recipe feature-extract \ --dim 1 --group trivial --J 8 --Q 8 \ --output results/gw-features/

Run it — Dashboard

Dashboard screenshot — coming in Pilot

The dashboard shows per-scale energy profiles (S₁ per j) and cross-scale correlation heatmaps (S₂ as a j₁×j₂ grid) for a sample of the input data. Useful for inspecting which scales carry the most discriminating information before running a downstream classifier or clustering pipeline. Available in the Pilot release.

Related

1-D scattering mathSolid harmonics and SO(3)Steerable wavelets — GPU register economyHEP Tagging (DisCo)BSM Anomaly DetectionCheng & Ménard — scattering for cosmologyGitHub

Get started

Ready to run this recipe?

Talk to founders →Request a feature ↗View on GitHub ↗