-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notebook to display html files from _plots
- Loading branch information
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |