Skip to content

Commit

Permalink
FEAT: visualize 1D projection of Δ** subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Feb 19, 2025
1 parent 87c655a commit e92b1a1
Showing 1 changed file with 57 additions and 7 deletions.
64 changes: 57 additions & 7 deletions docs/intensity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,47 @@
"plt.close(fig)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"mystnb": {
"code_prompt_show": "σ₃ vs σ₁ plot for σ₃ projection"
},
"tags": [
"hide-input",
"scroll-input",
"hide-output"
]
},
"outputs": [],
"source": [
"grid_sample_31 = generate_meshgrid_sample(\n",
" model.decay, resolution=1_000, x_mandelstam=3, y_mandelstam=1\n",
")\n",
"grid_sample_31 = transformer(grid_sample_31)\n",
"INTENSITIES_31 = intensity_func(grid_sample_31)\n",
"INTENSITY_INTEGRAL_31 = jnp.nansum(INTENSITIES_31)\n",
"NORMALIZED_INTENSITIES_31 = INTENSITIES_31 / INTENSITY_INTEGRAL_31\n",
"np.testing.assert_almost_equal(jnp.nansum(NORMALIZED_INTENSITIES_31), 1.0)\n",
"\n",
"%config InlineBackend.figure_formats = ['png']\n",
"fig, ax = plt.subplots()\n",
"ax.set_xlabel(\"$\" + s3_label[10:])\n",
"ax.set_ylabel(\"$\" + s1_label[10:])\n",
"mesh = ax.pcolormesh(\n",
" grid_sample_31[\"sigma3\"],\n",
" grid_sample_31[\"sigma1\"],\n",
" NORMALIZED_INTENSITIES_31,\n",
")\n",
"c_bar = fig.colorbar(mesh, ax=ax)\n",
"c_bar.ax.set_ylabel(\"Normalized intensity\")\n",
"plt.show(fig)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -352,10 +393,10 @@
"%config InlineBackend.figure_formats = ['svg']\n",
"plt.rcdefaults()\n",
"use_mpl_latex_fonts()\n",
"plt.rc(\"font\", size=18)\n",
"fig, (ax1, ax2) = plt.subplots(\n",
" ncols=2,\n",
" figsize=(12, 5),\n",
"plt.rc(\"font\", size=16)\n",
"fig, (ax1, ax2, ax3) = plt.subplots(\n",
" ncols=3,\n",
" figsize=(12, 3.5),\n",
" tight_layout=True,\n",
" sharey=True,\n",
")\n",
Expand All @@ -369,19 +410,28 @@
"x, y = X[0], Y[:, 0]\n",
"ax1.fill(x, jnp.nansum(NORMALIZED_INTENSITIES, axis=0), alpha=0.3)\n",
"ax2.fill(y, jnp.nansum(NORMALIZED_INTENSITIES, axis=1), alpha=0.3)\n",
"ax3.fill(y, jnp.nansum(NORMALIZED_INTENSITIES_31, axis=0), alpha=0.3)\n",
"\n",
"original_parameters = dict(intensity_func.parameters)\n",
"for label, identifier in zip(subsystem_labels, subsystem_identifiers):\n",
" label = f\"${label}$\"\n",
" sub_intensities = compute_sub_function(intensity_func, grid_sample, [identifier])\n",
" sub_intensities /= INTENSITY_INTEGRAL\n",
" sub_intensities = (\n",
" compute_sub_function(intensity_func, grid_sample, [identifier])\n",
" / INTENSITY_INTEGRAL\n",
" )\n",
" sub_intensities_31 = (\n",
" compute_sub_function(intensity_func, grid_sample_31, [identifier])\n",
" / INTENSITY_INTEGRAL_31\n",
" )\n",
" ax1.plot(x, jnp.nansum(sub_intensities, axis=0), label=label)\n",
" ax2.plot(y, jnp.nansum(sub_intensities, axis=1), label=label)\n",
" ax3.plot(y, jnp.nansum(sub_intensities_31, axis=0), label=label)\n",
" del sub_intensities\n",
" intensity_func.update_parameters(original_parameters)\n",
"ax1.set_ylim(0, None)\n",
"ax2.set_ylim(0, None)\n",
"ax2.legend()\n",
"ax3.set_ylim(0, None)\n",
"ax3.legend()\n",
"plt.savefig(\"_images/intensity-distributions-1D.svg\")\n",
"plt.show()"
]
Expand Down

0 comments on commit e92b1a1

Please sign in to comment.