Skip to content

Commit

Permalink
notebook to display html files from _plots
Browse files Browse the repository at this point in the history
  • Loading branch information
rjleveque committed Jan 25, 2023
1 parent b0441ee commit 756d5f9
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions fvmbook/chap6/wavepacket/show_html.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "3a702ffc-14cc-4a84-b319-4b5a53e51352",
"metadata": {},
"source": [
"# Viewer for Clawpack plots\n",
"\n",
"Useful if you are not able to open the html file due to security issues, e.g. on a Jupyter Hub."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65af1a93-6e69-4516-bee0-d8b8aa226751",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import HTML"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b15e0699-9de1-4afa-bd9a-4e07d0ccc3e5",
"metadata": {},
"outputs": [],
"source": [
"def show_element(elem, h=600):\n",
" embed_url = f\"<embed src='{elem}' width='100%%' height='{h}px' />\"\n",
" return HTML(embed_url)"
]
},
{
"cell_type": "markdown",
"id": "348586a9-f8a9-4c4b-8f7d-cae0f264095d",
"metadata": {},
"source": [
"## show a single png file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "25c7cc13-c8ca-4e36-aae8-93a7ca3033bd",
"metadata": {},
"outputs": [],
"source": [
"show_element('_plots/frame0000fig1.png')"
]
},
{
"cell_type": "markdown",
"id": "c610d1b6-2b65-4226-8bb5-e8b6cb7332ab",
"metadata": {},
"source": [
"## show the html wrapper with the figure:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "039758eb-0837-47b7-b069-21450243a6e4",
"metadata": {},
"outputs": [],
"source": [
"show_element('_plots/frame0000fig1.html')"
]
},
{
"cell_type": "markdown",
"id": "867c51ec-2fe3-4e60-906f-90c24132c10e",
"metadata": {},
"source": [
"## show an animation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91984ccb-aaeb-44bd-9701-5fc42ca4fe7c",
"metadata": {},
"outputs": [],
"source": [
"show_element('_plots/movie_fig1.html')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 756d5f9

Please sign in to comment.