{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Montecarlo Packet Visualization"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"This visualization tool plots the `RPackets` that are generated by the [Montecarlo](https://tardis-sn.github.io/tardis/physics/montecarlo/index.html) method and creates an animated plot that contains the packet trajectories as they move away from the photosphere.\n",
"The properties of individual RPackets are taken from the [rpacket_tracker](https://tardis-sn.github.io/tardis/io/output/rpacket_tracking.html). "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tardis import run_tardis\n",
"from tardis.io.configuration.config_reader import Configuration\n",
"from tardis.io.atom_data.util import download_atom_data\n",
"import plotly.express as px\n",
"import plotly.graph_objects as go\n",
"import math\n",
"import pandas as pd\n",
"import numpy as np\n",
"import random"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Download atom data\n",
"download_atom_data('kurucz_cd23_chianti_H_He')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Reading the Configuration stored in `tardis_example.yml` into config\n",
"\n",
"config = Configuration.from_yaml(\"tardis_example.yml\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# changing config file for plotting 15 packets\n",
"\n",
"config[\"montecarlo\"][\"tracking\"][\"track_rpacket\"]=True\n",
"config[\"montecarlo\"][\"seed\"]= 457\n",
"config[\"montecarlo\"][\"no_of_packets\"]=10\n",
"config[\"montecarlo\"][\"iterations\"]=1\n",
"config[\"montecarlo\"][\"last_no_of_packets\"]=15\n",
"config[\"montecarlo\"][\"no_of_virtual_packets\"]=3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"sim = run_tardis(config, show_progress_bars=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# accessing the rpacket_tracker dataframe\n",
"sim.transport.transport_state.rpacket_tracker_df"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Finding packet coordinates\n",
"\n",
"\\\n",
"\n",
"\n",
"
The diagram above shows the packet trajectory as it starts from photosphere `P0` and continues to move along the subsequent points `P1`, `P2`, and so on.\n",
"\n",
"