Skip to content

Commit

Permalink
docs: add better plot and some text to the notebook example
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Oct 24, 2023
1 parent 0dc7266 commit 302892a
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions docs/examples/amor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"metadata": {},
"outputs": [],
"source": [
"normalized = pipeline.compute(NormalizedIOverQ)\n",
"normalized.plot(norm='log') + normalized.mean('detector_number').plot(norm='log')\n"
"# Compute I over Q and the standard deviation of Q\n",
"ioq, qstd = pipeline.compute((NormalizedIOverQ, QStd)).values()"
]
},
{
Expand All @@ -47,14 +47,24 @@
"metadata": {},
"outputs": [],
"source": [
"# Diagnostics plot\n",
"(pipeline.compute(ThetaData[Sample])\n",
" .bins.concat('detector_number')\n",
" .hist(\n",
" theta=sc.linspace(dim='theta', start=0.0, stop=1.2, num=165, unit='deg').to(unit='rad'),\n",
" wavelength=sc.linspace(dim='wavelength', start=0, stop=15.0, num=165, unit='angstrom'),\n",
" )\n",
" .plot())\n"
"import matplotlib.pyplot as plt\n",
"\n",
"fig = plt.figure(figsize=(5, 7))\n",
"ax1 = fig.add_axes([0, 0.55, 1.0, 0.45])\n",
"ax2 = fig.add_axes([0, 0.0, 1.0, 0.45])\n",
"cax = fig.add_axes([1.05, 0.55, 0.03, 0.45])\n",
"fig1 = ioq.plot(norm='log', ax=ax1, cax=cax, grid=True)\n",
"fig2 = ioq.mean('detector_number').plot(norm='log', ax=ax2, grid=True)\n",
"fig1.canvas.xrange = fig2.canvas.xrange\n",
"fig1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Make a $(\\lambda, \\theta)$ map\n",
"A good sanity check is to create a two-dimensional map of the counts in $\\lambda$ and $\\theta$ bins. To achieve this, we request the `ThetaData` from the pipeline. In the graph above we can see that `WavelengthData` is required to compute `ThetaData`, therefore it is also present in `ThetaData` so we don't need to require it separately."
]
},
{
Expand All @@ -63,8 +73,21 @@
"metadata": {},
"outputs": [],
"source": [
"res = pipeline.compute((NormalizedIOverQ, QStd))\n",
"res[QStd].plot()"
"from essreflectometry.reflectometry.types import ThetaData\n",
"pipeline.compute(ThetaData[Sample])\\\n",
" .bins.concat('detector_number')\\\n",
" .hist(\n",
" theta=sc.linspace(dim='theta', start=0.0, stop=1.2, num=165, unit='deg').to(unit='rad'),\n",
" wavelength=sc.linspace(dim='wavelength', start=0, stop=15.0, num=165, unit='angstrom'),\n",
" )\\\n",
" .plot()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This plot can be used to check if the value of the sample rotation angle $\\omega$ is correct. The bright triangles should be pointing back to the origin $\\lambda = \\theta = 0$."
]
}
],
Expand Down

0 comments on commit 302892a

Please sign in to comment.