SparseWake/sparsewake
SparseWake SparseWake is a synthetic benchmark for sparse temporal hydrodynamic sensing. ICLR 2027 release The expanded release adds controlled multi-source mixtures and common-prior nearest-source tasks, with complete core data banks, reference checkpoints, a small review supplement, and reproduction code with a frozen wake-library input. Download release iclr2027-v1.0rc2 The version page lists the three archives, exact sizes, checksums, extraction instructions… See the full description on the dataset page: https://huggingface.co/datasets/SparseWake/sparsewake.
0275
1from __future__ import annotations2 3from pathlib import Path4 5import h5py6import numpy as np7 8 9LABEL_NAMES = ["delta_x", "delta_y", "theta_rel", "sin_phi", "cos_phi", "phi"]10REGION_NAMES = {1: "close_wake", 2: "near_side", 3: "mid_wake"}11SENSOR_NAMES = [12 "anterior_left",13 "anterior_right",14 "midbody_left",15 "midbody_right",16 "posterior_left",17 "posterior_right",18]19 20 21def _samples_first(array: np.ndarray, sample_axis_size: int) -> np.ndarray:22 if array.ndim == 1:23 return array24 if array.shape[0] == sample_axis_size:25 return array26 if array.shape[-1] == sample_axis_size:27 if array.ndim == 3 and array.shape[1] == 6 and array.shape[0] in (2, 3):28 return np.transpose(array, (2, 1, 0))29 axes = [array.ndim - 1] + list(range(array.ndim - 1))30 return np.transpose(array, axes)31 return array32 33 34def load_h5(path: str | Path, input_key: str = "X_raw") -> dict[str, np.ndarray]:35 path = Path(path)36 with h5py.File(path, "r") as handle:37 n = handle["y"].shape[-1]38 out: dict[str, np.ndarray] = {}39 for key in handle.keys():40 out[key] = _samples_first(np.asarray(handle[key]), n)41 out["input"] = out[input_key].astype(np.float32)42 out["target"] = out["y"][:, :3].astype(np.float32)43 out["pose_id"] = infer_pose_id(out)44 return out45 46 47def infer_pose_id(data: dict[str, np.ndarray]) -> np.ndarray:48 n = int(data["y"].shape[0])49 phase = np.asarray(data.get("groups", np.ones(n))).reshape(-1).astype(int)50 n_phase = int(len(np.unique(phase)))51 if n_phase <= 1 or n % n_phase != 0:52 return np.arange(n, dtype=np.int64)53 n_pose = n // n_phase54 return (np.arange(n) % n_pose).astype(np.int64)55 56 57def describe_h5(path: str | Path) -> dict[str, object]:58 path = Path(path)59 with h5py.File(path, "r") as handle:60 datasets = {61 key: {"shape": list(value.shape), "dtype": str(value.dtype)}62 for key, value in handle.items()63 if isinstance(value, h5py.Dataset)64 }65 return {"path": path.as_posix(), "datasets": datasets}66 