From f4d218e1b4f7c9ff7cec309953dde65ae9fc11a7 Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Fri, 1 May 2015 10:42:53 -0700 Subject: [PATCH] Fixed PDF output; blank Particle filter chapter. The PDF was not setting the Preface as a unnumbered chapter. I think there is more work to get it's subsections unnumbered. Added empty Particl filter chapter. Had to renumber the chapters to make it fit in. --- 13_Particle_Filters.ipynb | 305 ++++++++++++++++++ 13_Smoothing.ipynb => 14_Smoothing.ipynb | 0 ...ering.ipynb => 15_Adaptive_Filtering.ipynb | 0 ...ilters.ipynb => 16_HInfinity_Filters.ipynb | 0 ....ipynb => 17_Ensemble_Kalman_Filters.ipynb | 0 pdf/build_book | 7 +- pdf/merge_book.py | 9 +- pdf/to_pdf.py | 16 +- table_of_contents.ipynb | 19 +- 9 files changed, 336 insertions(+), 20 deletions(-) create mode 100644 13_Particle_Filters.ipynb rename 13_Smoothing.ipynb => 14_Smoothing.ipynb (100%) rename 14_Adaptive_Filtering.ipynb => 15_Adaptive_Filtering.ipynb (100%) rename 15_HInfinity_Filters.ipynb => 16_HInfinity_Filters.ipynb (100%) rename 16_Ensemble_Kalman_Filters.ipynb => 17_Ensemble_Kalman_Filters.ipynb (100%) diff --git a/13_Particle_Filters.ipynb b/13_Particle_Filters.ipynb new file mode 100644 index 0000000..2b7ddfb --- /dev/null +++ b/13_Particle_Filters.ipynb @@ -0,0 +1,305 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[Table of Contents](http://nbviewer.ipython.org/github/rlabbe/Kalman-and-Bayesian-Filters-in-Python/blob/master/table_of_contents.ipynb)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Particle Filters" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#format the book\n", + "%matplotlib inline\n", + "%load_ext autoreload\n", + "%autoreload 2 \n", + "from __future__ import division, print_function\n", + "import matplotlib.pyplot as plt\n", + "import book_format\n", + "book_format.load_style()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/13_Smoothing.ipynb b/14_Smoothing.ipynb similarity index 100% rename from 13_Smoothing.ipynb rename to 14_Smoothing.ipynb diff --git a/14_Adaptive_Filtering.ipynb b/15_Adaptive_Filtering.ipynb similarity index 100% rename from 14_Adaptive_Filtering.ipynb rename to 15_Adaptive_Filtering.ipynb diff --git a/15_HInfinity_Filters.ipynb b/16_HInfinity_Filters.ipynb similarity index 100% rename from 15_HInfinity_Filters.ipynb rename to 16_HInfinity_Filters.ipynb diff --git a/16_Ensemble_Kalman_Filters.ipynb b/17_Ensemble_Kalman_Filters.ipynb similarity index 100% rename from 16_Ensemble_Kalman_Filters.ipynb rename to 17_Ensemble_Kalman_Filters.ipynb diff --git a/pdf/build_book b/pdf/build_book index 3607e85..b14d1a0 100644 --- a/pdf/build_book +++ b/pdf/build_book @@ -1,13 +1,12 @@ #! /bin/bash echo "merging book..." - -python merge_book.py > Kalman_and_Bayesian_Filters_in_Python.ipynb +python merge_book.py echo "creating pdf..." -ipython nbconvert --to latex --template book Kalman_and_Bayesian_Filters_in_Python.ipynb +ipython nbconvert --to latex --template book book.ipynb ipython to_pdf.py mv Kalman_and_Bayesian_Filters_in_Python.pdf .. -echo "done." + diff --git a/pdf/merge_book.py b/pdf/merge_book.py index b6d68c3..88e9e4d 100644 --- a/pdf/merge_book.py +++ b/pdf/merge_book.py @@ -47,9 +47,10 @@ if __name__ == '__main__': '../10_Unscented_Kalman_Filter.ipynb', '../11_Extended_Kalman_Filters.ipynb', '../12_Designing_Nonlinear_Kalman_Filters.ipynb', - '../13_Smoothing.ipynb', - '../14_Adaptive_Filtering.ipynb', - '../15_HInfinity_Filters.ipynb', - '../16_Ensemble_Kalman_Filters.ipynb', + '../13_Particle_Filters.ipynb', + '../14_Smoothing.ipynb', + '../15_Adaptive_Filtering.ipynb', + '../16_HInfinity_Filters.ipynb', + '../17_Ensemble_Kalman_Filters.ipynb', '../Appendix_A_Installation.ipynb', '../Appendix_B_Symbols_and_Notations.ipynb']) diff --git a/pdf/to_pdf.py b/pdf/to_pdf.py index 96ce330..dc74efc 100644 --- a/pdf/to_pdf.py +++ b/pdf/to_pdf.py @@ -4,10 +4,22 @@ import io import IPython.nbconvert.exporters.pdf as pdf import fileinput +''' for line in fileinput.input('book.tex', openhook=fileinput.hook_encoded("iso-8859-1")): -# print(line.replace('\chapter{Preface}', '\chapter*{Preface}'), end='') - line.replace('\chapter{Preface}', '\chapter*{Preface}') + #print(line.replace('\chapter{Preface}\label{preface}', '\chapter*{Preface}\label{preface}'), end='') +# line.replace(' \chapter{Preface}\label{preface}', ' \chapter*{Preface}\label{preface}') + line.replace('shit', 'poop') +''' +f = open('book.tex', 'r', encoding="iso-8859-1") +filedata = f.read() +f.close() + +newdata = filedata.replace('\chapter{Preface}', '\chapter*{Preface}') + +f = open('book.tex', 'w', encoding="iso-8859-1") +f.write(newdata) +f.close() p = pdf.PDFExporter() p.run_latex('book.tex') diff --git a/table_of_contents.ipynb b/table_of_contents.ipynb index 93c8777..0bb13e4 100644 --- a/table_of_contents.ipynb +++ b/table_of_contents.ipynb @@ -77,24 +77,29 @@ "Works through some examples of the design of Kalman filters for nonlinear problems. *This is still very much a work in progress.*\n", "\n", "\n", - "[**Chapter 13: Smoothing**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/13_Smoothing.ipynb)\n", + "[**Chapter 13: Particle Filters**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/13_Particle_Filters.ipynb)\n", + " \n", + "Particle filters uses Monte Carlo techniques to filter data. They easily handle highly nonlinear and non-Gaussian systems, as well as multimodal distributions (tracking multiple objects simultaneously) at the cost of high computational requirements.\n", + "\n", + "\n", + "[**Chapter 14: Smoothing**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/14_Smoothing.ipynb)\n", "\n", "Kalman filters are recursive, and thus very suitable for real time filtering. However, they work extremely well for post-processing data. After all, Kalman filters are predictor-correctors, and it is easier to predict the past than the future! We discuss some common approaches.\n", "\n", "\n", - "[**Chapter 14: Adaptive Filtering**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/14_Adaptive_Filtering.ipynb)\n", + "[**Chapter 15: Adaptive Filtering**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/15_Adaptive_Filtering.ipynb)\n", " \n", "Kalman filters assume a single process model, but manuevering targets typically need to be described by several different process models. Adaptive filtering uses several techniques to allow the Kalman filter to adapt to the changing behavior of the target.\n", "\n", "\n", - "[**Chapter 15: H-Infinity Filters**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/15_HInfinity_Filters.ipynb)\n", + "[**Chapter 16: H-Infinity Filters**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/16_HInfinity_Filters.ipynb)\n", " \n", "Describes the $H_\\infty$ filter. \n", "\n", "*I have code that implements the filter, but no supporting text yet.*\n", "\n", "\n", - "[**Chapter 16: Ensemble Kalman Filters**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/16_Ensemble_Kalman_Filters.ipynb)\n", + "[**Chapter 17: Ensemble Kalman Filters**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/17_Ensemble_Kalman_Filters.ipynb)\n", "\n", "Discusses the ensemble Kalman Filter, which uses a Monte Carlo approach to deal with very large Kalman filter states in nonlinear systems.\n", "\n", @@ -105,12 +110,6 @@ "\n", "*This chapter is not started. I'm likely to rearrange where this material goes - this is just a placeholder.*\n", "\n", - "[**Chapter XX: Particle Filters**](not implemented)\n", - " \n", - "Particle filters uses a Monte Carlo technique to filter. \n", - "\n", - "*This is not implemented, and I have not decided if I want to make it part of this book or not.*\n", - "\n", "\n", "[**Appendix: Installation, Python, NumPy, and FilterPy**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/Appendix_A_Installation.ipynb)\n", "\n",