From 0ca0f6a9209c93ac00c4033142173cc088ccdc6e Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Fri, 11 Oct 2024 15:21:29 +0200 Subject: [PATCH] docs: adapt tutorial to new tool --- docs/user-guide/amor/amor-reduction.ipynb | 64 ++++++++++++++++------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/docs/user-guide/amor/amor-reduction.ipynb b/docs/user-guide/amor/amor-reduction.ipynb index 3a15367e..33e13c69 100644 --- a/docs/user-guide/amor/amor-reduction.ipynb +++ b/docs/user-guide/amor/amor-reduction.ipynb @@ -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." ] }, { @@ -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)" ] @@ -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)" ] }, @@ -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", ")"