This repository collects Jupyter notebooks that compare multiple Kalman filtering strategies on Gaussian shear-frame building models. The notebooks sweep through single- and multi-floor observation scenarios, linear and nonlinear measurement models, and small (3 floor) versus larger (10 floor) structures. Each experiment saves the generated ensembles, probability density functions (PDFs), and plots so you can reproduce or extend the studies.
| Path | Description |
|---|---|
KF/ |
Classic Kalman Filter notebooks (kalman_singlefloor.ipynb, Kalman_update_2floor.ipynb) plus stored priors/updates (pdf_prior_2data.npz, pdf_update_*.npz) and the reference plot KF_floor3_1observed.pdf. |
EnkF/ |
Ensemble Kalman Filter studies (EnKF_singlefloor.ipynb, EnkF_multiplefloors.ipynb, EnkF_multiplefloors_nonlinear.ipynb, check.ipynb), supporting ensembles (enkf_prior_*, enkf_update_*.npz), and comparison figures in matched/. |
PCKF/ |
Polynomial Chaos Kalman Filter notebooks for linear and nonlinear observation models plus extensive PDF exports (e.g., PCKF_floor*_2data_nonlinear_{10k,100k,1mill,10mill}.pdf). The matched/ folder contains overlays used to verify agreement with EnKF/KF. |
example_10dof/ |
Ten-degree-of-freedom examples for both EnKF and PCKF (standard and averaged-measurement variants) along with linear/nonlinear comparison data in matched/linear and matched/nonlinear. |
Supporting artifacts such as sample.txt, data_sample.txt, and pckf_prior_alpha.npz capture the raw ensembles and chaos coefficients that feed the update steps.
- Python 3.9+
- JupyterLab or Jupyter Notebook
- NumPy
- SciPy (for
scipy.stats,scipy.special) - Matplotlib
Install dependencies into a virtual environment to keep the workspace isolated:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install jupyterlab numpy scipy matplotlib- Activate the virtual environment and launch Jupyter:
source .venv/bin/activate jupyter lab - Open any notebook in the folder of interest (
KF/,EnkF/,PCKF/, orexample_10dof/). - Run the cells from top to bottom. Most notebooks expose key scenario parameters near the top:
floorsselects the structural dimension (3 or 10).observedchooses how many floors are instrumented (e.g., 1, 2, 3, or 5 averaged floors for 10-DOF studies).nsamp(ornpc) controls ensemble size/Polynomial Chaos order.Gamma,noisevar, andepsilonspecify measurement noise assumptions.
kalman_singlefloor.ipynbreconstructs a single observed floor in the 3-floor model and analytically derives covariance matrices for validation.Kalman_update_2floor.ipynbexpands to multiple observed floors and writes PDFs topdf_update_single.npz,pdf_update_2data.npz, andpdf_update_multiple.npzfor downstream comparison.- Use the exported
KF_floor3_1observed.pdfplot or regenerate it by re-running the notebook; PDFs are stored with a consistent naming scheme so EnKF/PCKF notebooks can load them.
EnKF_singlefloor.ipynbandEnkF_multiplefloors.ipynbfollow the same structural model but rely on Monte Carlo ensembles; they output the priors/updates asenkf_prior_*.npzandenkf_update_*.npz.EnkF_multiplefloors_nonlinear.ipynbreplaces the observation model with a nonlinear mapping and employs kernel density estimates viascipy.stats.gaussian_kde.check.ipynbprovides quick sanity plots or scalar checks.- The
matched/subdirectory holds side-by-side PDFs (EnKF vs. PCKF) for each floor to verify the agreement of the ensemble approximation.
PCKF_linear.ipynbandPCKF_nonlinear.ipynbload the saved EnKF ensembles (see thenp.load('./../EnKF/enkf_*.npz')calls) to match the stochastic inputs and then propagate Polynomial Chaos coefficients (pckf_prior_alpha.npz,pckf_update_alpha.npz).- Each notebook exports KDE plots for individual floors with varying sample budgets (
10k,100k,1mill,10mill), letting you study convergence as ensemble size grows. - The
matched/nonlinearfolder mirrors the EnKF comparisons and helps confirm that the chaos expansion reproduces the target PDFs floor-by-floor.
EnkF_10floors.ipynbandPCKF_10floors.ipynbscale the approach to ten floors with direct measurements, while the_averagedvariants (EnkF_10floors_averaged.ipynb,PCKF_10floors_averaged.ipynb) use averaged measurement matrices (see the customHkdefinitions).matched/linearandmatched/nonlinearcontain nested folders (1data,2data,3data,10data) with the saved priors/posteriors (pckf_prior_pdfs.npz,pckf_update_pdfs.npz) and Polynomial Chaos coefficients, allowing you to reproduce the figures or feed the data into other notebooks.- Each notebook saves an accompanying
pckf_prior_pdfs.npz,pckf_update_pdfs.npz, and (when relevant)pckf_prior_alpha.npz/pckf_update_alpha.npz, enabling deterministic reruns without regenerating the ensembles.
.npzarchives capture ensembles, priors, and posteriors for KF, EnKF, and PCKF runs. They are ready to be reloaded withnumpy.loadfor downstream analyses..pdffiles (for examplePCKF_floor3_2data_nonlinear_1mill.pdforEnKF_floor1_2data.pdf) summarize the PDFs for each floor, observation count, and noise setting. Many are duplicated undermatched/folders to simplify cross-filter comparisons.- Plain-text helpers such as
EnkF/sample.txtandexample_10dof/data_sample.txtstore the actual observation draws that seeded a notebook run.
- Adjust
observed,floors, orHkinside the notebooks to test different sensor layouts or averaged measurements. - Increase
nsamp/npcto study convergence (the existing10kto10millPDFs provide a reference for how the density evolves). - Swap the nonlinear observation sections in
EnkF_multiplefloors_nonlinear.ipynbandPCKF_nonlinear.ipynbwith your own measurement equations, keeping the saved.npzfiles in sync if you want to compare filters. - Use the
matched/artifacts as regression baselines; rerun a notebook, regenerate the PDFs, and compare them to the saved plots to confirm nothing drifted.
Contact : Sudhi Sharma P V Email: sudhisharmapadillath@gmail.com