From c2d0b0a8a9606cbcf0be6b06657240aeb73e6c57 Mon Sep 17 00:00:00 2001 From: Atharva Arya <55894364+atharva-2001@users.noreply.github.com> Date: Fri, 30 Jul 2021 00:27:01 +0530 Subject: [PATCH] Adding Convergence Plots to the Documentation (#1753) * Add convergence_plots notebook to toctree * Clear output in convergence_plots notebook * [build docs] --- docs/io/visualization/convergence_plot.ipynb | 649 +------------------ docs/io/visualization/index.rst | 1 + 2 files changed, 16 insertions(+), 634 deletions(-) diff --git a/docs/io/visualization/convergence_plot.ipynb b/docs/io/visualization/convergence_plot.ipynb index 7524fe90e96..42f700dbdd8 100644 --- a/docs/io/visualization/convergence_plot.ipynb +++ b/docs/io/visualization/convergence_plot.ipynb @@ -24,7 +24,9 @@ "metadata": {}, "source": [ "
\n", - " \n", + "\n", + "Note\n", + " \n", "You only need to include `export_cplots=True` in the `run_tardis` function when you want to share the notebook. The function shows the plot using the Plotly `notebook_connected` renderer, which helps display the plot online. You don't need to do it when running the notebook locally.\n", "\n", "
" @@ -32,142 +34,12 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "ba7cc7d2", "metadata": { "scrolled": false }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "9e8c4cf955fe459a903c206b12dce519", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "VBox(children=(FigureWidget({\n", - " 'data': [{'type': 'scatter', 'uid': '6300bc97-3326-433b-9702-37a6cef7ba32', …" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "from tardis import run_tardis\n", "sim = run_tardis('tardis_example.yml', export_cplots=True)" @@ -184,136 +56,20 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "48768471", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "sim.cplots.plasma_plot.show(renderer=\"notebook_connected\")" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "9db6b395", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "sim.cplots.t_inner_luminosities_plot.show(renderer=\"notebook_connected\")" ] @@ -356,142 +112,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "9109967e", "metadata": { "scrolled": false }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a5d948f93c5e46fba408974c41901e33", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "VBox(children=(FigureWidget({\n", - " 'data': [{'type': 'scatter', 'uid': '708836fc-9431-4f4d-b65d-64e3ce7d217f', …" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "sim = run_tardis(\n", " \"tardis_example.yml\",\n", @@ -532,142 +158,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "548990c8", "metadata": { "scrolled": false }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "0f661eefdb7b472b86353beeaae2693e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "VBox(children=(FigureWidget({\n", - " 'data': [{'type': 'scatter', 'uid': 'ad54a6db-bbf4-4c68-9e0d-9cfb0ed1b9ad', …" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "sim = run_tardis(\n", " \"tardis_example.yml\",\n", @@ -704,127 +200,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "6ceaaa1e", "metadata": { "scrolled": false }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Help on class ConvergencePlots in module tardis.visualization.tools.convergence_plot:\n", - "\n", - "class ConvergencePlots(builtins.object)\n", - " | ConvergencePlots(iterations, **kwargs)\n", - " | \n", - " | Create and update convergence plots for visualizing convergence of the simulation.\n", - " | \n", - " | Parameters\n", - " | ----------\n", - " | iterations : int\n", - " | iteration number\n", - " | **kwargs : dict, optional\n", - " | Additional keyword arguments. These arguments are defined in the Other Parameters section.\n", - " | \n", - " | Other Parameters\n", - " | ----------------\n", - " | plasma_plot_config : dict, optional\n", - " | Dictionary used to override default plot properties of plasma plots.\n", - " | t_inner_luminosities_config : dict, optional\n", - " | Dictionary used to override default plot properties of the inner boundary temperature and luminosity plots.\n", - " | plasma_cmap : str, default: 'jet', optional\n", - " | String defining the cmap used in plasma plots.\n", - " | t_inner_luminosities_colors : str or list, optional\n", - " | String defining cmap for luminosity and inner boundary temperature plot.\n", - " | The list can be a list of colors in rgb, hex or css-names format as well.\n", - " | export_cplots : bool, default: False, optional\n", - " | If True, plots are displayed again using the ``notebook_connected`` renderer. This helps\n", - " | to display the plots in the documentation or in platforms like nbviewer.\n", - " | \n", - " | Notes\n", - " | -----\n", - " | When overriding plot's configuration using the ``plasma_plot_config`` and the\n", - " | ``t_inner_luminosities_config`` dictionaries, data related properties are\n", - " | applied equally accross all traces.\n", - " | The dictionary should have a structure like that of ``plotly.graph_objs.FigureWidget.to_dict()``,\n", - " | for more information please see https://plotly.com/python/figure-structure/\n", - " | \n", - " | Methods defined here:\n", - " | \n", - " | __init__(self, iterations, **kwargs)\n", - " | Initialize self. See help(type(self)) for accurate signature.\n", - " | \n", - " | build(self, display_plot=True)\n", - " | Create empty convergence plots and display them.\n", - " | \n", - " | Parameters\n", - " | ----------\n", - " | display_plot : bool, default: True, optional\n", - " | Displays empty plots.\n", - " | \n", - " | create_plasma_plot(self)\n", - " | Create an empty plasma plot.\n", - " | \n", - " | create_t_inner_luminosities_plot(self)\n", - " | Create an empty t_inner and luminosity plot.\n", - " | \n", - " | fetch_data(self, name=None, value=None, item_type=None)\n", - " | Fetch data from the Simulation class.\n", - " | \n", - " | Parameters\n", - " | ----------\n", - " | name : string\n", - " | name of the data\n", - " | value : string or array\n", - " | string or an array of quantities\n", - " | item_type : string\n", - " | either iterable or value\n", - " | \n", - " | override_plot_parameters(self, fig, parameters)\n", - " | Override default plot properties.\n", - " | \n", - " | Any property inside the data dictionary is however, applied equally across all traces.\n", - " | This means trace-specific data properties can't be changed using this function.\n", - " | \n", - " | Parameters\n", - " | ----------\n", - " | fig : go.FigureWidget\n", - " | FigureWidget object to be updated\n", - " | parameters : dict\n", - " | Dictionary used to update the default plot style.\n", - " | \n", - " | update(self, export_cplots=False, last=False)\n", - " | Update the convergence plots every iteration.\n", - " | \n", - " | Parameters\n", - " | ----------\n", - " | export_cplots : bool, default: False, optional\n", - " | Displays the convergence plots again using plotly's ``notebook_connected`` renderer.\n", - " | This helps to display the plots in notebooks when shared on platforms like nbviewer.\n", - " | Please see https://plotly.com/python/renderers/ for more information.\n", - " | last : bool\n", - " | True if it's last iteration.\n", - " | \n", - " | update_plasma_plots(self)\n", - " | Update plasma convergence plots every iteration.\n", - " | \n", - " | update_t_inner_luminosities_plot(self)\n", - " | Update the t_inner and luminosity convergence plots every iteration.\n", - " | \n", - " | ----------------------------------------------------------------------\n", - " | Data descriptors defined here:\n", - " | \n", - " | __dict__\n", - " | dictionary for instance variables (if defined)\n", - " | \n", - " | __weakref__\n", - " | list of weak references to the object (if defined)\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "from tardis.visualization import ConvergencePlots\n", "help(ConvergencePlots)" diff --git a/docs/io/visualization/index.rst b/docs/io/visualization/index.rst index 601e55d64fa..1a7cfecae84 100644 --- a/docs/io/visualization/index.rst +++ b/docs/io/visualization/index.rst @@ -13,6 +13,7 @@ diagnostic visualizations. :maxdepth: 2 sdec_plot + convergence_plot TARDIS Widgets (Graphical User Interfaces)