Skip to content

Commit

Permalink
Update decay radiation notebook: fix execution counts and enhance out…
Browse files Browse the repository at this point in the history
…put formatting
  • Loading branch information
wkerzendorf committed Feb 25, 2025
1 parent d0bc0dc commit 844eb3e
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 480 deletions.
165 changes: 151 additions & 14 deletions docs/how-to/high-energy/decay_radiation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,44 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/wkerzend/python/tardis/tardis/__init__.py:20: UserWarning: Astropy is already imported externally. Astropy should be imported after TARDIS.\n",
" warnings.warn(\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bf9190eb231746b6b09f793faa4f11c7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Iterations: 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a438d909701342eea6c7b9247b0cfee8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Packets: 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Step 1: Setup and Imports\n",
"import astropy.units as u\n",
Expand Down Expand Up @@ -402,7 +439,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"id": "e8b9ad2b",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -458,7 +495,7 @@
"28 56 1.241517e+50"
]
},
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -490,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 7,
"id": "17b27519",
"metadata": {},
"outputs": [
Expand All @@ -502,7 +539,7 @@
"Name: (28, 56, 12), dtype: float64"
]
},
"execution_count": 12,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -522,7 +559,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 8,
"id": "218f80c6",
"metadata": {},
"outputs": [],
Expand All @@ -545,21 +582,121 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 11,
"id": "bc09e086",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"791 μs ± 12.3 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n"
]
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>0</th>\n",
" </tr>\n",
" <tr>\n",
" <th>atomic_number</th>\n",
" <th>mass_number</th>\n",
" <th>channel_id</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>28</th>\n",
" <th>56</th>\n",
" <th>15</th>\n",
" <td>4.144926e+53</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"10\" valign=\"top\">27</th>\n",
" <th rowspan=\"10\" valign=\"top\">56</th>\n",
" <th>51</th>\n",
" <td>8.667681e+52</td>\n",
" </tr>\n",
" <tr>\n",
" <th>62</th>\n",
" <td>1.372503e+52</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51</th>\n",
" <td>8.489408e+52</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>4.580369e+52</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>1.940563e+49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>1.228449e+49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>9.842633e+48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>8.917336e+48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>8.316877e+48</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>10000 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" 0\n",
"atomic_number mass_number channel_id \n",
"28 56 15 4.144926e+53\n",
"27 56 51 8.667681e+52\n",
" 62 1.372503e+52\n",
" 51 8.489408e+52\n",
" 40 4.580369e+52\n",
"... ...\n",
" 78 1.940563e+49\n",
" 41 1.228449e+49\n",
" 35 9.842633e+48\n",
" 35 8.917336e+48\n",
" 37 8.316877e+48\n",
"\n",
"[10000 rows x 1 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%timeit\n",
"x.sample(weights=x[0], replace=True, n=10000)"
"x.sample(weights=x[0], n=10000)"
]
},
{
Expand Down
Loading

0 comments on commit 844eb3e

Please sign in to comment.