Skip to content

Commit e79ffa8

Browse files
authored
Merge pull request #230 from scipp/unfold-pulse-dimension
Time-of-flight: remove pulse dimension in lookup table
2 parents 9b9cbe0 + a3a9525 commit e79ffa8

File tree

6 files changed

+159
-243
lines changed

6 files changed

+159
-243
lines changed

docs/user-guide/tof/dream.ipynb

+45-27
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,35 @@
402402
"metadata": {},
403403
"outputs": [],
404404
"source": [
405-
"table = workflow.compute(time_of_flight.TimeOfFlightLookupTable).squeeze()\n",
405+
"table = workflow.compute(time_of_flight.TimeOfFlightLookupTable)\n",
406406
"\n",
407407
"# Overlay mean on the figure above\n",
408408
"table[\"distance\", 13].plot(ax=fig2.ax, color=\"C1\", ls=\"-\", marker=None)"
409409
]
410410
},
411411
{
412-
"attachments": {},
413412
"cell_type": "markdown",
414413
"id": "27",
415414
"metadata": {},
415+
"source": [
416+
"The full table covers a range of distances, and looks like"
417+
]
418+
},
419+
{
420+
"cell_type": "code",
421+
"execution_count": null,
422+
"id": "28",
423+
"metadata": {},
424+
"outputs": [],
425+
"source": [
426+
"table.plot()"
427+
]
428+
},
429+
{
430+
"attachments": {},
431+
"cell_type": "markdown",
432+
"id": "29",
433+
"metadata": {},
416434
"source": [
417435
"### Computing a time-of-flight coordinate\n",
418436
"\n",
@@ -422,7 +440,7 @@
422440
{
423441
"cell_type": "code",
424442
"execution_count": null,
425-
"id": "28",
443+
"id": "30",
426444
"metadata": {},
427445
"outputs": [],
428446
"source": [
@@ -432,7 +450,7 @@
432450
},
433451
{
434452
"cell_type": "markdown",
435-
"id": "29",
453+
"id": "31",
436454
"metadata": {},
437455
"source": [
438456
"Histogramming the data for a plot should show a profile with 6 bumps that correspond to the frames:"
@@ -441,7 +459,7 @@
441459
{
442460
"cell_type": "code",
443461
"execution_count": null,
444-
"id": "30",
462+
"id": "32",
445463
"metadata": {},
446464
"outputs": [],
447465
"source": [
@@ -450,7 +468,7 @@
450468
},
451469
{
452470
"cell_type": "markdown",
453-
"id": "31",
471+
"id": "33",
454472
"metadata": {},
455473
"source": [
456474
"### Converting to wavelength\n",
@@ -461,7 +479,7 @@
461479
{
462480
"cell_type": "code",
463481
"execution_count": null,
464-
"id": "32",
482+
"id": "34",
465483
"metadata": {},
466484
"outputs": [],
467485
"source": [
@@ -481,7 +499,7 @@
481499
},
482500
{
483501
"cell_type": "markdown",
484-
"id": "33",
502+
"id": "35",
485503
"metadata": {},
486504
"source": [
487505
"### Comparing to the ground truth\n",
@@ -493,7 +511,7 @@
493511
{
494512
"cell_type": "code",
495513
"execution_count": null,
496-
"id": "34",
514+
"id": "36",
497515
"metadata": {},
498516
"outputs": [],
499517
"source": [
@@ -510,7 +528,7 @@
510528
},
511529
{
512530
"cell_type": "markdown",
513-
"id": "35",
531+
"id": "37",
514532
"metadata": {},
515533
"source": [
516534
"## Multiple detector pixels\n",
@@ -526,7 +544,7 @@
526544
{
527545
"cell_type": "code",
528546
"execution_count": null,
529-
"id": "36",
547+
"id": "38",
530548
"metadata": {},
531549
"outputs": [],
532550
"source": [
@@ -544,7 +562,7 @@
544562
},
545563
{
546564
"cell_type": "markdown",
547-
"id": "37",
565+
"id": "39",
548566
"metadata": {},
549567
"source": [
550568
"Our raw data has now a `detector_number` dimension of length 2.\n",
@@ -555,7 +573,7 @@
555573
{
556574
"cell_type": "code",
557575
"execution_count": null,
558-
"id": "38",
576+
"id": "40",
559577
"metadata": {},
560578
"outputs": [],
561579
"source": [
@@ -570,7 +588,7 @@
570588
},
571589
{
572590
"cell_type": "markdown",
573-
"id": "39",
591+
"id": "41",
574592
"metadata": {},
575593
"source": [
576594
"Computing time-of-flight is done in the same way as above.\n",
@@ -580,7 +598,7 @@
580598
{
581599
"cell_type": "code",
582600
"execution_count": null,
583-
"id": "40",
601+
"id": "42",
584602
"metadata": {},
585603
"outputs": [],
586604
"source": [
@@ -614,7 +632,7 @@
614632
},
615633
{
616634
"cell_type": "markdown",
617-
"id": "41",
635+
"id": "43",
618636
"metadata": {},
619637
"source": [
620638
"## Handling time overlap between subframes\n",
@@ -634,7 +652,7 @@
634652
{
635653
"cell_type": "code",
636654
"execution_count": null,
637-
"id": "42",
655+
"id": "44",
638656
"metadata": {},
639657
"outputs": [],
640658
"source": [
@@ -665,7 +683,7 @@
665683
},
666684
{
667685
"cell_type": "markdown",
668-
"id": "43",
686+
"id": "45",
669687
"metadata": {},
670688
"source": [
671689
"We can now see that there is no longer a gap between the two frames at the center of each pulse (green region).\n",
@@ -677,7 +695,7 @@
677695
{
678696
"cell_type": "code",
679697
"execution_count": null,
680-
"id": "44",
698+
"id": "46",
681699
"metadata": {},
682700
"outputs": [],
683701
"source": [
@@ -696,7 +714,7 @@
696714
},
697715
{
698716
"cell_type": "markdown",
699-
"id": "45",
717+
"id": "47",
700718
"metadata": {},
701719
"source": [
702720
"The data in the lookup table contains both the mean time-of-flight for each distance and time-of-arrival bin,\n",
@@ -713,17 +731,17 @@
713731
{
714732
"cell_type": "code",
715733
"execution_count": null,
716-
"id": "46",
734+
"id": "48",
717735
"metadata": {},
718736
"outputs": [],
719737
"source": [
720-
"table = workflow.compute(time_of_flight.TimeOfFlightLookupTable).squeeze()\n",
738+
"table = workflow.compute(time_of_flight.TimeOfFlightLookupTable)\n",
721739
"table.plot() / (sc.stddevs(table) / sc.values(table)).plot(norm=\"log\")"
722740
]
723741
},
724742
{
725743
"cell_type": "markdown",
726-
"id": "47",
744+
"id": "49",
727745
"metadata": {},
728746
"source": [
729747
"The workflow has a parameter which is used to mask out regions where the standard deviation is above a certain threshold.\n",
@@ -737,18 +755,18 @@
737755
{
738756
"cell_type": "code",
739757
"execution_count": null,
740-
"id": "48",
758+
"id": "50",
741759
"metadata": {},
742760
"outputs": [],
743761
"source": [
744762
"workflow[time_of_flight.LookupTableRelativeErrorThreshold] = 0.01\n",
745763
"\n",
746-
"workflow.compute(time_of_flight.TimeOfFlightLookupTable).squeeze().plot()"
764+
"workflow.compute(time_of_flight.TimeOfFlightLookupTable).plot()"
747765
]
748766
},
749767
{
750768
"cell_type": "markdown",
751-
"id": "49",
769+
"id": "51",
752770
"metadata": {},
753771
"source": [
754772
"We can now see that the central region is masked out.\n",
@@ -763,7 +781,7 @@
763781
{
764782
"cell_type": "code",
765783
"execution_count": null,
766-
"id": "50",
784+
"id": "52",
767785
"metadata": {},
768786
"outputs": [],
769787
"source": [

docs/user-guide/tof/frame-unwrapping.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@
420420
"source": [
421421
"table = workflow.compute(time_of_flight.TimeOfFlightLookupTable)\n",
422422
"\n",
423-
"table[\"pulse\", 0].plot(title=\"Pulse-0\") + table[\"pulse\", 1].plot(title=\"Pulse-1\")"
423+
"table.plot()"
424424
]
425425
},
426426
{

0 commit comments

Comments
 (0)