× COMPATIBILITY & METHODS
From desktop Python to the Web The original Python reader, calibration and seven processing functions run with NumPy and SciPy in a browser Worker. This version exposes height/topography signals only: Height, Height Sensor, ZSensor and Topography, including their trace/retrace variants. Original signal names and calibrations are preserved. Phase, Amplitude and other non-height signals are excluded.
Verified libraries Loading the scientific engine…
Pyodide 0.29.3 provides NumPy, SciPy and Matplotlib. The native PyQt5, PyQtGraph and PyOpenGL interface is replaced by Web controls and Canvas rendering. Matplotlib supplies colormaps, which may differ slightly from PyQtGraph lookup tables.
Preserved calculations Line flatten: linear fit per scan row. Plane flatten: NumPy least squares. Despike: 3 × 3 median, 4σ threshold with MAD × 1.4826. Median filter: nearest boundaries. Remove background: Gaussian σ = 20 weighted by valid pixels. Fix scan lines: align row medians. Auto enhance: despike, fix lines, line flatten, remove background. Operations are cumulative and preserve invalid pixels.
Contrast and brightness use the 1st–99th percentiles, as in the original Python program. Native 4× export uses scipy.ndimage.zoom(order=3, mode='nearest') with an order-0 validity mask and a 60-million-pixel limit. It exports the entire oriented Height image in 2D, independent of display zoom. Other resolutions export the current view using browser interpolation. Interpolation does not create additional measured detail.
Multiple conditions Select or drop several .spm files at once. Each file becomes a separate condition, named after its filename. Rename conditions and switch between them without losing processing or display settings. Invalid files are reported individually while valid files remain available. Exports use the selected condition. All conditions stay in browser memory until the page is reloaded.
Reading and calibration The original reader supports Ciao image list blocks, signed 1/2/4/8-byte integers and Z calibration through /LSB factors and referenced sensitivity. 32-bit values ≤ −2147483640 become NaN. Without Z calibration, data remain in LSB. Without XY calibration, the scale bar is omitted. Force-curve-only files are unsupported. Incomplete image blocks are skipped and counted. Non-height channels are intentionally excluded. If no height signal is found, the import report lists the available channels.
External Python service None of the provided processing functions needs an external Python service: they use NumPy/SciPy in Pyodide. A separate service could help with files exceeding browser memory or future unsupported native libraries. No external compute service is connected. The first launch downloads the runtime and libraries from jsDelivr; AFM files stay local.
Validation and limitations Calculations are retained from the source. Real-acquisition validation and a complete comparison with the desktop program remain pending. The 3D view is sampled at approximately 180 points per axis, with normalized and exaggerated relief as in the original program. Scale bars are available in 2D only.
Sa and Sq measure deviations from the mean; Sz equals max − min over valid pixels in the full Height image. These added descriptive indicators do not replace a standardized roughness analysis.
Pyodide and supported libraries · PyQtGraph