
Chris Parmer
2026-11-16
SciPy demo
Scientific computing and signal processing in Python, with Dash and Plotly
TL;DR
- SciPy is Python's library of scientific algorithms: signal processing, statistics, optimization, curve fitting, differential equations, interpolation and linear algebra, all on NumPy arrays. Travis Oliphant, Eric Jones and Pearu Peterson started it in 2001, and SciPy 1.18.1 came out on August 21, 2026.
- In Dash apps, SciPy does the math behind engineering and science pages: filtered sensor signals and spectra, fitted decline and dose-response curves, optimized portfolios and simulated models.
- With a coding agent you don't write the filter or the fit yourself. You name the method and the agent writes the SciPy calls. These demos show you what's possible. This post lists those methods, the prompts we used and other apps you can build.
- Our example is Vibration Monitor, an app built with an agent that finds damaged bearings in 40 public test recordings from Case Western Reserve University (CWRU).

What is SciPy?
Engineers and scientists have a shared toolbox of numerical methods: digital filters, spectral estimates, least-squares fits, optimizers, integrators for differential equations and statistical tests. Most of those methods are decades old and well understood, and SciPy collects tested, fast implementations of them in one package, organized into subpackages such as scipy.signal, scipy.optimize, scipy.integrate, scipy.stats, scipy.interpolate and scipy.linalg.
That makes SciPy the package behind Dash apps like these:
- Signal apps for vibration, acoustics, electrocardiograms and other sensor data, with filters, spectra and peak detection.
- Curve fitting apps for production decline, dose-response assays and calibration curves.
- Optimization tools that choose portfolio weights, schedules or design parameters under constraints.
- Model simulators that integrate differential equations, from drug concentrations to reactor temperatures.
An agent now writes the SciPy code in minutes, so your time goes into choosing the method and checking the answer on real data.
What's possible
These are the SciPy capabilities worth naming to your agent, in plain words. The first five are what Vibration Monitor uses:
- Read MATLAB files: scipy.io.loadmat.
- Filter a band of frequencies: design a Butterworth band-pass filter with scipy.signal.butter(..., output="sos") and apply it forward and backward with sosfiltfilt, so the filter doesn't shift the signal in time.
- Estimate a spectrum: scipy.signal.welch averages the spectra of overlapping windows into a smooth power spectral density.
- Get the envelope of a signal: the magnitude of scipy.signal.hilbert traces the outline of the vibration, which is where repeating impacts show up.
- Describe the waveform: scipy.stats.kurtosis measures how spiky a signal is.
- Find peaks and smooth trends: scipy.signal.find_peaks, scipy.signal.ShortTimeFFT for spectrograms and scipy.signal.whittaker_henderson (new in 1.18) to smooth a trend of readings.
- Fit and optimize: scipy.optimize.curve_fit for a model with a few parameters, least_squares for harder fits and minimize for constrained problems.
- Simulate: scipy.integrate.solve_ivp for ordinary differential equations.
How to build a vibration monitoring app with SciPy
Pumps, compressors, fans and turbines all turn on bearings, and plants record their vibration thousands of times a second so a reliability engineer can decide whether to keep running, plan a repair or stop. The CWRU Bearing Data Center publishes recordings from a test motor whose bearings were given small, deliberate defects on the inner race, a ball or the outer race. We used 40 of them, 4 normal and 36 with a defect, which scipy.io.loadmat reads directly from MATLAB files.
Each damaged part makes the bearing ring at its own defect frequency, set by the bearing's geometry and the shaft speed. CWRU lists those frequencies for its bearing, so the app knows what to look for.
Page 1: Fleet health

The first page treats the recordings like a fleet of machines, one row each, with the overall vibration level (root mean square, or RMS) and kurtosis computed when the app starts. A slider sets the alarm level, and on this dataset a single RMS threshold separates every damaged bearing from the normal ones.
Prompt: Build a Dash app called Vibration Monitor for bearing condition monitoring on the CWRU bearing dataset (12 kHz drive end .mat files from engineering.case.edu/bearingdatacenter). Convert 40 recordings (normal, inner race, ball and outer race @6:00 faults, 7/14/21 mil, loads 0-3 hp) to one compressed npz of the first 10 s as float32, with the label, fault type, size, load and rpm in a JSON file. Fleet page: compute RMS, peak, crest factor and kurtosis (scipy.stats.kurtosis, not Fisher) for every recording at startup. A slider sets an RMS alarm level. Show cards for alarms, faults caught and false alarms, a log-x scatter of RMS against kurtosis colored by fault type with the alarm level as a dashed line, and a sortable DataTable.
Page 2: Spectrum

