|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | 3 | { |
| 4 | + "attachments": {}, |
4 | 5 | "cell_type": "markdown", |
5 | 6 | "id": "cb1a9b1f-5495-417a-a21b-10f1f6132e56", |
6 | 7 | "metadata": {}, |
|
11 | 12 | ] |
12 | 13 | }, |
13 | 14 | { |
| 15 | + "attachments": {}, |
14 | 16 | "cell_type": "markdown", |
15 | 17 | "id": "36b6b654-fbc3-4124-ba7c-3340225a3356", |
16 | 18 | "metadata": {}, |
|
19 | 21 | ] |
20 | 22 | }, |
21 | 23 | { |
| 24 | + "attachments": {}, |
22 | 25 | "cell_type": "markdown", |
23 | 26 | "id": "77205b12-3f0b-4e8a-90b5-c2964d4cb34c", |
24 | 27 | "metadata": {}, |
|
29 | 32 | ] |
30 | 33 | }, |
31 | 34 | { |
| 35 | + "attachments": {}, |
32 | 36 | "cell_type": "markdown", |
33 | 37 | "id": "be649cc3-56f7-4ab9-b2a8-1fb6235e6493", |
34 | 38 | "metadata": {}, |
|
39 | 43 | ] |
40 | 44 | }, |
41 | 45 | { |
| 46 | + "attachments": {}, |
42 | 47 | "cell_type": "markdown", |
43 | 48 | "id": "93503d83-1b11-4c91-8155-3f51a28ab6a7", |
44 | 49 | "metadata": {}, |
|
54 | 59 | "Those **I** values are stored as a 2D dataset of shape (400, 1000) in the `intensities.npy` file.\n", |
55 | 60 | "The **q** values are stored in the `q.txt` file.\n", |
56 | 61 | "\n", |
57 | | - "At first, only the buffer is passing through the capillary, then sample+buffer and finally buffer again." |
58 | | - ] |
59 | | - }, |
60 | | - { |
61 | | - "cell_type": "markdown", |
62 | | - "id": "530ef2d2-5910-447f-831a-b6029e4a1beb", |
63 | | - "metadata": {}, |
64 | | - "source": [ |
| 62 | + "At first, only the buffer is passing through the capillary, then sample + buffer and finally buffer again.\n", |
| 63 | + "\n", |
65 | 64 | "The goal is to extract the intensity contributed by the sample.\n", |
66 | 65 | "The steps are:\n", |
67 | 66 | "\n", |
68 | | - "0. Separate integrated intensities corresponding to buffer+sample from those corresponding to buffer only\n", |
69 | | - "0. Estimate the buffer and the sample+buffer intensities by averaging the selected integrated intensities\n", |
70 | | - "0. Remove the buffer background from sample+buffer" |
| 67 | + "1. Separate integrated intensities corresponding to buffer+sample from those corresponding to buffer only\n", |
| 68 | + "2. Estimate the buffer and the sample + buffer intensities by averaging the selected integrated intensities\n", |
| 69 | + "3. Remove the buffer background from sample + buffer" |
71 | 70 | ] |
72 | 71 | }, |
73 | 72 | { |
| 73 | + "attachments": {}, |
74 | 74 | "cell_type": "markdown", |
75 | 75 | "id": "98afc9af-cdb1-4bf7-8c93-c0d1a7fb2a8e", |
76 | 76 | "metadata": {}, |
|
85 | 85 | "metadata": {}, |
86 | 86 | "outputs": [], |
87 | 87 | "source": [ |
88 | | - "import numpy" |
| 88 | + "import numpy as np" |
89 | 89 | ] |
90 | 90 | }, |
91 | 91 | { |
| 92 | + "attachments": {}, |
92 | 93 | "cell_type": "markdown", |
93 | 94 | "id": "d2c55c1c-c588-40e5-ae01-c476a1c2616e", |
94 | 95 | "metadata": {}, |
|
110 | 111 | ] |
111 | 112 | }, |
112 | 113 | { |
| 114 | + "attachments": {}, |
113 | 115 | "cell_type": "markdown", |
114 | 116 | "id": "c70d852d-470d-45d1-adc7-a6a23feb5854", |
115 | 117 | "metadata": {}, |
|
138 | 140 | "metadata": {}, |
139 | 141 | "outputs": [], |
140 | 142 | "source": [ |
141 | | - "# Plot intensities\n", |
| 143 | + "# Plot the intensities\n", |
142 | 144 | "import matplotlib.colors as colors\n", |
143 | 145 | "\n", |
144 | 146 | "fig = plt.figure()\n", |
145 | 147 | "plt.imshow(intensities, norm=colors.LogNorm(), aspect=\"auto\")\n", |
146 | | - "\n", |
147 | | - "# Note: with latest version of matplotlib:\n", |
| 148 | + " \n", |
| 149 | + "# Note: with latest version of matplotlib: \n", |
148 | 150 | "# plt.imshow(intensities, norm=\"log\", aspect=\"auto\")" |
149 | 151 | ] |
150 | 152 | }, |
|
162 | 164 | ] |
163 | 165 | }, |
164 | 166 | { |
| 167 | + "attachments": {}, |
165 | 168 | "cell_type": "markdown", |
166 | 169 | "id": "de96e9c6-5421-4d74-8b4d-9da68716cac2", |
167 | 170 | "metadata": {}, |
|
170 | 173 | ] |
171 | 174 | }, |
172 | 175 | { |
| 176 | + "attachments": {}, |
173 | 177 | "cell_type": "markdown", |
174 | 178 | "id": "4961fad5-fe0b-4d6e-9663-228c630fb60c", |
175 | 179 | "metadata": { |
|
207 | 211 | ] |
208 | 212 | }, |
209 | 213 | { |
| 214 | + "attachments": {}, |
210 | 215 | "cell_type": "markdown", |
211 | 216 | "id": "9c2026c6-a04a-4ad5-92a4-5e473ce3dd3b", |
212 | 217 | "metadata": {}, |
213 | 218 | "source": [ |
214 | | - "Note: This is not meaningful, the buffer and sample+buffer cases should be separated." |
| 219 | + "Note: This is not meaningful, the buffer and sample + buffer cases should be separated." |
215 | 220 | ] |
216 | 221 | }, |
217 | 222 | { |
| 223 | + "attachments": {}, |
218 | 224 | "cell_type": "markdown", |
219 | 225 | "id": "3adff22d-4835-4f3c-935f-a06f71372e01", |
220 | 226 | "metadata": {}, |
|
242 | 248 | "outputs": [], |
243 | 249 | "source": [ |
244 | 250 | "fig = plt.figure()\n", |
245 | | - "plt.plot(frames_intensities)\n", |
| 251 | + "plt.plot(intensities_per_frame)\n", |
246 | 252 | "plt.xlabel(\"Frame ID\")\n", |
247 | 253 | "plt.ylabel(\"I\")" |
248 | 254 | ] |
249 | 255 | }, |
250 | 256 | { |
| 257 | + "attachments": {}, |
251 | 258 | "cell_type": "markdown", |
252 | 259 | "id": "37949d27-0a36-488b-b230-df7765a6f286", |
253 | 260 | "metadata": {}, |
|
256 | 263 | ] |
257 | 264 | }, |
258 | 265 | { |
| 266 | + "attachments": {}, |
259 | 267 | "cell_type": "markdown", |
260 | 268 | "id": "de3ad40e-97b1-4ef9-aae7-168117aad0a0", |
261 | 269 | "metadata": { |
262 | 270 | "tags": [] |
263 | 271 | }, |
264 | 272 | "source": [ |
265 | | - "### Separate sample+buffer from buffer only\n", |
| 273 | + "### Separate sample + buffer from buffer only\n", |
266 | 274 | "\n", |
267 | | - "Select buffer and sample+buffer intensities by using a threshold over `intensities_summed`" |
| 275 | + "Select buffer and sample + buffer intensities by using a threshold over `intensities_summed`." |
268 | 276 | ] |
269 | 277 | }, |
270 | 278 | { |
|
298 | 306 | ] |
299 | 307 | }, |
300 | 308 | { |
| 309 | + "attachments": {}, |
301 | 310 | "cell_type": "markdown", |
302 | 311 | "id": "51fa7126-33b6-4fb2-8fa9-0c5b427325ba", |
303 | 312 | "metadata": {}, |
304 | 313 | "source": [ |
305 | | - "### Average sample+buffer and buffer intensities\n", |
| 314 | + "### Average sample + buffer and buffer intensities\n", |
306 | 315 | "\n", |
307 | 316 | "Compute the average of azimuthal integrations of `buffer` for each `q`." |
308 | 317 | ] |
|
318 | 327 | ] |
319 | 328 | }, |
320 | 329 | { |
| 330 | + "attachments": {}, |
321 | 331 | "cell_type": "markdown", |
322 | 332 | "id": "93b16a5e-466a-4a7f-8da5-6b591bf6c3ce", |
323 | 333 | "metadata": {}, |
|
344 | 354 | "source": [ |
345 | 355 | "fig = plt.figure()\n", |
346 | 356 | "plt.plot(q, buffer_mean, 'black', q, sample_buffer_mean, 'red')\n", |
347 | | - "plt.title(\"buffer and sample+buffer average\")\n", |
| 357 | + "plt.title(\"buffer and sample + buffer average\")\n", |
348 | 358 | "plt.xlabel(\"q\")\n", |
349 | 359 | "plt.ylabel(\"I\")\n", |
350 | 360 | "plt.yscale(\"log\")" |
351 | 361 | ] |
352 | 362 | }, |
353 | 363 | { |
| 364 | + "attachments": {}, |
354 | 365 | "cell_type": "markdown", |
355 | 366 | "id": "13476124-7e14-4a6a-a49f-1f3b02dd1a6f", |
356 | 367 | "metadata": {}, |
|
383 | 394 | ] |
384 | 395 | }, |
385 | 396 | { |
| 397 | + "attachments": {}, |
386 | 398 | "cell_type": "markdown", |
387 | 399 | "id": "dbc81e5b-19b4-4aac-8648-7e8b67f3c9e0", |
388 | 400 | "metadata": {}, |
|
395 | 407 | "```python\n", |
396 | 408 | "# Part I\n", |
397 | 409 | "\n", |
398 | | - "import numpy\n", |
| 410 | + "import numpy as np\n", |
399 | 411 | "\n", |
400 | 412 | "# Load data\n", |
401 | | - "intensities = numpy.load(\"intensities.npy\")\n", |
402 | | - "q = numpy.loadtxt(\"q.txt\")\n", |
| 413 | + "intensities = np.load(\"intensities.npy\")\n", |
| 414 | + "q = np.loadtxt(\"q.txt\")\n", |
403 | 415 | "\n", |
404 | 416 | "# Part II\n", |
405 | 417 | "\n", |
406 | 418 | "# Average of all azimuthal integrations\n", |
407 | | - "intensities_mean = numpy.mean(intensities, axis=0)\n", |
| 419 | + "intensities_mean = np.mean(intensities, axis=0)\n", |
408 | 420 | "\n", |
409 | 421 | "# Summed intensity of each azimuthal integration\n", |
410 | | - "frames_intensities = numpy.sum(intensities, axis=1)\n", |
| 422 | + "intensities_per_frame = np.sum(intensities, axis=1)\n", |
411 | 423 | "\n", |
412 | 424 | "# Part III\n", |
413 | 425 | "\n", |
414 | | - "# Separate sample+buffer from buffer only\n", |
| 426 | + "# Separate sample + buffer from buffer only\n", |
415 | 427 | "# 1. with thresholds\n", |
416 | | - "buffer_mask = frames_intensities < 32500\n", |
| 428 | + "buffer_mask = intensities_per_frame < 32500\n", |
417 | 429 | "buffer = intensities[buffer_mask]\n", |
418 | 430 | "sample_buffer_mask = frames_intensities > 33000\n", |
419 | 431 | "sample_buffer = intensities[sample_buffer_mask]\n", |
420 | 432 | "# 2. With slicing\n", |
421 | 433 | "buffer = intensities[:200]\n", |
422 | 434 | "sample_buffer = intensities[270:340]\n", |
423 | 435 | "\n", |
424 | | - "# Average sample+buffer and buffer intensities\n", |
425 | | - "buffer_mean = numpy.mean(buffer, axis=0)\n", |
426 | | - "sample_buffer_mean = numpy.mean(sample_buffer, axis=0)\n", |
| 436 | + "# Average sample + buffer and buffer intensities\n", |
| 437 | + "buffer_mean = np.mean(buffer, axis=0)\n", |
| 438 | + "sample_buffer_mean = np.mean(sample_buffer, axis=0)\n", |
427 | 439 | "\n", |
428 | 440 | "# Remove buffer background\n", |
429 | 441 | "sample = sample_buffer_mean - buffer_mean\n", |
|
434 | 446 | } |
435 | 447 | ], |
436 | 448 | "metadata": { |
437 | | - "kernelspec": { |
438 | | - "display_name": "Python 3 (ipykernel)", |
439 | | - "language": "python", |
440 | | - "name": "python3" |
441 | | - }, |
442 | 449 | "language_info": { |
443 | | - "codemirror_mode": { |
444 | | - "name": "ipython", |
445 | | - "version": 3 |
446 | | - }, |
447 | | - "file_extension": ".py", |
448 | | - "mimetype": "text/x-python", |
449 | | - "name": "python", |
450 | | - "nbconvert_exporter": "python", |
451 | | - "pygments_lexer": "ipython3", |
452 | | - "version": "3.9.12" |
| 450 | + "name": "python" |
453 | 451 | } |
454 | 452 | }, |
455 | 453 | "nbformat": 4, |
|
0 commit comments