deduplication pass

This commit is contained in:
2026-04-03 18:19:08 -07:00
parent f6b47e6d79
commit c8d766677b
42 changed files with 484 additions and 689 deletions

View File

@@ -1,5 +1,7 @@
from __future__ import annotations
import numpy as np
from backend.data_types import DataField
@@ -15,6 +17,21 @@ def unit_dimension_key(unit: str) -> str:
return text
def slope_unit(field: DataField) -> str:
"""Return the physical slope unit string (z_unit/xy_unit)."""
z = str(field.si_unit_z or "").strip()
xy = str(field.si_unit_xy or "").strip()
return f"{z}/{xy}" if z and xy else (z or xy)
def physical_sobel_gradient(field: DataField) -> tuple[np.ndarray, np.ndarray]:
"""Compute physical Sobel gradient (gx, gy) in z_unit/xy_unit."""
from scipy.ndimage import sobel
gx = sobel(field.data, axis=1) / (8.0 * field.dx)
gy = sobel(field.data, axis=0) / (8.0 * field.dy)
return gx, gy
def require_compatible_xy_z_units(field: DataField, node_name: str) -> None:
xy_key = unit_dimension_key(field.si_unit_xy)
z_key = unit_dimension_key(field.si_unit_z)