CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: test
Views: 91872
1
from __future__ import print_function
2
import io
3
import IPython.nbformat as nbformat
4
import sys
5
from formatting import *
6
7
8
def merge_notebooks(outfile, filenames):
9
merged = None
10
added_appendix = False
11
for fname in filenames:
12
with io.open(fname, 'r', encoding='utf-8') as f:
13
nb = nbformat.read(f, nbformat.NO_CONVERT)
14
remove_formatting(nb)
15
if not added_appendix and fname[0:8] == 'Appendix':
16
remove_links_add_appendix(nb)
17
added_appendix = True
18
else:
19
remove_links(nb)
20
if merged is None:
21
merged = nb
22
else:
23
merged.cells.extend(nb.cells)
24
#merged.metadata.name += "_merged"
25
26
outfile.write(nbformat.writes(merged, nbformat.NO_CONVERT))
27
28
29
if __name__ == '__main__':
30
f = open('book.ipynb', 'w', encoding='utf-8')
31
'''merge_notebooks(
32
['../00_Preface.ipynb',
33
'../01_g-h_filter.ipynb',
34
'../Appendix_A_Installation.ipynb'])'''
35
36
merge_notebooks(f,
37
['../00-Preface.ipynb',
38
'../01-g-h-filter.ipynb',
39
'../02-Discrete-Bayes.ipynb',
40
'../03-Gaussians.ipynb',
41
'../04-One-Dimensional-Kalman-Filters.ipynb',
42
'../05-Multivariate-Gaussians.ipynb',
43
'../06-Multivariate-Kalman-Filters.ipynb',
44
'../07-Kalman-Filter-Math.ipynb',
45
'../08-Designing-Kalman-Filters.ipynb',
46
'../09-Nonlinear-Filtering.ipynb',
47
'../10-Unscented-Kalman-Filter.ipynb',
48
'../11-Extended-Kalman-Filters.ipynb',
49
'../12-Particle-Filters.ipynb',
50
'../13-Smoothing.ipynb',
51
'../14-Adaptive-Filtering.ipynb',
52
'../Appendix-A-Installation.ipynb',
53
'../Appendix-B-Symbols-and-Notations.ipynb',
54
'../Appendix-C-Walking-Through-KF-Code.ipynb',
55
'../Appendix-D-HInfinity-Filters.ipynb',
56
'../Appendix-E-Ensemble-Kalman-Filters.ipynb'])
57
58