Skip to main content

svr-roughness

svr-roughness is a high-performance Python package for ASTM WK92969 and ISO 16610-61 areal surface roughness analysis ($S_a$, $S_q$, $S_{VR}$). It is developed by the Human-centered Advanced Manufacturing (HAM) Lab at Iowa State University.

The numerical core is implemented in pure Python using vectorized NumPy operations, eliminating all heavy external C++ compiler and DLL dependencies while providing 100% numerical fidelity to the reference SurfInspect metrology pipeline.

import numpy as np
from svr_roughness import RoughnessConfig, analyze_points

# points shape (N, 3), units in millimeters
config = RoughnessConfig(
    grid_mm=0.20,
    short_cutoff_mm=1.0,
    long_cutoff_mm=25.0,
    svr_points=10,
    svr_span_mm=0.50,
)
result = analyze_points(points_xyz_mm, config=config)
print(f"Sa:  {result.sa_um:.3f} µm")
print(f"Sq:  {result.sq_um:.3f} µm")
print(f"Svr: {result.svr_um:.3f} µm")

Features

  • Standard-Compliant Metrology: Implements the full ASTM WK92969 pipeline:
    1. Centering and unit standardization
    2. $O(N)$ 3D voxel grid centroid downsampling
    3. PCA best-fit plane alignment
    4. 2.5D elevation grid rasterization with iterative hole filling and boundary cropping
    5. Dual-pass ISO 16610-61 Gaussian filtration ($\alpha = 0.4697$)
    6. 2D FFT autocorrelation variogram and local $S_{VR}$ dispersion map
  • Zero-Compiling Pure-Python: Runs everywhere Python 3.10+ runs (Linux, macOS, Windows, Pyodide/WebAssembly) with only standard numpy and scipy.
  • Wide Scan Format Support: Reads .ply (ASCII & binary), .pcd (ASCII & binary), .stl (ASCII & binary), .obj, delimited text (.csv, .tsv, .xyz, .txt), and NumPy arrays (.npy, .npz).
  • CLI and Web Integration: Ships with a command-line interface (svr-roughness) and powers the client-side WebAssembly inspection dashboard.

Install

Install from PyPI:

pip install svr-roughness

Or install from source:

pip install .

Python API

Use analyze_points() when your scanner or upstream software already gives you XYZ points:

import numpy as np
from svr_roughness import analyze_points

points_xyz_mm = np.asarray(points)  # shape (N, 3), columns x/y/z, units mm
result = analyze_points(points_xyz_mm, grid_mm=0.30, short_cutoff_mm=0.6, long_cutoff_mm=8.0)

print(result.sa_um, result.sq_um, result.svr_um)

Use analyze_file() as a convenience adapter for supported files:

from svr_roughness import RoughnessConfig, analyze_file

config = RoughnessConfig(grid_mm=0.30, short_cutoff_mm=0.6, long_cutoff_mm=8.0)
result = analyze_file("scan.ply", config=config)

Supported file loaders (all are converted to an Nx3 NumPy array):

  • ASCII and binary little-endian .ply point clouds
  • ASCII and binary .pcd point clouds
  • ASCII and binary .stl mesh vertices
  • .obj vertex meshes
  • comma-, tab-, or whitespace-delimited .csv, .tsv, .xyz, and .txt
  • .npy and .npz NumPy arrays

STL files are converted to their unique mesh vertices before analysis. For production mesh metrology, prefer scanner point clouds or add controlled surface sampling before calling analyze_points().

Result Output

result.save_grid_npz("output/roughness/latest_grid.npz")
result.save_metrics_json("output/roughness/latest_metrics.json")

save_metrics_json() writes:

  • sa_um
  • sq_um
  • svr_um
  • point counts, grid dimensions, grid coverage, and filter cutoffs

save_grid_npz() writes:

  • grid_raw
  • grid_filled
  • grid_filtered
  • valid_raw
  • valid_filled
  • grid_origin
  • plane basis arrays

Command line

The package also includes a no-code command for scanner integrations:

svr-roughness scan.ply --grid-mm 0.30 --metrics-out metrics.json --grid-out grid.npz
# Add --gaussian-mesh to use the recovered legacy Gaussian mesh path.

Coordinates are assumed to be millimeters, and metrics are reported in micrometers. Unit conversion should happen before calling the library.

Testing

Run the test suite using pytest:

pytest tests/ -v

The test suite covers:

  • Complete I/O loading for all supported formats (ASCII/binary PLY, ASCII/binary STL, PCD, OBJ, CSV, XYZ, NPY/NPZ)
  • $O(N)$ voxel downsampling and edge cases
  • PCA plane alignment and coordinate frame invariants
  • 2.5D elevation grid rasterization, boundary shaving, and iterative hole filling
  • Dual-pass ISO 16610-61 Gaussian filtering ($\alpha = 0.4697$)
  • Monotonicity, dispersion mapping, and Cauchy-Schwarz mathematical invariants ($S_q \ge S_a$)
  • End-to-end ASTM WK92969 validation on SCRATA comparator standards

Legacy C++ Native Core (Optional)

The historical C++ native bridge and CMake configuration are preserved under native/ for reference and backwards compatibility. The standard pure-Python package no longer requires building or compiling native code, as the vectorized NumPy/SciPy engine provides identical numerical output with superior cross-platform portability.

License

MIT License — Iowa State University HAM Lab.

Release files for svr-roughness 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svr-roughness 0.6.1
File Size Uploaded
svr_roughness-0.6.1.tar.gz 31.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for svr-roughness 0.6.1
File Interpreter ABI Platform
svr_roughness-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 55.1 kB

Release files / svr_roughness-0.6.1.tar.gz

Download URL svr_roughness-0.6.1.tar.gz
Size 31.0 kB
Tags Source
SHA-256 checksum
How to use checksums
63afdda119d0cae9ea1717f0b034cdbb007f8b0de3fe551a9f52804572e35528
BLAKE2b-256 checksum
How to use checksums
ee59636d9ecb3c979dfbc81557dff471c650f637b5892109500bc2efd2c06a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / svr_roughness-0.6.1-py3-none-any.whl

Download URL svr_roughness-0.6.1-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
167fff7a1b3f4b72b53b94ce9cbffe86cf873bb08502f73deee1aa50fe580758
BLAKE2b-256 checksum
How to use checksums
d3e01989d8dce37a836ad120474a34460ce569e1d7d855362c78ff45d10b6492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.4.18

2 release files

0.4.17

2 release files

0.4.16

2 release files

0.4.13

2 release files

0.4.12

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page