The second page shows one recording the way an engineer would first look at it: the waveform and its Welch spectrum, with a band-pass filter set by a slider. For a damaged inner race, the waveform is a train of short bursts, one each time a ball rolls over the defect, and the spectrum shows the band where those impacts ring.
Prompt: Spectrum page: a dropdown of recordings and a RangeSlider for a band-pass filter (0-6,000 Hz). Design the filter with scipy.signal.butter(4, [lo, hi], btype="bandpass", fs=12000, output="sos") and apply it with sosfiltfilt. Plot the first 0.1 s of the raw and filtered signals, and the Welch spectrum (scipy.signal.welch, nperseg=8192) on a log y axis with the pass band shaded. Cards: RMS, kurtosis before and after filtering, crest factor, and how long the filter and spectrum took.
Page 3: Diagnosis
The third page says which part is damaged, using envelope analysis: filter the signal to the band where the impacts ring, take its envelope with the Hilbert transform, and look at the envelope's spectrum. A defect shows up as a peak at its defect frequency and the harmonics of that frequency. Here's the SciPy code for it:
from scipy import signalsos = signal.butter(4, [2000, 5000], btype="bandpass", fs=12000, output="sos")envelope = np.abs(signal.hilbert(signal.sosfiltfilt(sos, x)))f, p = signal.welch(envelope - envelope.mean(), fs=12000, nperseg=2**15)amplitude = np.sqrt(p) # peaks at the defect frequency and its harmonics
For the outer race fault at the top of this post, the peak at the outer race frequency stands far above everything else. An inner race fault looks similar at its own frequency:

Across the dataset, the page named the damaged part in 20 of the 36 recordings, and every name it gave was right. Ball defects are the hard case on this dataset, and when no frequency stands out clearly the app says so rather than guessing, while the RMS alarm on the first page still flags the machine.

Prompt: Diagnosis page: a dropdown of recordings and a RangeSlider for the demodulation band (default 2,000-5,000 Hz). Band-pass with butter + sosfiltfilt, take np.abs of scipy.signal.hilbert, subtract the mean and take its Welch spectrum (nperseg=2**15). Plot 0-600 Hz with vertical lines at BPFO = 3.5848, BPFI = 5.4152 and 2xBSF = 4.7135 times the shaft frequency (rpm / 60) and their 2nd and 3rd harmonics. Score each fault as the mean of the peak within +/-2% of each of the first 3 harmonics over the median envelope amplitude from 5-600 Hz. Show the scores as bars on a log axis with a dashed line at 10, name the top fault if it's above 10, else "No bearing tone", and compare with the CWRU label. Add the fleet-wide diagnosis to the Fleet table.
Other apps you can build with SciPy
- Energy: a decline curve app that fits Arps curves to monthly oil and gas production with scipy.optimize.curve_fit and forecasts output.
- Finance: a portfolio builder that finds minimum-variance weights under position limits with scipy.optimize.minimize(method="SLSQP").
- Pharma: a pharmacokinetics app that fits a compartment model to blood concentrations with scipy.integrate.solve_ivp and scipy.optimize.least_squares.
- Lab science: a dose-response app that fits four-parameter logistic curves to assay plates with curve_fit and reports the half-maximal concentration (EC50).
- Spectroscopy: a peak picker that finds and measures peaks in Raman or mass spectra with scipy.signal.find_peaks and peak_widths.
SciPy works on the arrays covered in our NumPy demo, and our guide to Python packages for data covers the rest of the series.
What's new in SciPy 1.18
SciPy 1.18.0 came out on June 19, 2026, and 1.18.1 on August 21. It supports Python 3.12 to 3.14 and needs NumPy 2.0 or later. From the release notes:
- scipy.signal.whittaker_henderson, a new smoother for discrete signals that can choose its own smoothing strength. The release notes describe it as an alternative to the Savitzky-Golay filter, and with a penalty of order 2 it's the Hodrick-Prescott filter economists use.
- A new FFT backend: scipy.fft moved from pocketfft to its successor, ducc0, which needs much less memory for cached plans of long transforms.
- Faster linear algebra: lu and det rewritten in C++, and the batching loops of cholesky, qr, eig, lstsq and svd moved to C.
- Array API and JAX: many scipy.stats functions now accept lazy arrays and work under JAX's just-in-time compiler, and at least 21 functions gained array API support.
Running SciPy on Plotly Cloud and Dash Enterprise
What we learned deploying Vibration Monitor privately on Plotly Cloud, which applies the same way on Dash Enterprise:
- Ship compact arrays, not the raw files. The 40 MATLAB files are 134 MB, but the first 10 seconds of each as float32 in one compressed NumPy file is small enough to load at startup.
- Compute the fleet once, the detail on demand. Fleet-wide numbers are computed when the app starts, and filtering and the envelope spectrum for one recording run in the callback in milliseconds.
- Use second-order sections. Ask for output="sos" and sosfiltfilt. Narrow band-pass filters designed as transfer functions can become numerically unstable, and filtering forward and backward keeps the impacts where they happened.