{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to Generate Custom Abundance Widget" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates how to generate and display Custom Abundance Widget." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, import `CustomAbundanceWidget` module from `visualization` subpackage to create the widget." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tardis.visualization import CustomAbundanceWidget" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize the GUI " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are four ways to generate the widget. You can generate it from `.yml`/`.csvy` configuration files before running any simulation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using a YAML file" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widget = CustomAbundanceWidget.from_yml(\"tardis_example.yml\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using a CSVY file" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# widget = CustomAbundanceWidget.from_csvy(\"demo.csvy\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, you can generate the widget after the simulation from a Simulation instance or a saved simulation (HDF file)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using a Simulation object" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# sim = run_tardis(\"tardis_example.yml\")\n", "# widget = CustomAbundanceWidget.from_simulation(sim)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using a HDF file" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# widget = CustomAbundanceWidget.from_hdf(\"demo.h5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Display the GUI" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "No matter which way you use to initialize the widget, you can call `.display()` to display the GUI easily." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widget.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The image below is just a screenshot of the GUI for a demonstration purpose. If you want to interact with the GUI, please run the code in the notebook.\n", "\n", "![Custom Abundance Widget Demo](../images/custom_abundance_widget.png)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "42180fb7a26743e791b9c1155ac51f7e87399be241c0afbd4c0781c11826afd9" }, "kernelspec": { "display_name": "Python 3", "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.7.10" } }, "nbformat": 4, "nbformat_minor": 2 }