Skip to content

Commit

Permalink
docs: adapt tutorial to new tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Oct 11, 2024
1 parent 55f43e0 commit 0ca0f6a
Showing 1 changed file with 45 additions and 19 deletions.
64 changes: 45 additions & 19 deletions docs/user-guide/amor/amor-reduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,32 @@
"source": [
"## Computing sample reflectivity\n",
"\n",
"We now compute the sample reflectivity from 3 runs that used different sample rotation angles.\n",
"The different rotation angles cover different ranges in $Q$."
"We now compute the sample reflectivity from 4 runs that used different sample rotation angles.\n",
"The measurements at different rotation angles cover different ranges of $Q$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this tutorial we use some Amor data files we have received.\n",
"The file paths to the tutorial files are obtained by calling:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"amor.data.amor_sample_run(608)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When you encounter `amor.data.amor_sample_run` you should imagining replacing that with a path to your own dataset."
]
},
{
Expand All @@ -148,17 +172,25 @@
"outputs": [],
"source": [
"runs = {\n",
" '608': sc.scalar(0.85, unit='deg'),\n",
" '609': sc.scalar(2.25, unit='deg'),\n",
" '610': sc.scalar(3.65, unit='deg'),\n",
" '611': sc.scalar(5.05, unit='deg'),\n",
" run_number: {\n",
" # The sample rotation values in the files are slightly off, so we replace\n",
" # them with corrected values.\n",
" SampleRotation[SampleRun]: sc.scalar(sample_rotation_angle, unit='deg'),\n",
" Filename[SampleRun]: amor.data.amor_sample_run(run_number),\n",
" }\n",
" for run_number, sample_rotation_angle in (\n",
" ('608', 0.85),\n",
" ('609', 2.25),\n",
" ('610', 3.65),\n",
" ('611', 5.05),\n",
" )\n",
"}\n",
"\n",
"results = {}\n",
"for file, angle in runs.items():\n",
" workflow[Filename[SampleRun]] = amor.data.amor_sample_run(file)\n",
" workflow[SampleRotation[SampleRun]] = angle\n",
" results[file] = workflow.compute(ReflectivityOverQ).hist()\n",
"for run_number, params in runs.items():\n",
" workflow[Filename[SampleRun]] = params[Filename[SampleRun]]\n",
" workflow[SampleRotation[SampleRun]] = params[SampleRotation[SampleRun]]\n",
" results[run_number] = workflow.compute(ReflectivityOverQ).hist()\n",
"\n",
"sc.plot(results, norm='log', vmin=1e-4)"
]
Expand Down Expand Up @@ -202,8 +234,8 @@
"metadata": {},
"outputs": [],
"source": [
"workflow[Filename[SampleRun]] = amor.data.amor_sample_run(608)\n",
"workflow[SampleRotation[SampleRun]] = sc.scalar(0.85, unit='deg')\n",
"workflow[Filename[SampleRun]] = runs['608'][Filename[SampleRun]]\n",
"workflow[SampleRotation[SampleRun]] = runs['608'][SampleRotation[SampleRun]]\n",
"workflow.compute(ReflectivityDiagnosticsView)"
]
},
Expand Down Expand Up @@ -349,13 +381,7 @@
"\n",
"datasets = orso_datasets_from_measurements(\n",
" workflow,\n",
" # `orso_datasets_from_measurements` expects a dictionary with filenames as keys\n",
" # and a dictionary of parameters as the value.\n",
" # In this case the only file-dependent parameter we want to set is the sample rotation.\n",
" {\n",
" amor.data.amor_sample_run(run): {SampleRotation[SampleRun]: value}\n",
" for run, value in runs.items()\n",
" },\n",
" runs.values(),\n",
" # Optionally scale the curves to overlap using `scale_reflectivity_curves_to_overlap`\n",
" scale_to_overlap=True\n",
")"
Expand Down

0 comments on commit 0ca0f6a

Please sign in to comment.