-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathoverview.html
More file actions
952 lines (780 loc) · 57.5 KB
/
overview.html
File metadata and controls
952 lines (780 loc) · 57.5 KB
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
<!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>Overview — hklpy 1.1</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
</script>
<!--
this give us a css class that will be invisible only if js is disabled
-->
<noscript>
<style>
.pst-js-only { display: none !important; }
</style>
</noscript>
<!-- Loaded before other Sphinx assets -->
<link href="_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link href="_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=8f2a1f02" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<link rel="stylesheet" type="text/css" href="_static/tabs.css?v=a5c4661c" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<!-- So that users can add custom icons -->
<script src="_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
<script src="_static/documentation_options.js?v=6f037312"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/design-tabs.js?v=f930bc37"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
<script defer="defer" 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="Simulated Diffractometers" href="ready_to_use.html" />
<link rel="prev" title="User Guide" href="user_guide.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
<meta name="docsearch:version" content="1.1" />
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
<dialog id="pst-search-dialog">
<form class="bd-search d-flex align-items-center"
action="search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
placeholder="Search the docs ..."
aria-label="Search the docs ..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</dialog>
<div class="pst-async-banner-revealer d-none">
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
</div>
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
<div class="bd-header__inner bd-page-width">
<button class="pst-navbar-icon sidebar-toggle primary-toggle" aria-label="Site navigation">
<span class="fa-solid fa-bars"></span>
</button>
<div class="col-lg-3 navbar-header-items__start">
<div class="navbar-item">
<a class="navbar-brand logo" href="index.html">
<p class="title logo__title">hklpy 1.1</p>
</a></div>
</div>
<div class="col-lg-9 navbar-header-items">
<div class="me-auto navbar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="user_guide.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="install.html">
Install
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="api.html">
API Reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="release_notes.html">
Release History
</a>
</li>
</ul>
</nav></div>
</div>
<div class="navbar-header-items__end">
<div class="navbar-item navbar-persistent--container">
<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
</div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
</div>
</div>
<div class="navbar-persistent--mobile">
<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
</div>
<button class="pst-navbar-icon sidebar-toggle secondary-toggle" aria-label="On this page">
<span class="fa-solid fa-outdent"></span>
</button>
</div>
</header>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<dialog id="pst-primary-sidebar-modal"></dialog>
<div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="user_guide.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="install.html">
Install
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="api.html">
API Reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="release_notes.html">
Release History
</a>
</li>
</ul>
</nav></div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
</div>
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<nav class="bd-docs-nav bd-links"
aria-label="Section Navigation">
<p class="bd-links__title" role="heading" aria-level="1">Section Navigation</p>
<div class="bd-toc-item navbar-nav"><ul class="current nav bd-sidenav">
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="ready_to_use.html">Simulated Diffractometers</a></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="examples/diffractometer.html">Diffractometer Examples</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/geo_e4cv.html">E4CV : 4-circle diffractometer example</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/geo_e6c.html">E6C : 6-circle diffractometer example</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/geo_k4cv.html">K4CV : 4-circle kappa diffractometer example</a></li>
</ul>
</details></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="examples/howto.html">How-to Guides</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/how_additional_parameters.html">Diffractometer “Parameters”</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/how_configuration.html">Sample orientation: export & restore diffractometer configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/how_extra_real_axis.html">How to add extra motors to a diffractometer class</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/how_spec_commands.html">SPEC commands in Bluesky</a></li>
</ul>
</details></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="examples/t_and_c.html">Tests and Comparisons</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/tst_UB_in_descriptor_document.html"><strong>UB</strong> : Save and Restore Crystal Orientation</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/tst_UB_in_stream.html">WIP: save reflection information in stream</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/tst_e4cv_fourc.html">Compare E4CV 4-circle orientation with SPEC fourc</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/tst_e6c_test_calculations.html">Non-exhaustive test of E6C calculations</a></li>
</ul>
</details></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="examples/variations.html">Variations</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/var_e4cv_renamed_axes.html">Rename the axes of a 4-circle diffractometer</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/var_engines.html">Use <code class="docutils literal notranslate"><span class="pre">E4CV</span></code>’s <span class="math notranslate nohighlight">\(Q\)</span> calculation engine</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/notebooks/var_nslsii_tardis.html">NSLS-II TARDIS Configuration</a></li>
</ul>
</details></li>
<li class="toctree-l1"><a class="reference internal" href="constraints.html">Constraints</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
<div class="sidebar-primary-item">
<div id="ethical-ad-placement"
class="flat"
data-ea-publisher="readthedocs"
data-ea-type="readthedocs-sidebar"
data-ea-manual="true">
</div></div>
</div>
</div>
<main id="main-content" class="bd-main" role="main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article d-print-none">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item">
<nav aria-label="Breadcrumb" class="d-print-none">
<ul class="bd-breadcrumbs">
<li class="breadcrumb-item breadcrumb-home">
<a href="index.html" class="nav-link" aria-label="Home">
<i class="fa-solid fa-home"></i>
</a>
</li>
<li class="breadcrumb-item"><a href="user_guide.html" class="nav-link">User Guide</a></li>
<li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">Overview</span></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article">
<section id="overview">
<span id="id1"></span><h1>Overview<a class="headerlink" href="#overview" title="Link to this heading">#</a></h1>
<p><strong>hklpy</strong> provides <a class="reference external" href="https://blueskyproject.io/ophyd">ophyd</a> diffractometer
devices. Each diffractometer is a positioner which may be used with <a class="reference external" href="https://blueskyproject.io/bluesky">bluesky</a> plans.</p>
<p><em>Hkl</em> (<a class="reference external" href="https://people.debian.org/~picca/hkl/hkl.html">documentation</a>), from
Synchrotron Soleil, is used as a backend library to convert between real-space
motor coordinates and reciprocal-space crystallographic coordinates. Here, we
refer to this library as <strong>libhkl</strong> to clarify and distinguish from other use of
of the term <em>hkl</em>. Multiple source code repositories exist. <strong>hklpy</strong> uses the
<a class="reference external" href="https://repo.or.cz/hkl.git">active development repository</a>.</p>
<p>All diffractometers can be provisioned with simulated axes; motors from an EPICS
control system are not required to use <strong>hklpy</strong>. A few diffractometer simulators
are provided <a class="reference internal" href="ready_to_use.html#ready-to-use"><span class="std std-ref">ready to use</span></a>.</p>
<p><a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer()</span></code></a> is the base class from which all the
different diffractometer geometries are built. Built on the
<a class="reference external" href="https://blueskyproject.io/ophyd/positioners.html#pseudopositioner">ophyd.PseudoPositioner</a> interface,
it defines all the components of a diffractometer. The different geometries
specify the names and order for the real motor axes.</p>
<section id="definitions">
<h2>Definitions<a class="headerlink" href="#definitions" title="Link to this heading">#</a></h2>
<p>Several terms used throughout are:</p>
<section id="real-axis-positioner">
<span id="index-0"></span><span id="overview-real"></span><h3>real axis (positioner)<a class="headerlink" href="#real-axis-positioner" title="Link to this heading">#</a></h3>
<p>A positioner (whether simulated or attached to hardware) that operates in
<em>real</em> space. Typically an instance of <a class="reference external" href="https://blueskyproject.io/ophyd/builtin-devices.html#epicsmotor">ophyd.EpicsMotor</a>
or
<a class="reference external" href="https://blueskyproject.io/ophyd/positioners.html#softpositioner">ophyd.SoftPositioner</a>.</p>
</section>
<section id="pseudo-axis-positioner">
<span id="index-1"></span><span id="overview-pseudo"></span><h3>pseudo axis (positioner)<a class="headerlink" href="#pseudo-axis-positioner" title="Link to this heading">#</a></h3>
<p>A positioner (whether simulated or attached to hardware) that operates in
<em>reciprocal</em> space. Typically an instance of <a class="reference external" href="https://blueskyproject.io/ophyd/positioners.html#ophyd.pseudopos.PseudoSingle">ophyd.PseudoSingle</a>.</p>
</section>
<section id="forward-transformation">
<span id="index-2"></span><h3>forward (transformation)<a class="headerlink" href="#forward-transformation" title="Link to this heading">#</a></h3>
<p>Compute the values of the real positioners given values of the pseudo
positioners. Additional <a class="reference internal" href="#constraint-overview"><span class="std std-ref">constraints</span></a> (limits on the
real positioner and diffractometer mode) may be defined to limit the number of
possible solutions.</p>
</section>
<section id="inverse-transformation">
<span id="index-3"></span><h3>inverse (transformation)<a class="headerlink" href="#inverse-transformation" title="Link to this heading">#</a></h3>
<p>Compute the values of the <a class="reference internal" href="#overview-pseudo"><span class="std std-ref">pseudo positioners</span></a> given
values of the <a class="reference internal" href="#overview-real"><span class="std std-ref">real positioners</span></a>.</p>
</section>
<section id="libhkl-support-library">
<span id="index-4"></span><h3><em>libhkl</em> support library<a class="headerlink" href="#libhkl-support-library" title="Link to this heading">#</a></h3>
<p>The transformation between real and reciprocal (a.k.a., <em>pseudo</em>) space are passed
(from modules <a class="reference internal" href="diffract.html#module-hkl.diffract" title="hkl.diffract"><code class="xref py py-mod docutils literal notranslate"><span class="pre">diffract</span></code></a> through <a class="reference internal" href="calc.html#module-hkl.calc" title="hkl.calc"><code class="xref py py-mod docutils literal notranslate"><span class="pre">calc</span></code></a>) to a support library
known here as <em>libhkl</em> (<a class="reference external" href="https://repo.or.cz/hkl.git">https://repo.or.cz/hkl.git</a>), written in C.</p>
</section>
</section>
<section id="parts-of-a-diffractometer-object">
<h2>Parts of a <cite>Diffractometer</cite> object<a class="headerlink" href="#parts-of-a-diffractometer-object" title="Link to this heading">#</a></h2>
<p>A <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer</span></code></a> object has several parts:</p>
<section id="name">
<h3>name<a class="headerlink" href="#name" title="Link to this heading">#</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">name</span></code> of the <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer()</span></code></a> instance is
completely at the choice of the user and conveys no specific information to
the underlying Python support code.</p>
<p>One important convention is that the name given on the left side of the <code class="docutils literal notranslate"><span class="pre">=</span></code>
matches the name given by the <code class="docutils literal notranslate"><span class="pre">name="..."</span></code> keyword, such as this example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">e4cv</span> <span class="o">=</span> <span class="n">E4CV</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"e4cv"</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="geometry">
<span id="index-5"></span><h3>geometry<a class="headerlink" href="#geometry" title="Link to this heading">#</a></h3>
<p>The geometry describes the physical arrangement of real positioners that
make up the diffractometer. The choices are limited to those geometries
provided in <a class="reference internal" href="geometries.html#module-hkl.geometries" title="hkl.geometries"><code class="xref py py-mod docutils literal notranslate"><span class="pre">geometries</span></code></a> (which are the geometries provided by the
<em>libhkl</em> support library). A geometry will provide a list of the real
positioners. It is possible to use alternate names.</p>
</section>
<section id="calc">
<span id="index-6"></span><h3>calc<a class="headerlink" href="#calc" title="Link to this heading">#</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">calc</span></code> attribute, set when the <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer</span></code></a>
object is defined, connects with the underlying <em>libhkl</em> support library.
While a user might call certain methods from this
<a class="reference internal" href="calc.html#hkl.calc.CalcRecip" title="hkl.calc.CalcRecip"><code class="xref py py-class docutils literal notranslate"><span class="pre">CalcRecip()</span></code></a> object, it is usually not necessary. The
most common term from this layer would be the actual wavelength used for
computations. Using from the example above, <code class="docutils literal notranslate"><span class="pre">DFRCT.calc.wavelength</span></code>
(where <code class="docutils literal notranslate"><span class="pre">DFRCT</span></code> is the diffractometer object, such as <code class="docutils literal notranslate"><span class="pre">e4cv</span></code> above),
expressed in Angstrom units. Normally, the user will set the energy in the
diffractometer object, <code class="docutils literal notranslate"><span class="pre">DFRCT.energy</span></code>, which will then set the wavelength.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">calc</span></code> contains the methods that convert between energy and
wavelength. To use this Python support at an instrument that does not use
X-rays (such as a neutron source), re-write these methods and also redefine
any classes that use <a class="reference internal" href="calc.html#hkl.calc.CalcRecip" title="hkl.calc.CalcRecip"><code class="xref py py-class docutils literal notranslate"><span class="pre">CalcRecip()</span></code></a>.</p>
</section>
<section id="wavelength-and-energy">
<span id="index-7"></span><h3>wavelength (and energy)<a class="headerlink" href="#wavelength-and-energy" title="Link to this heading">#</a></h3>
<p>The <a class="reference internal" href="diffract.html#diffract-energy"><span class="std std-ref">energy</span></a> of the diffractometer sets the
<em>wavelength</em> (<span class="math notranslate nohighlight">\(\lambda\)</span>), <a class="footnote-reference brackets" href="#lambda-name" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> which is used when:</p>
<ol class="arabic simple">
<li><p>computing <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.forward" title="hkl.diffract.Diffractometer.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forward()</span></code></a> and
<a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.inverse" title="hkl.diffract.Diffractometer.inverse"><code class="xref py py-meth docutils literal notranslate"><span class="pre">inverse()</span></code></a> transformations</p></li>
<li><p>defining orientation <a class="reference internal" href="#overview-orientation-reflections"><span class="std std-ref">reflections</span></a></p></li>
<li><p>documenting the <a class="reference internal" href="configuration.html#hkl.configuration.DiffractometerConfiguration" title="hkl.configuration.DiffractometerConfiguration"><code class="xref py py-class docutils literal notranslate"><span class="pre">DiffractometerConfiguration</span></code></a></p></li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>It is more common for X-ray users to describe the <em>energy</em>
of the incident radiation than its
<em>wavelength</em>. The high-level interface allows the X-ray photon energy
to be expressed in any <a class="reference internal" href="diffract.html#diffract-energy-units"><span class="std std-ref">engineering units</span></a>
that are convertible to the expected units (<cite>keV</cite>). An offset may be
applied, which is useful when connecting the diffractometer energy
with a control system variable. (See the
<a class="reference internal" href="diffract.html#diffract-energy-control-system"><span class="std std-ref">Control System Energy</span></a> section.)</p>
</div>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="lambda-name" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id2">1</a><span class="fn-bracket">]</span></span>
<p>The wavelength, commonly written as <span class="math notranslate nohighlight">\(\lambda\)</span>,
cannot be named in Python code as <cite>“lambda”</cite>, which is a
<a class="reference external" href="https://docs.python.org/3/reference/expressions.html#lambda">reserved</a>
Python word.</p>
</aside>
</aside>
</section>
<section id="sample">
<span id="index-8"></span><h3>sample<a class="headerlink" href="#sample" title="Link to this heading">#</a></h3>
<p>The point of a diffractometer is to position a sample for scientific
measurements. The <code class="docutils literal notranslate"><span class="pre">sample</span></code> attribute is an instance of
<a class="reference internal" href="sample.html#hkl.sample.HklSample" title="hkl.sample.HklSample"><code class="xref py py-class docutils literal notranslate"><span class="pre">HklSample</span></code></a>. Behind the scenes, the
<a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer</span></code></a> object maintains a <em>dictionary</em> of
samples (keyed by <code class="docutils literal notranslate"><span class="pre">name</span></code>), each with its own <code class="xref py py-class docutils literal notranslate"><span class="pre">Lattice</span></code>
and orientation (reflections) information.</p>
<section id="lattice">
<span id="index-9"></span><h4>lattice<a class="headerlink" href="#lattice" title="Link to this heading">#</a></h4>
<p>Crystal samples have <code class="xref py py-class docutils literal notranslate"><span class="pre">Lattice</span></code> parameters defined by
unit cell lengths and angles. (Units here are angstroms and degrees.)</p>
<p>This table describes the lattice of crystalline Vibranium <a class="footnote-reference brackets" href="#vibranium" id="id3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>:</p>
<div class="pst-scrollable-table-container"><table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>sample</p></th>
<th class="head"><p>a</p></th>
<th class="head"><p>b</p></th>
<th class="head"><p>c</p></th>
<th class="head"><p>alpha</p></th>
<th class="head"><p>beta</p></th>
<th class="head"><p>gamma</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>vibranium</p></td>
<td><p><span class="math notranslate nohighlight">\(2\pi\)</span></p></td>
<td><p><span class="math notranslate nohighlight">\(2\pi\)</span></p></td>
<td><p><span class="math notranslate nohighlight">\(2\pi\)</span></p></td>
<td><p>90</p></td>
<td><p>90</p></td>
<td><p>90</p></td>
</tr>
</tbody>
</table>
</div>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="vibranium" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id3">1</a>,<a role="doc-backlink" href="#id4">2</a>)</span>
<p>Vibranium (<a class="reference external" href="https://en.wikipedia.org/wiki/Vibranium">https://en.wikipedia.org/wiki/Vibranium</a>)
is a fictional metal. Here, we have decided it is cubic with a lattice
constant of exactly <span class="math notranslate nohighlight">\(2\pi\)</span>.</p>
</aside>
</aside>
</section>
<section id="orientation">
<span id="index-10"></span><span id="overview-orientation"></span><h4>orientation<a class="headerlink" href="#orientation" title="Link to this heading">#</a></h4>
<p>The <strong>UB</strong> matrix describes the <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.forward" title="hkl.diffract.Diffractometer.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forward()</span></code></a>
and <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.inverse" title="hkl.diffract.Diffractometer.inverse"><code class="xref py py-meth docutils literal notranslate"><span class="pre">inverse()</span></code></a> transformations that allow
precise positioning of a crystalline sample’s atomic planes in the laboratory
reference system of the diffractometer. Typically, the <strong>UB</strong> matrix is
computed (by <em>libhkl</em>) from two orientation reflections. Two different methods
are available to compute the <strong>UB</strong> matrix:</p>
<div class="pst-scrollable-table-container"><table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>method</p></th>
<th class="head"><p>description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><a class="reference internal" href="sample.html#hkl.sample.HklSample.compute_UB" title="hkl.sample.HklSample.compute_UB"><code class="xref py py-meth docutils literal notranslate"><span class="pre">compute_UB()</span></code></a></p></td>
<td><p>Busing & Levy computation with 2 reflections</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="sample.html#hkl.sample.HklSample.affine" title="hkl.sample.HklSample.affine"><code class="xref py py-meth docutils literal notranslate"><span class="pre">affine()</span></code></a></p></td>
<td><p>Simplex refinement with more than 2 reflections</p></td>
</tr>
</tbody>
</table>
</div>
<section id="orientation-reflections">
<span id="index-11"></span><span id="overview-orientation-reflections"></span><h5>orientation reflections<a class="headerlink" href="#orientation-reflections" title="Link to this heading">#</a></h5>
<p>An orientation reflection consists of a set of matching <a class="reference internal" href="#overview-pseudo"><span class="std std-ref">pseudo axis (positioner)</span></a>
and <a class="reference internal" href="#overview-real"><span class="std std-ref">real axis (positioner)</span></a> values at a specified wavelength. These values may be
measured or computed. It is not necessary that the real axis positions be
within any of the <a class="reference internal" href="constraints.html#constraints"><span class="std std-ref">constraints</span></a>.</p>
<p>There are several use cases for a set of reflections:</p>
<ul class="simple">
<li><p>Computation of the <a class="reference internal" href="#overview-orientation"><span class="std std-ref">orientation</span></a> matrix (for 2 or more non-parallel reflections).</p></li>
<li><p>Documentation of observed (or theoretical) reflection settings.</p></li>
<li><p>Reference settings so as to re-position the diffractometer.</p></li>
<li><p>Define a crystallographic zone or axis to guide the diffractometer for measurements.</p></li>
</ul>
<p>Here is an example of three orientation reflections for a sample of crystalline
vibranium <a class="footnote-reference brackets" href="#vibranium" id="id4" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> as mounted on a diffractometer with
<a class="reference internal" href="geometries.html#hkl.geometries.E4CV" title="hkl.geometries.E4CV"><code class="xref py py-class docutils literal notranslate"><span class="pre">E4CV</span></code></a> geometry:</p>
<div class="pst-scrollable-table-container"><table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>#</p></th>
<th class="head"><p>h</p></th>
<th class="head"><p>k</p></th>
<th class="head"><p>l</p></th>
<th class="head"><p>omega</p></th>
<th class="head"><p>chi</p></th>
<th class="head"><p>phi</p></th>
<th class="head"><p>tth</p></th>
<th class="head"><p>wavelength</p></th>
<th class="head"><p>orient?</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>1</p></td>
<td><p>4.0</p></td>
<td><p>0.0</p></td>
<td><p>0.0</p></td>
<td><p>-145.451</p></td>
<td><p>0.0</p></td>
<td><p>0.0</p></td>
<td><p>69.0966</p></td>
<td><p>1.54</p></td>
<td><p>False</p></td>
</tr>
<tr class="row-odd"><td><p>2</p></td>
<td><p>0.0</p></td>
<td><p>4.0</p></td>
<td><p>0.0</p></td>
<td><p>-145.451</p></td>
<td><p>0.0</p></td>
<td><p>90.0</p></td>
<td><p>69.0966</p></td>
<td><p>1.54</p></td>
<td><p>True</p></td>
</tr>
<tr class="row-even"><td><p>3</p></td>
<td><p>0.0</p></td>
<td><p>0.0</p></td>
<td><p>4.0</p></td>
<td><p>-145.451</p></td>
<td><p>90.0</p></td>
<td><p>0.0</p></td>
<td><p>69.0966</p></td>
<td><p>1.54</p></td>
<td><p>True</p></td>
</tr>
</tbody>
</table>
</div>
</section>
</section>
</section>
<section id="constraint">
<span id="constraint-overview"></span><span id="index-12"></span><h3>constraint<a class="headerlink" href="#constraint" title="Link to this heading">#</a></h3>
<p>A <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.forward" title="hkl.diffract.Diffractometer.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forward()</span></code></a> transformation can
have many solutions. A <code class="xref py py-class docutils literal notranslate"><span class="pre">Constraint</span></code> can be applied:</p>
<ul class="simple">
<li><p>to limit the range of solutions accepted for that positioner</p></li>
<li><p>to declare the value to use when the positioner should be kept constant</p></li>
</ul>
<p>See the <a class="reference internal" href="constraints.html#constraints"><span class="std std-ref">Constraints</span></a> section for more information.</p>
</section>
<section id="mode">
<span id="overview-mode"></span><span id="index-13"></span><h3>mode<a class="headerlink" href="#mode" title="Link to this heading">#</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">forward()</span></code> transformation can have many solutions. The
diffractometer is set to a mode (chosen from a list specified by the
diffractometer geometry) that controls how values for each of the real
positioners will be controlled. A mode can control relationships between
real positioners in addition to limiting the motion of a real positioner.
Further, a mode can specify an additional reflection which will be used to
determine the outcome of the <code class="docutils literal notranslate"><span class="pre">forward()</span></code> transformation.</p>
<div class="pst-scrollable-table-container"><table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>object</p></th>
<th class="head"><p>meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">DFRCT.engine.mode</span></code></p></td>
<td><p>mode selected now</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">DFRCT.engine.modes</span></code></p></td>
<td><p>list of possible modes</p></td>
</tr>
</tbody>
</table>
</div>
<p>Here, <code class="docutils literal notranslate"><span class="pre">DFRCT</span></code> is the diffractometer object (such as <code class="docutils literal notranslate"><span class="pre">e4cv</span></code> above).</p>
</section>
</section>
<section id="steps-to-define-a-diffractometer-object">
<h2>Steps to define a diffractometer object<a class="headerlink" href="#steps-to-define-a-diffractometer-object" title="Link to this heading">#</a></h2>
<ol class="arabic simple">
<li><p>Identify the geometry.</p></li>
<li><p>Check that it is supported in the <a class="reference internal" href="geometries.html#module-hkl.geometries" title="hkl.geometries"><code class="xref py py-mod docutils literal notranslate"><span class="pre">geometries</span></code></a> module.</p></li>
<li><p>Create a custom subclass for the diffractometer.</p></li>
<li><p>Connect the real positioners with the control system motors.</p></li>
<li><p>(optional) Connect energy to the control system.</p></li>
<li><p>Define the diffractometer object from the custom subclass.</p></li>
</ol>
</section>
<section id="use-a-diffractometer-with-the-bluesky-runengine">
<h2>Use a Diffractometer with the bluesky RunEngine<a class="headerlink" href="#use-a-diffractometer-with-the-bluesky-runengine" title="Link to this heading">#</a></h2>
<p>The positioners of a <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer</span></code></a> object may be
used with the <a class="reference external" href="https://blueskyproject.io/bluesky/generated/bluesky.run_engine.RunEngine.html?highlight=runengine">bluesky RunEngine</a>
with any of the <a class="reference external" href="https://blueskyproject.io/bluesky/plans.html#pre-assembled-plans">pre-assembled plans</a> or
in custom plans of your own.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fourc</span> <span class="o">=</span> <span class="n">hkl</span><span class="o">.</span><span class="n">geometries</span><span class="o">.</span><span class="n">SimulatedE4CV</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"fourc"</span><span class="p">)</span>
<span class="c1"># steps not shown here:</span>
<span class="c1"># define a sample & orientation reflections, and compute UB matrix</span>
<span class="c1"># record the diffractometer metadata to a run</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">count</span><span class="p">([</span><span class="n">fourc</span><span class="p">]))</span>
<span class="c1"># relative *(h00)* scan</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">rel_scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">h</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mi">21</span><span class="p">))</span>
<span class="c1"># absolute *(0kl)* scan</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">k</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">,</span> <span class="mf">1.1</span><span class="p">,</span> <span class="n">fourc</span><span class="o">.</span><span class="n">l</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">21</span><span class="p">))</span>
<span class="c1"># absolute ``chi`` scan</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">chi</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">31</span><span class="p">))</span>
</pre></div>
</div>
<p>Keep in mind these considerations:</p>
<ol class="arabic">
<li><p>Don’t mix axis types (pseudos <em>v.</em> reals) in a scan. You can only
scan with either <em>pseudo</em> axes (<code class="docutils literal notranslate"><span class="pre">h</span></code>, <code class="docutils literal notranslate"><span class="pre">k</span></code>, <code class="docutils literal notranslate"><span class="pre">l</span></code>, <code class="docutils literal notranslate"><span class="pre">q</span></code>, …) or <em>real</em>
axes (<code class="docutils literal notranslate"><span class="pre">omega</span></code>, <code class="docutils literal notranslate"><span class="pre">tth</span></code>, <code class="docutils literal notranslate"><span class="pre">chi</span></code>, …) at one time. You cannot scan with
both types (such as <code class="docutils literal notranslate"><span class="pre">h</span></code> and <code class="docutils literal notranslate"><span class="pre">tth</span></code>) in a single scan (because the
<a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.forward" title="hkl.diffract.Diffractometer.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forward()</span></code></a> and
<a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.inverse" title="hkl.diffract.Diffractometer.inverse"><code class="xref py py-meth docutils literal notranslate"><span class="pre">inverse()</span></code></a> methods cannot
resolve). Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># Cannot scan both ``k`` and ``chi`` at the same time.</span>
<span class="c1"># This will raise a `ValueError` exception.</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">k</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">,</span> <span class="mf">1.1</span><span class="p">,</span> <span class="n">fourc</span><span class="o">.</span><span class="n">chi</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">21</span><span class="p">))</span>
</pre></div>
</div>
</li>
<li><p>When scanning with pseudo axes (<code class="docutils literal notranslate"><span class="pre">h</span></code>, <code class="docutils literal notranslate"><span class="pre">k</span></code>, <code class="docutils literal notranslate"><span class="pre">l</span></code>, <code class="docutils literal notranslate"><span class="pre">q</span></code>, …), first
check that all steps in the scan can be computed successfully with
the <a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer.forward" title="hkl.diffract.Diffractometer.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forward()</span></code></a> computation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fourc</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">1.9</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>Include the diffractometer object as an additional detector
to record the diffractometer metadata <a class="footnote-reference brackets" href="#id6" id="id5" role="doc-noteref"><span class="fn-bracket">[</span>3<span class="fn-bracket">]</span></a> as part of the scan.
For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fourc</span> <span class="o">=</span> <span class="n">hkl</span><span class="o">.</span><span class="n">geometries</span><span class="o">.</span><span class="n">SimulatedE4CV</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"fourc"</span><span class="p">)</span>
<span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">h</span><span class="p">,</span> <span class="mf">1.9</span><span class="p">,</span> <span class="mf">2.1</span><span class="p">,</span> <span class="mi">21</span><span class="p">))</span>
</pre></div>
</div>
</li>
<li><p>To save crystal orientation and reflections for later use,
include the diffractometer object as an additional detector
(as stated in consideration 3 above):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">RE</span><span class="p">(</span><span class="n">bp</span><span class="o">.</span><span class="n">scan</span><span class="p">([</span><span class="n">scaler</span><span class="p">,</span> <span class="n">fourc</span><span class="p">],</span> <span class="n">fourc</span><span class="o">.</span><span class="n">chi</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">31</span><span class="p">))</span>
<span class="c1"># ^^^^^</span>
</pre></div>
</div>
</li>
<li><p>To restore crystal lattice and orientation reflections from a previous
run, first use the <a class="reference external" href="https://blueskyproject.io/databroker/tutorials/search-and-lookup.html#find-runs-in-a-catalog">databroker</a>
to find the run. (The <a class="reference internal" href="util.html#hkl.util.list_orientation_runs" title="hkl.util.list_orientation_runs"><code class="xref py py-func docutils literal notranslate"><span class="pre">list_orientation_runs()</span></code></a> function
can list any recent runs with orientation information. It needs
the databroker catalog object.) With the run, use
<a class="reference internal" href="util.html#hkl.util.run_orientation_info" title="hkl.util.run_orientation_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">run_orientation_info()</span></code></a> to obtain
the orientation information.
Then call <a class="reference internal" href="util.html#hkl.util.restore_orientation" title="hkl.util.restore_orientation"><code class="xref py py-func docutils literal notranslate"><span class="pre">restore_orientation()</span></code></a>
with the run’s orientation information. Here is an example
with the <cite>fourc</cite> object created above and a previous run with
<code class="docutils literal notranslate"><span class="pre">scan_id</span> <span class="pre">=</span> <span class="pre">457</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># find a run</span>
<span class="n">hkl</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">list_orientation_runs</span><span class="p">(</span><span class="n">cat</span><span class="p">)</span>
<span class="c1"># get the run's orientation metadata</span>
<span class="n">info</span> <span class="o">=</span> <span class="n">hkl</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">run_orientation_info</span><span class="p">(</span><span class="n">cat</span><span class="p">[</span><span class="mi">457</span><span class="p">])</span>
<span class="c1"># restore the orientation</span>
<span class="n">hkl</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">restore_orientation</span><span class="p">(</span><span class="n">info</span><span class="p">[</span><span class="s2">"fourc"</span><span class="p">],</span> <span class="n">fourc</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>You should only restore orientation reflections from a <strong>matching</strong>
diffractometer geometry (such as <code class="docutils literal notranslate"><span class="pre">E4CV</span></code>). A <cite>ValueError</cite>
exception will be raised if the geometry names (one of the names
in <a class="reference internal" href="geometries.html#module-hkl.geometries" title="hkl.geometries"><code class="xref py py-mod docutils literal notranslate"><span class="pre">geometries</span></code></a>) do not match. To override this check
(at your own risk), replace <code class="xref py py-func docutils literal notranslate"><span class="pre">_check_geometry()</span></code>
with your own code.</p></li>
<li><p>A sample lattice can be restored into any
<a class="reference internal" href="diffract.html#hkl.diffract.Diffractometer" title="hkl.diffract.Diffractometer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Diffractometer</span></code></a> object, as long
as it has not already been defined (by name) in that object:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">info</span> <span class="o">=</span> <span class="n">hkl</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">run_orientation_info</span><span class="p">(</span><span class="n">cat</span><span class="p">[</span><span class="mi">457</span><span class="p">])</span>
<span class="n">hkl</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">restore_sample</span><span class="p">(</span><span class="n">info</span><span class="p">[</span><span class="s2">"fourc"</span><span class="p">],</span> <span class="n">fourc</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>If you want to save other information during a run, or save
this information in a different format, it is suggested to
write that information as a separate stream using a custom plan.</p></li>
</ol>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id6" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id5">3</a><span class="fn-bracket">]</span></span>
<p>The diffractometer metadata will be recorded in the scan’s
descriptor document and can be retrieved later for analysis or use in
other scans. Recorded data includes diffractometer name and
geometry, sample name and lattice, orientation reflections, … A
complete list of the metadata keys is available from the
diffractometer object as either an ophyd
<a class="reference external" href="https://blueskyproject.io/ophyd/signals.html#signals">Signal</a>
(such as <code class="docutils literal notranslate"><span class="pre">fourc.orientation_attrs.get()</span></code>) or a direct attribute (such
as <code class="docutils literal notranslate"><span class="pre">fourc._orientation_attrs</span></code>).</p>
</aside>
</aside>
</section>
</section>
</article>
<footer class="prev-next-footer d-print-none">
<div class="prev-next-area">
<a class="left-prev"
href="user_guide.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">User Guide</p>
</div>
</a>
<a class="right-next"
href="ready_to_use.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Simulated Diffractometers</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
</div>
</footer>
</div>
<dialog id="pst-secondary-sidebar-modal"></dialog>
<div id="pst-secondary-sidebar" class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">
<div class="sidebar-secondary-item">
<div
id="pst-page-navigation-heading-2"
class="page-toc tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav class="bd-toc-nav page-toc" aria-labelledby="pst-page-navigation-heading-2">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#definitions">Definitions</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#real-axis-positioner">real axis (positioner)</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#pseudo-axis-positioner">pseudo axis (positioner)</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#forward-transformation">forward (transformation)</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#inverse-transformation">inverse (transformation)</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#libhkl-support-library"><em>libhkl</em> support library</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#parts-of-a-diffractometer-object">Parts of a <cite>Diffractometer</cite> object</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#name">name</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#geometry">geometry</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#calc">calc</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#wavelength-and-energy">wavelength (and energy)</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sample">sample</a><ul class="nav section-nav flex-column">
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#lattice">lattice</a></li>
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#orientation">orientation</a><ul class="nav section-nav flex-column">
<li class="toc-h5 nav-item toc-entry"><a class="reference internal nav-link" href="#orientation-reflections">orientation reflections</a></li>
</ul>
</li>
</ul>
</li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#constraint">constraint</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mode">mode</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#steps-to-define-a-diffractometer-object">Steps to define a diffractometer object</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#use-a-diffractometer-with-the-bluesky-runengine">Use a Diffractometer with the bluesky RunEngine</a></li>
</ul>
</nav></div>
<div class="sidebar-secondary-item">
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/overview.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div></div>
</div></div>
</div>
<footer class="bd-footer-content">
</footer>
</main>
</div>
</div>
<!-- Scripts loaded after <body> so the DOM is not blocked -->
<script defer src="_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf"></script>
<script defer src="_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf"></script>
<footer class="bd-footer">
<div class="bd-footer__inner bd-page-width">
<div class="footer-items__start">
<div class="footer-item">
<p class="copyright">
© Copyright 2014-2023, Brookhaven National Laboratory.
<br/>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
<br/>
</p>
</div>
</div>
<div class="footer-items__end">
<div class="footer-item">
<p class="theme-version">
<!-- # L10n: Setting the PST URL as an argument as this does not need to be localized -->
Built with the <a href="https://pydata-sphinx-theme.readthedocs.io/en/stable/index.html">PyData Sphinx Theme</a> 0.16.1.
</p></div>
</div>
</div>
</footer>
</body>
</html>