-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISISSANSReductionBackend.html
2706 lines (2663 loc) · 123 KB
/
ISISSANSReductionBackend.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ISIS SANS Reduction Back-end</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css?v=fadd4351" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=77160d70" />
<script src="_static/documentation_options.js?v=a8da1a53"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Load Algorithm Hook" href="LoadAlgorithmHook.html" />
<link rel="prev" title="Instrument Viewer Widget" href="InstrumentViewer.html" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59110517-1', 'auto');
ga('send', 'pageview');
</script>
</head><body>
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.mantidproject.org">
</a>
<span class="navbar-text navbar-version pull-left"><b>main</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="index.html">Home</a></li>
<li><a href="https://download.mantidproject.org">Download</a></li>
<li><a href="https://docs.mantidproject.org">User Documentation</a></li>
<li><a href="http://www.mantidproject.org/contact">Contact Us</a></li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<p>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="nav-item nav-item-0"><a href="index.html">Documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">ISIS SANS Reduction Back-end</a></li>
</ul>
</div> </p>
</div>
<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">
<section id="isis-sans-reduction-back-end">
<span id="isissansreductionbackend"></span><h1>ISIS SANS Reduction Back-end<a class="headerlink" href="#isis-sans-reduction-back-end" title="Link to this heading">¶</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#what-is-calculated-in-a-sans-reduction" id="id1">What is calculated in a SANS reduction?</a></p></li>
<li><p><a class="reference internal" href="#general" id="id2">General</a></p>
<ul>
<li><p><a class="reference internal" href="#introduction-and-motivation" id="id3">Introduction and Motivation</a></p></li>
<li><p><a class="reference internal" href="#overview" id="id4">Overview</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#sansstate" id="id5"><em>SANSState</em></a></p>
<ul>
<li><p><a class="reference internal" href="#motivation" id="id6">Motivation</a></p></li>
<li><p><a class="reference internal" href="#components" id="id7">Components</a></p>
<ul>
<li><p><a class="reference internal" href="#state-base-py" id="id8"><em>state_base.py</em></a></p></li>
<li><p><a class="reference internal" href="#individual-states" id="id9">Individual states</a></p>
<ul>
<li><p><a class="reference internal" href="#state-py" id="id10"><em>state.py</em></a></p></li>
<li><p><a class="reference internal" href="#data-py" id="id11"><em>data.py</em></a></p></li>
<li><p><a class="reference internal" href="#move-py" id="id12"><em>move.py</em></a></p></li>
<li><p><a class="reference internal" href="#reduction-mode-py" id="id13"><em>reduction_mode.py</em></a></p></li>
<li><p><a class="reference internal" href="#slice-py" id="id14"><em>slice.py</em></a></p></li>
<li><p><a class="reference internal" href="#mask-py" id="id15"><em>mask.py</em></a></p></li>
<li><p><a class="reference internal" href="#wavelength-py" id="id16"><em>wavelength.py</em></a></p></li>
<li><p><a class="reference internal" href="#save-py" id="id17"><em>save.py</em></a></p></li>
<li><p><a class="reference internal" href="#scale-py" id="id18"><em>scale.py</em></a></p></li>
<li><p><a class="reference internal" href="#adjustment-py" id="id19"><em>adjustment.py</em></a></p></li>
<li><p><a class="reference internal" href="#convert-to-q-py" id="id20"><em>convert_to_q.py</em></a></p></li>
<li><p><a class="reference internal" href="#compatibility-py" id="id21"><em>compatibility.py</em></a></p></li>
</ul>
</li>
</ul>
</li>
<li><p><a class="reference internal" href="#state-generation" id="id22">State Generation</a></p>
<ul>
<li><p><a class="reference internal" href="#user-input-dictionary" id="id23">User input dictionary</a></p></li>
<li><p><a class="reference internal" href="#builders" id="id24">Builders</a></p>
<ul>
<li><p><a class="reference internal" href="#selection-of-the-builders" id="id25">Selection of the builders</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#directors" id="id26">Directors</a></p>
<ul>
<li><p><a class="reference internal" href="#state-director-py" id="id27"><em>state_director.py</em></a></p></li>
<li><p><a class="reference internal" href="#user-file-input" id="id28">User file input</a></p></li>
<li><p><a class="reference internal" href="#director-for-isiscommandinterface-cli" id="id29">Director for <em>ISISCommandInterface</em> (CLI)</a></p></li>
<li><p><a class="reference internal" href="#usage-via-gui" id="id30">Usage via GUI</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#other-useful-information" id="id31">Other useful information</a></p>
<ul>
<li><p><a class="reference internal" href="#enum-py" id="id32"><em>enum.py</em></a></p></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p><a class="reference internal" href="#work-flow-algorithms-for-individual-reduction-steps" id="id33">Work-flow algorithms for individual reduction steps</a></p>
<ul>
<li><p><a class="reference internal" href="#calculate-sans-transmission" id="id34"><em>Calculate SANS Transmission</em></a></p></li>
<li><p><a class="reference internal" href="#conversion-to-q" id="id35">Conversion to Q</a></p></li>
<li><p><a class="reference internal" href="#sansconverttowavelengthandrebin" id="id36"><em>SANSConvertToWavelengthAndRebin</em></a></p></li>
<li><p><a class="reference internal" href="#create-sans-wavelength-and-pixel-adjustment" id="id37"><em>Create SANS Wavelength and Pixel Adjustment</em></a></p></li>
<li><p><a class="reference internal" href="#sansload" id="id38"><em>SANSLoad</em></a></p></li>
<li><p><a class="reference internal" href="#workspace-masking" id="id39"><em>Workspace Masking</em></a></p></li>
<li><p><a class="reference internal" href="#moveinstrumentcomponent-and-rotateinstrumentcomponent" id="id40"><em>MoveInstrumentComponent</em> and <em>RotateInstrumentComponent</em></a></p></li>
<li><p><a class="reference internal" href="#normalize-to-sans-monitor" id="id41"><em>Normalize To SANS Monitor</em></a></p></li>
<li><p><a class="reference internal" href="#sanssave" id="id42"><em>SANSSave</em></a></p></li>
<li><p><a class="reference internal" href="#slice-sans-event" id="id43"><em>Slice SANS Event</em></a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#work-flow-algorithm-orchestration" id="id44">Work-flow algorithm orchestration</a></p>
<ul>
<li><p><a class="reference internal" href="#sansbatchreduction" id="id45"><em>SANSBatchReduction</em></a></p></li>
<li><p><a class="reference internal" href="#sanssinglereduction" id="id46"><em>SANSSingleReduction</em></a></p></li>
<li><p><a class="reference internal" href="#sansreductioncore" id="id47"><em>SANSReductionCore</em></a></p></li>
</ul>
</li>
</ul>
</nav>
<section id="what-is-calculated-in-a-sans-reduction">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">What is calculated in a SANS reduction?</a><a class="headerlink" href="#what-is-calculated-in-a-sans-reduction" title="Link to this heading">¶</a></h2>
<p>This section gives a summary of what is calculated during the ISIS SANS reduction
without going into implementation details. This is done in some sections below.</p>
<p>The starting point is equation 5 in the article by
Richard Heenan et al, <em>J. Appl. Cryst.</em> (1997), pages 1140-1147. The coherent
macroscopic cross-section is calculated at ISIS using :</p>
<div class="math notranslate nohighlight">
\[\frac{\partial \Sigma}{\partial \Omega} (Q) = \frac{Scale}{V_{SAM}} \frac{\sum_{R,\lambda \subset Q}C(R,\lambda)}{\sum_{R,\lambda \subset Q}M(\lambda)T(\lambda)D(\lambda)F(R)\Omega (R) Cor(R,\lambda)}\]</div>
<p>This equation is aiming to do the best job at returning from the measured SANS
data the quantity of interest, the cross-section, <span class="math notranslate nohighlight">\(\frac{\partial \Sigma}{\partial \Omega}\)</span>,
which is an absolute scattering probability, in units of <span class="math notranslate nohighlight">\(cm_{-1}\)</span>. The <span class="math notranslate nohighlight">\(Scale\)</span>
factor in the equation above fine tunes the cross-section to give the correct
value (usually based on a fit to scattering from a standard polymer sample).
The value of <span class="math notranslate nohighlight">\(Scale\)</span> varies with the instrument set up, and with how the
units and normalisation for the other terms are chosen. <span class="math notranslate nohighlight">\(C(R,\lambda)\)</span>
are the observed counts at radius vector <span class="math notranslate nohighlight">\(R\)</span> from the diffractometer axis
and wavelength <span class="math notranslate nohighlight">\(\lambda\)</span>. <span class="math notranslate nohighlight">\(V_{SAM}\)</span> is the volume of the sample.
<span class="math notranslate nohighlight">\(M(\lambda)\)</span> is an incident monitor spectrum. <span class="math notranslate nohighlight">\(D(\lambda)\)</span> contains
the relative efficiency of the main detector compared to the incident monitor.
<span class="math notranslate nohighlight">\(D(\lambda)\)</span> is initially determined experimentally, but later subjected
to empirical adjustments. In reality the detector efficiencies implied in
<span class="math notranslate nohighlight">\(D(\lambda)\)</span> are also pixel dependent. This variation is in part
accounted for by <span class="math notranslate nohighlight">\(F(R)\)</span>, which is called the flat cell or flood source
calibration file. <span class="math notranslate nohighlight">\(F(R)\)</span> is also determined experimentally, and aims to
contain information about the relative efficiency of individual detector pixels.
It is normalised to values close to 1 in order not to change the overall scaling
of the equation. The experimental flood source data are divided by detector pixel
solid angles at their measurement set up to give <span class="math notranslate nohighlight">\(F(R)\)</span>.
Detector pixel solid angles are calculated for the instrument geometry at the
time of the SANS experiment. <span class="math notranslate nohighlight">\(Cor(R,\lambda)\)</span> optionally takes into account
any corrections that cannot be described as only pixel dependent or only
wavelength dependent. One such example is for the angle dependence of
transmissions, <a class="reference external" href="https://docs.mantidproject.org/nightly/algorithms/SANSWideAngleCorrection-v1.html#algm-sanswideanglecorrection" title="(in MantidProject v6.11)"><span class="xref std std-ref">SANSWideAngleCorrection</span></a>. <span class="math notranslate nohighlight">\(T(\lambda)\)</span>
is the transmission, which measures the ratio of neutron counts after the sample,
divided by the neutron counts before the sample. <span class="math notranslate nohighlight">\(T(\lambda)\)</span> is calculated
from a “transmission run” and a “direct run”. There are at least three ways to
measure transmission: using a monitor that drops in after the sample position,
a monitor on the main beam stop or by attenuating the beam, removing the beam stop,
and using the main detector itself. In all cases counts on the “transmission detector”
with a sample in the beam are divided by those for an empty (or “direct”) beam.
In order to allow for different exposures or changes in moderator spectrum,
each transmission spectrum is also first normalised to an incident beam monitor spectrum.
The sample transmission and direct beam transmissions must of course be acquired
with the same beam line set up, and ideally around the same time in case of any
electronic or performance drift.</p>
<p>Also, note that a SANS experiment frequently involves measurements of the sample (<em>Sample</em>)
material of interest contained inside a can (<em>Can</em>) or dissolved in a solvent inside a
cell. Separate SANS and transmission measurements must be made for the can or for
the pure solvent in a cell. For convenience this is always referred to as the
<em>Can</em> run. (Though for say a solid sample with no can, the <em>Can</em> run may actually
be simply an empty beam run.) The full data reduction is performed separately for
<em>Sample</em> and then the <em>Can</em>, before subtracting the <em>Can</em> cross-section from the <em>Sample</em>
plus <em>Can</em> cross-section, to obtain the cross-section for the <em>Sample</em> alone.
(In practise there can be some excluded volume and other annoying effects where
hydrogenous solvents are involved.)</p>
</section>
<section id="general">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">General</a><a class="headerlink" href="#general" title="Link to this heading">¶</a></h2>
<section id="introduction-and-motivation">
<h3><a class="toc-backref" href="#id3" role="doc-backlink">Introduction and Motivation</a><a class="headerlink" href="#introduction-and-motivation" title="Link to this heading">¶</a></h3>
<p>The ISIS SANS v2 reduction back-end is a more modern and updated version of the
original ISIS SANS reduction back-end which has been in use for almost 10 years.</p>
<p>Users who sets up a SANS reduction work-flow have control over a vast number of
settings (>50) in addition to settings which are extracted from the provided
workspaces and instrument specific settings. The total number of settings which
define a SANS data reduction can be close to 100.</p>
<p>The previous implementation of the SANS data reduction stored the settings
non-centrally and allowed the overall state to be mutable.
This made it extremely hard to reason about the overall state of a data
reduction and lead to unnecessary data reloads, degrading the overall
performance. Also, the direct coupling of the state to the algorithms does not allow
for extending them to other facilities.</p>
<p>The new implementation of the SANS data reduction aims to avoid these pitfalls
and focusses on robustness, maintainability and performance. The main way to
achieve this is to use a simple state object which stores the reduction-relevant
information centrally.</p>
</section>
<section id="overview">
<h3><a class="toc-backref" href="#id4" role="doc-backlink">Overview</a><a class="headerlink" href="#overview" title="Link to this heading">¶</a></h3>
<p>The reduction back-end consists of three components:</p>
<ul class="simple">
<li><p>the <em>SANSState</em> approach to centrally store the state of the reduction</p></li>
<li><p>a set of work-flow algorithms which perform the individual reduction steps</p></li>
<li><p>algorithms which orchestrate the work-flow algorithms.</p></li>
</ul>
</section>
</section>
<section id="sansstate">
<h2><a class="toc-backref" href="#id5" role="doc-backlink"><em>SANSState</em></a><a class="headerlink" href="#sansstate" title="Link to this heading">¶</a></h2>
<section id="motivation">
<h3><a class="toc-backref" href="#id6" role="doc-backlink">Motivation</a><a class="headerlink" href="#motivation" title="Link to this heading">¶</a></h3>
<p>As mentioned above, the amount of parameters that can be set by the user makes
the SANS reduction one of the more complex ones in the Mantid ecosystem. Previous
implementations stored the settings non-centrally which led to many difficult-to-find
bugs and a lot of uncertainty about the current settings of the reduction as they
were changed during the reduction.</p>
<p>This has been the main bottleneck of the previous reduction framework. To overcome
this, the new implementation of the SANS data reduction uses a simple state object
which stores the reduction-relevant information centrally.
This <em>SANSState</em> approach is the corner stone of the new design.</p>
<p>The <em>SANSState</em> is:</p>
<ul class="simple">
<li><p>self-validating</p></li>
<li><dl class="simple">
<dt>immutable (currently this is not enforced on the object itself, but should be added in the future.</dt><dd><p>The reduction code is written however such that it does not make sense to mutate the state
while a reduction is running.)</p>
</dd>
</dl>
</li>
<li><p>typed</p></li>
<li><p>serializable</p></li>
<li><p>easy to reason about</p></li>
<li><p>modular (sub-states for units of work)</p></li>
</ul>
<p>This approach allows us to identify issues with the settings before a lengthy
data reduction has been started.</p>
</section>
<section id="components">
<h3><a class="toc-backref" href="#id7" role="doc-backlink">Components</a><a class="headerlink" href="#components" title="Link to this heading">¶</a></h3>
<p>This section describes the essential components of the state mechanism.
These include the states themselves, the parameters in a state and
the state construction.</p>
<section id="state-base-py">
<h4><a class="toc-backref" href="#id8" role="doc-backlink"><em>state_base.py</em></a><a class="headerlink" href="#state-base-py" title="Link to this heading">¶</a></h4>
<p>The <em>JsonSerializable</em> metaclass contains the essential ingredients for
serializing a state object. Additionally it provides a decorator for any
Enum types which need to be JSON serializable.</p>
<p>Any classes which use the metaclass must place any attributes they intend
to be serialized into JSON string in the instance. I.e. class level variables
are not recommended since they may not end up in the instances internal
dictionary.</p>
<p>The <em>Serializer</em> is responsible for serialization using the JSON library and
provides static methods to (de)serialize to a string or file.</p>
</section>
<section id="individual-states">
<h4><a class="toc-backref" href="#id9" role="doc-backlink">Individual states</a><a class="headerlink" href="#individual-states" title="Link to this heading">¶</a></h4>
<p>The overall state object is made of sub-state objects which carry all required
information for a single reduction step or other unit of work.
This ensures that all the sub-states are independent of each other carry all
required information. Note that this also means that some data is stored
redundantly, for example the binning for the wavelength conversion is stored
in the state object used for monitor normalization and in the state object
for the transmission calculation.</p>
<p>In the following sections we list the different parameters on the currently
implemented states.</p>
<section id="state-py">
<h5><a class="toc-backref" href="#id10" role="doc-backlink"><em>state.py</em></a><a class="headerlink" href="#state-py" title="Link to this heading">¶</a></h5>
<p>The <em>State</em> class is the overarching state which contains sub-states where each
sub-state has a different responsibility (see below).</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>State type</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>data</p></td>
<td><p>info about runs to use (most important state)</p></td>
<td><p><em>StateData</em></p></td>
</tr>
<tr class="row-odd"><td><p>move</p></td>
<td><p>info about the instrument component positions</p></td>
<td><p><em>StateMove</em></p></td>
</tr>
<tr class="row-even"><td><p>reduction</p></td>
<td><p>general reduction info</p></td>
<td><p><em>StateReductionMode</em></p></td>
</tr>
<tr class="row-odd"><td><p>slice</p></td>
<td><p>info about event slicing (when applicable)</p></td>
<td><p><em>StateSliceEvent</em></p></td>
</tr>
<tr class="row-even"><td><p>mask</p></td>
<td><p>info about masking</p></td>
<td><p><em>StateMask</em></p></td>
</tr>
<tr class="row-odd"><td><p>wavelength</p></td>
<td><p>info about wavelength conversion of the scatter data</p></td>
<td><p><em>StateWavelength</em></p></td>
</tr>
<tr class="row-even"><td><p>save</p></td>
<td><p>info about the save settings</p></td>
<td><p><em>StateSave</em></p></td>
</tr>
<tr class="row-odd"><td><p>scale</p></td>
<td><p>info about the absolute scale and the sample volume</p></td>
<td><p><em>StateScale</em></p></td>
</tr>
<tr class="row-even"><td><p>adjustment</p></td>
<td><p>info about adjustment workspaces</p></td>
<td><p><em>StateAdjustment</em></p></td>
</tr>
<tr class="row-odd"><td><p>convert_to_q</p></td>
<td><p>info about momentum transfer conversion</p></td>
<td><p><em>StateConvertToQ</em></p></td>
</tr>
<tr class="row-even"><td><p>compatibility</p></td>
<td><p>used when reducing in compatibility mode</p></td>
<td><p><em>StateCompatibility</em></p></td>
</tr>
</tbody>
</table>
</section>
<section id="data-py">
<h5><a class="toc-backref" href="#id11" role="doc-backlink"><em>data.py</em></a><a class="headerlink" href="#data-py" title="Link to this heading">¶</a></h5>
<p>This is the most important state. Since the reduction framework has a data-driven
approach it is not possible to build up most of the reduction without knowing what
the actual data for the reduction will be.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>sample_scatter</p></td>
<td><p>The sample scatter file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>N</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>sample_scatter_period</p></td>
<td><p>The period to use for the sample scatter</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>sample_transmission</p></td>
<td><p>The sample transmission file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>sample_transmission_period</p></td>
<td><p>The period to use for the sample transmission</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>sample_direct</p></td>
<td><p>The sample direct file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>sample_direct_period</p></td>
<td><p>The period to use for the sample direct</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>can_scatter</p></td>
<td><p>The can scatter file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>can_scatter_period</p></td>
<td><p>The period to use for the can scatter</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>can_transmission</p></td>
<td><p>The can transmission file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>can_transmission_period</p></td>
<td><p>The period to use for the can transmission</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>can_direct</p></td>
<td><p>The can direct file path</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>can_direct_period</p></td>
<td><p>The period to use for the can direct</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>calibration</p></td>
<td><p>The path to the calibration file</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>sample_scatter_run_number</p></td>
<td><p>Run number of the sample scatter file</p></td>
<td><p><em>PositiveIntegerParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>sample_scatter_is_multi_period</p></td>
<td><p>If the sample scatter is multi-period</p></td>
<td><p><em>BoolParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>instrument</p></td>
<td><p>Enum for the SANS instrument</p></td>
<td><p><em>Enum (SANSInstrument)</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>idf_file_path</p></td>
<td><p>Path to the IDF file</p></td>
<td><p><em>StringParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>ipf_file_path</p></td>
<td><p>Path to the IPF file</p></td>
<td><p><em>StringParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>Note that while some parameters are optional they might become mandatory if other
optional parameters have been specified. Also note that some of the parameters
on the state are auto-generated by the builder classes.</p>
</section>
<section id="move-py">
<h5><a class="toc-backref" href="#id12" role="doc-backlink"><em>move.py</em></a><a class="headerlink" href="#move-py" title="Link to this heading">¶</a></h5>
<p>The move state defines how instruments are moved. This is highly individual to
the different instruments. Therefore there is most likely going to be one state
per instrument, sometimes even more when there should be different behaviour for
different run numbers.</p>
<p>The fundamental class is <em>StateMove</em> which has the following parameters:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
<th class="head"><p>Default value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>x_translation_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>y_translation_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>z_translation_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>rotation_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>side_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>radius_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>x_tilt_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>y_tilt_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>z_tilt_correction</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>sample_centre_pos1</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>sample_centre_pos2</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-odd"><td><p>detector_name</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>StringWithNoneParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
<tr class="row-even"><td><p>detector_name_short</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>StringWithNoneParameter</em></p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>Y</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If nothing is specified, then the detector positions and movements are assumed to be 0.
Note that each instrument contains additional parameters on their individual state classes. When adding
a new instrument, this will be most likely one of the main areas to add new code.</p>
</section>
<section id="reduction-mode-py">
<h5><a class="toc-backref" href="#id13" role="doc-backlink"><em>reduction_mode.py</em></a><a class="headerlink" href="#reduction-mode-py" title="Link to this heading">¶</a></h5>
<p>The <em>StateReductionMode</em> class contains general settings about the reduction, e.g. if we are dealing with a merged
reduction. It contains the following parameters:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
<th class="head"><p>Default value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>reduction_mode</p></td>
<td><p>The type of reduction, i.e. LAB, HAB, merged or both</p></td>
<td><p><em>Enum(ReductionMode)</em></p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p><em>ReductionMode.LAB</em> enum value</p></td>
</tr>
<tr class="row-odd"><td><p>reduction_dimensionality</p></td>
<td><p>If 1D or 2D reduction</p></td>
<td><p><em>Enum(ReductionDimensionality)</em></p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p><em>ReductionDimensionality.OneDim</em> enum value</p></td>
</tr>
<tr class="row-even"><td><p>merge_fit_mode</p></td>
<td><p>The fit mode for merging</p></td>
<td><p><em>Enum(FitModeForMerge)</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p><em>FitModeForMerge.NoFit</em> enum value</p></td>
</tr>
<tr class="row-odd"><td><p>merge_shift</p></td>
<td><p>The shift value for merging</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>0.0</p></td>
</tr>
<tr class="row-even"><td><p>merge_scale</p></td>
<td><p>The scale value for merging</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>1.0</p></td>
</tr>
<tr class="row-odd"><td><p>merge_range_min</p></td>
<td><p>The min q value for merging</p></td>
<td><p><em>FloatWithNoneParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p><em>None</em></p></td>
</tr>
<tr class="row-even"><td><p>merge_range_max</p></td>
<td><p>The max q value for merging</p></td>
<td><p><em>FloatWithNoneParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p><em>None</em></p></td>
</tr>
<tr class="row-odd"><td><p>detector_names</p></td>
<td><p>A dict from detector type to detector name</p></td>
<td><p><em>DictParameter</em></p></td>
<td><p>N</p></td>
<td><p>Y</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
</tbody>
</table>
</section>
<section id="slice-py">
<h5><a class="toc-backref" href="#id14" role="doc-backlink"><em>slice.py</em></a><a class="headerlink" href="#slice-py" title="Link to this heading">¶</a></h5>
<p>The <em>StateSliceEvent</em> class is only relevant when we are dealing with event-type
data and the user decides to perform an event-sliced reduction, i.e. one reduction per event slice.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>start_time</p></td>
<td><p>A list of start times for event slices</p></td>
<td><p><em>FloatListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>end_time</p></td>
<td><p>A list of stop times for event slices</p></td>
<td><p><em>FloatListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
</tbody>
</table>
<p>Note that the validation ensures that the number of <em>start_time</em> and <em>end_time</em>
entries is matched and that the end time is larger than the start time.</p>
</section>
<section id="mask-py">
<h5><a class="toc-backref" href="#id15" role="doc-backlink"><em>mask.py</em></a><a class="headerlink" href="#mask-py" title="Link to this heading">¶</a></h5>
<p>The <em>StateMask</em> class holds information regarding time and pixel masking.
It also contains two sub-states which contain detector-specific masking information.
The <em>StateMask</em> contains the following parameters:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>radius_min</p></td>
<td><p>The min radius of a circular mask on the detector</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>radius_max</p></td>
<td><p>The max radius of a circular mask on the detector</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>bin_mask_general_start</p></td>
<td><p>A list of start times for general bin masks</p></td>
<td><p><em>FloatListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>bin_mask_general_stop</p></td>
<td><p>A list of stop times for general bin masks</p></td>
<td><p><em>FloatListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>mask_files</p></td>
<td><p>A list of mask files</p></td>
<td><p><em>StringListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>phi_min</p></td>
<td><p>The min angle of an angle mask</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>phi_max</p></td>
<td><p>The max angle of an angle mask</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>use_mask_phi_mirror</p></td>
<td><p>If the mirror slice should be used</p></td>
<td><p><em>BoolParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>beam_stop_arm_width</p></td>
<td><p>The width of the beam stop arm</p></td>
<td><p><em>PositiveFloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>beam_stop_arm_angle</p></td>
<td><p>The angle of the beam stop arm</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>beam_stop_arm_pos1</p></td>
<td><p>The x position of the beam stop arm</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>beam_stop_arm_pos2</p></td>
<td><p>The y position of the beam stop arm</p></td>
<td><p><em>FloatParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>clear</p></td>
<td><p>currently not used</p></td>
<td><p><em>BoolParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>clear_time</p></td>
<td><p>currently not used</p></td>
<td><p><em>BoolParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>detector</p></td>
<td><p>A dict of detector type to <em>StateMaskDetectors</em> sub-states</p></td>
<td><p><em>DictParameter</em></p></td>
<td><p>N</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>idf_path</p></td>
<td><p>The path to the IDF</p></td>
<td><p><em>StringParameter</em></p></td>
<td><p>N</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>Validation is applied to some of the entries.</p>
<p>The detector-specific settings are stored in the <em>StateMaskDetectors</em> which contains the following parameters:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Comment</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Optional?</p></th>
<th class="head"><p>Auto-generated?</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>single_vertical_strip_mask</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>range_vertical_strip_start</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>range_vertical_strip_stop</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>single_horizontal_strip_mask</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>range_horizontal_strip_start</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>range_horizontal_strip_stop</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p>block_horizontal_start</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
<td><p><em>PositiveIntegerListParameter</em></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p>block_horizontal_stop</p></td>
<td><ul class="simple">
<li></li>
</ul>