Make animations for webpage

Create html versions of some animations to be uploaded to the webpage. Links from the pdf version of the book will go to these versions for readers who are only reading the pdf.

Note that make_html_on_master.py will copy everything from html_animations into build_html when creating webpage version.


In [ ]:
%matplotlib inline

In [ ]:
from IPython.display import FileLink

Acoustics

Animation to link from Acoustics.ipynb.


In [ ]:
from exact_solvers import acoustics_demos

In [ ]:
def make_bump_animation_html(numframes, file_name):
    video_html = acoustics_demos.bump_animation(numframes)
    f = open(file_name,'w')
    f.write('<html>\n')
    file_name = 'acoustics_bump_animation.html'
    descr = """<h1>Acoustics Bump Animation</h1>
        This animation is to accompany 
        <a href="http://www.clawpack.org/riemann_book/html/Acoustics.html">this
        notebook</a>,\n from the book <a
        href="http://www.clawpack.org/riemann_book/index.html">Riemann Problems and
        Jupyter Solutions</a>\n"""
    f.write(descr)
    f.write("<p>")
    f.write(video_html)
    print("Created ", file_name)
    f.close()

In [ ]:
file_name = 'html_animations/acoustics_bump_animation.html'
anim = make_bump_animation_html(numframes=50, file_name=file_name)
FileLink(file_name)

Burgers

Animations to link from Burgers.ipynb.


In [ ]:
from exact_solvers import burgers_demos

In [ ]:
from importlib import reload
reload(burgers_demos)

In [ ]:
video_html = burgers_demos.bump_animation(numframes = 50)
file_name = 'html_animations/burgers_animation0.html'
f = open(file_name,'w')
f.write('<html>\n')
descr = """<h1>Burgers' Equation Animation</h1>
    This animation is to accompany 
    <a href="http://www.clawpack.org/riemann_book/html/Burgers.html">this
    notebook</a>,\n from the book <a
    href="http://www.clawpack.org/riemann_book/index.html">Riemann Problems and
    Jupyter Solutions</a>\n
    <p>
    Burgers' equation with hump initial data, evolving into a shock wave
    followed by a rarefaction wave."""
f.write(descr)
f.write("<p>")
f.write(video_html)
print("Created ", file_name)
f.close()
FileLink(file_name)

In [ ]:
def make_burgers_animation_html(ql, qm, qr, file_name):
    video_html = burgers_demos.triplestate_animation(ql,qm,qr,numframes=50)
    f = open(file_name,'w')
    f.write('<html>\n')
    descr = """<h1>Burgers' Equation Animation</h1>
        This animation is to accompany 
        <a href="http://www.clawpack.org/riemann_book/html/Burgers.html">this
        notebook</a>,\n from the book <a
        href="http://www.clawpack.org/riemann_book/index.html">Riemann Problems and
        Jupyter Solutions</a>\n
        <p>
        Burgers' equation with three constant states as initial data,\n
        ql = %.1f, qm = %.1f, qr = %.1f""" % (ql,qm,qr)
    f.write(descr)
    f.write("<p>")
    f.write(video_html)
    print("Created ", file_name)
    f.close()

In [ ]:
file_name = 'html_animations/burgers_animation1.html'
make_burgers_animation_html(4., 2., 0., file_name)
FileLink(file_name)

In [ ]:
file_name = 'html_animations/burgers_animation2.html'
make_burgers_animation_html(4., -1.5, 0.5, file_name)
FileLink(file_name)

In [ ]:
file_name = 'html_animations/burgers_animation3.html'
make_burgers_animation_html(-1., 3., -2., file_name)
FileLink(file_name)

In [ ]: