-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPy16progs.html
More file actions
856 lines (810 loc) · 97.8 KB
/
Py16progs.html
File metadata and controls
856 lines (810 loc) · 97.8 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module Py16progs</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Py16progs</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/users/grp66007/dropbox/python/i16/py16/py16progs.py">c:\users\grp66007\dropbox\python\i16\py16\py16progs.py</a></font></td></tr></table>
<p><tt>Module: I16 Data analysis programs "Py16Progs.py"<br>
<br>
By Dan Porter, PhD<br>
Diamond<br>
2016<br>
<br>
Usage: <br>
******In Script********<br>
include the following lines at the top of your script<br>
<br>
import sys<br>
sys.path.insert(0,'/dls_sw/i16/software/python/Py16') # location of Py16Progs<br>
import Py16Progs as p16<br>
p16.filedir = '/dls/i16/data/2015/mt0000-1' # your experiment folder<br>
p16.savedir = '' # where to save output<br>
<br>
# Use functions:<br>
p16.<a href="#-checkexp">checkexp</a>()<br>
num = p16.<a href="#-latest">latest</a>()<br>
d= p16.<a href="#-readscan">readscan</a>(num)<br>
p16.<a href="#-plotscan">plotscan</a>(num)<br>
p16.<a href="#-plotpil">plotpil</a>(num)<br>
<br>
******In Console*******<br>
Run the file in the current console:<br>
>> cd /dls_sw/i16/software/python/Py16/<br>
>> ipython -i --matplotlib tk<br>
In the python console:<br>
>> import Py16progs as p16<br>
Change filedir: <br>
>> p16.filedir = '/dls/i16/data/2015/cm12169-2/CsFeSe' # your experiment folder<br>
<br>
# Use functions:<br>
>> d= p16.<a href="#-readscan">readscan</a>(12345) # generate data structure for scan number 12345<br>
>> d.eta # returns scan data for eta psudo-device<br>
>> d.metadata.Energy # returns metadata for scan (at start of scan) <br>
>> p16.<a href="#-checkexp">checkexp</a>() # experiment dates + scans numbers<br>
>> num = p16.<a href="#-latest">latest</a>() # Latest scan number<br>
<br>
**********************<br>
Some Useful Functions:<br>
d = <a href="#-readscan">readscan</a>(num) <br>
x,y,dy,varx,vary,ttl,d = <a href="#-getdata">getdata</a>(num/d,'varx','vary',save=None)<br>
x,y,z,varx,vary,varz,ttl = <a href="#-joindata">joindata</a>([nums],'varx','vary','varz')<br>
vol = <a href="#-getvol">getvol</a>(num)<br>
ROI_sum,ROI_maxval,ROI_bkg = <a href="#-pilroi">pilroi</a>(num,ROIcen,ROIsize,findpeak,peakregion)<br>
A = <a href="#-getmeta">getmeta</a>([nums],'Field')<br>
<br>
num = <a href="#-latest">latest</a>()<br>
<a href="#-checkexp">checkexp</a>()<br>
<a href="#-checkscan">checkscan</a>(num1=None,num2=None)<br>
<a href="#-checklog">checklog</a>(time=None,mins=2,cmd=False)<br>
<a href="#-prend">prend</a>(start,end)<br>
<a href="#-polflip">polflip</a>(sigsig,sigpi,fit='Gauss',output=False)<br>
<a href="#-metaprint">metaprint</a>(d1,d2=None)<br>
<a href="#-savedata">savedata</a>(num/d,'varx','vary')<br>
<br>
<a href="#-plotscan">plotscan</a>(num=None,vary='',fit=None,save=None)<br>
<a href="#-plotpil">plotpil</a>(num,cax=None,imnum=None)<br>
<a href="#-plotscans3D">plotscans3D</a>(scans,depvar='Ta',vary='',save=None)<br>
<br>
fit,err = <a href="#-fit_scans">fit_scans</a>(scans,depvar='Ta',vary='',save=None)<br>
<br>
out,err = <a href="#-peakfit">peakfit</a>(x,y,dy,type='dVoight')<br>
<br>
HHH,KKK,LLL = <a href="#-pixel2hkl">pixel2hkl</a>(num)<br>
XXX,YYY,ZZZ = <a href="#-pixel2xyz">pixel2xyz</a>(num)<br>
TTH,INT = <a href="#-pixel2tth">pixel2tth</a>(num)<br>
<br>
ROIcen_ij,ROIcen_frame = <a href="#-pilpeak">pilpeak</a>(Y,test = 1,disp=False)<br>
<a href="#-ispeak">ispeak</a>(Y,test = 1,disp=False)<br>
peak = <a href="#-peakfind">peakfind</a>(Y,cutoff=0.01)*<br>
<br>
<a href="#-labels">labels</a>(title,xlabel,ylabel,zlabel)<br>
vals = <a href="#-frange">frange</a>(start,stop=None,step=1)<br>
str = <a href="#-stfm">stfm</a>(val,err)<br>
<br>
<br>
Version 3.2<br>
Last updated: 23/10/17<br>
<br>
Version History:<br>
07/02/16 0.9 Program created from DansI16progs.py V3.0<br>
18/02/16 1.0 Functions renamed, readscan updated for errors, simplifications to outputs<br>
03/03/16 1.1 Tested on Beamline, removed errors, cleaned up<br>
08/03/16 1.2 Refinements after a week of beamline use<br>
15/04/16 1.3 New masks method in peak_fit<br>
05/05/16 1.4 Fixed bug that did integer normalisation of APD/counttime<br>
10/05/16 1.5 Added print buffer function<br>
19/05/16 1.6 Fixed 3D plotting bugs, new outputs on fit_scans, catch psi='unavailable' bug (psi=0)<br>
12/07/16 1.7 Ungraded peakfit with variable backgrouns, estimate input and new default values.<br>
10/08/16 1.8 Added logplot and diffplot options to plotscan<br>
08/09/16 1.9 Generalised getvol for any detector by pre-loading the first image<br>
21/09/16 2.0 Removed dnp.io.load. New title includes folder and new functions for lists of scan numbers<br>
07/10/16 2.1 Ordered keys in dataloader, some minor fixes<br>
17/10/16 2.2 Improved ROI functionality - _sfm to remove first frame<br>
14/12/16 2.3 Improved multiscan titles, funtions to write + load previous experiment directories for fast access<br>
20/12/16 2.4 Added checkscans and auto_varx/vary functions, added dont_normalise for none-normalisable values<br>
02/02/17 2.5 Added checkhkl and checkwl. Bugs fixed when using DifCalc (psi+azih not recorded)<br>
22/02/17 2.6 Added dead pixel mask for pilatus for experiments in Feb 2017<br>
13/06/17 2.7 Added <a href="#-getmeta">getmeta</a>() function<br>
24/07/17 2.8 Added d.metadata.hkl_str, fixing incorrect position bug. Various other fixes.<br>
01/08/17 2.9 Added check for large pilatus arrays.<br>
02/10/17 2.9 Added various misc functions, other bugs fixed<br>
06/10/17 3.0 Added pixel2hkl functions, incluing plots, other bug fixes<br>
17/10/17 3.1 Added choice of temperature sensor, d.metadata.temperature<br>
23/10/17 3.2 Added new plotting features, better multi-dimensional fits<br>
<br>
###FEEDBACK### Please submit your bug reports, feature requests or queries to: dan.porter@diamond.ac.uk<br>
<br>
@author: Dan Porter<br>
I16, Diamond Light Source<br>
2016</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="datetime.html">datetime</a><br>
<a href="glob.html">glob</a><br>
<a href="scipy.misc.html">scipy.misc</a><br>
</td><td width="25%" valign=top><a href="matplotlib.ticker.html">matplotlib.ticker</a><br>
<a href="numpy.html">numpy</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="matplotlib.pyplot.html">matplotlib.pyplot</a><br>
<a href="re.html">re</a><br>
<a href="sys.html">sys</a><br>
</td><td width="25%" valign=top><a href="tempfile.html">tempfile</a><br>
<a href="time.html">time</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="collections.html#OrderedDict">collections.OrderedDict</a>(<a href="__builtin__.html#dict">__builtin__.dict</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="Py16progs.html#dict2obj">dict2obj</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="dict2obj">class <strong>dict2obj</strong></a>(<a href="collections.html#OrderedDict">collections.OrderedDict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Convert dictionary object to class instance<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="Py16progs.html#dict2obj">dict2obj</a></dd>
<dd><a href="collections.html#OrderedDict">collections.OrderedDict</a></dd>
<dd><a href="__builtin__.html#dict">__builtin__.dict</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="dict2obj-__init__"><strong>__init__</strong></a>(self, dictvals, order<font color="#909090">=None</font>)</dt></dl>
<hr>
Methods inherited from <a href="collections.html#OrderedDict">collections.OrderedDict</a>:<br>
<dl><dt><a name="dict2obj-__delitem__"><strong>__delitem__</strong></a>(self, key, dict_delitem<font color="#909090">=<slot wrapper '__delitem__' of 'dict' objects></font>)</dt><dd><tt>od.<a href="#dict2obj-__delitem__">__delitem__</a>(y) <==> del od[y]</tt></dd></dl>
<dl><dt><a name="dict2obj-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>od.<a href="#dict2obj-__eq__">__eq__</a>(y) <==> od==y. Comparison to another OD is order-sensitive<br>
while comparison to a regular mapping is order-insensitive.</tt></dd></dl>
<dl><dt><a name="dict2obj-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-__iter__">__iter__</a>() <==> iter(od)</tt></dd></dl>
<dl><dt><a name="dict2obj-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>od.<a href="#dict2obj-__ne__">__ne__</a>(y) <==> od!=y</tt></dd></dl>
<dl><dt><a name="dict2obj-__reduce__"><strong>__reduce__</strong></a>(self)</dt><dd><tt>Return state information for pickling</tt></dd></dl>
<dl><dt><a name="dict2obj-__repr__"><strong>__repr__</strong></a>(self, _repr_running<font color="#909090">={}</font>)</dt><dd><tt>od.<a href="#dict2obj-__repr__">__repr__</a>() <==> repr(od)</tt></dd></dl>
<dl><dt><a name="dict2obj-__reversed__"><strong>__reversed__</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-__reversed__">__reversed__</a>() <==> reversed(od)</tt></dd></dl>
<dl><dt><a name="dict2obj-__setitem__"><strong>__setitem__</strong></a>(self, key, value, dict_setitem<font color="#909090">=<slot wrapper '__setitem__' of 'dict' objects></font>)</dt><dd><tt>od.<a href="#dict2obj-__setitem__">__setitem__</a>(i, y) <==> od[i]=y</tt></dd></dl>
<dl><dt><a name="dict2obj-clear"><strong>clear</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-clear">clear</a>() -> None. Remove all items from od.</tt></dd></dl>
<dl><dt><a name="dict2obj-copy"><strong>copy</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-copy">copy</a>() -> a shallow copy of od</tt></dd></dl>
<dl><dt><a name="dict2obj-items"><strong>items</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-items">items</a>() -> list of (key, value) pairs in od</tt></dd></dl>
<dl><dt><a name="dict2obj-iteritems"><strong>iteritems</strong></a>(self)</dt><dd><tt>od.iteritems -> an iterator over the (key, value) pairs in od</tt></dd></dl>
<dl><dt><a name="dict2obj-iterkeys"><strong>iterkeys</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-iterkeys">iterkeys</a>() -> an iterator over the keys in od</tt></dd></dl>
<dl><dt><a name="dict2obj-itervalues"><strong>itervalues</strong></a>(self)</dt><dd><tt>od.itervalues -> an iterator over the values in od</tt></dd></dl>
<dl><dt><a name="dict2obj-keys"><strong>keys</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-keys">keys</a>() -> list of keys in od</tt></dd></dl>
<dl><dt><a name="dict2obj-pop"><strong>pop</strong></a>(self, key, default<font color="#909090">=<object object></font>)</dt><dd><tt>od.<a href="#dict2obj-pop">pop</a>(k[,d]) -> v, remove specified key and return the corresponding<br>
value. If key is not found, d is returned if given, otherwise KeyError<br>
is raised.</tt></dd></dl>
<dl><dt><a name="dict2obj-popitem"><strong>popitem</strong></a>(self, last<font color="#909090">=True</font>)</dt><dd><tt>od.<a href="#dict2obj-popitem">popitem</a>() -> (k, v), return and remove a (key, value) pair.<br>
Pairs are returned in LIFO order if last is true or FIFO order if false.</tt></dd></dl>
<dl><dt><a name="dict2obj-setdefault"><strong>setdefault</strong></a>(self, key, default<font color="#909090">=None</font>)</dt><dd><tt>od.<a href="#dict2obj-setdefault">setdefault</a>(k[,d]) -> od.<a href="#dict2obj-get">get</a>(k,d), also set od[k]=d if k not in od</tt></dd></dl>
<dl><dt><a name="dict2obj-update"><strong>update</strong></a>(*args, **kwds)</dt><dd><tt>D.<a href="#dict2obj-update">update</a>([E, ]**F) -> None. Update D from mapping/iterable E and F.<br>
If E present and has a .<a href="#dict2obj-keys">keys</a>() method, does: for k in E: D[k] = E[k]<br>
If E present and lacks .<a href="#dict2obj-keys">keys</a>() method, does: for (k, v) in E: D[k] = v<br>
In either case, this is followed by: for k, v in F.<a href="#dict2obj-items">items</a>(): D[k] = v</tt></dd></dl>
<dl><dt><a name="dict2obj-values"><strong>values</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-values">values</a>() -> list of values in od</tt></dd></dl>
<dl><dt><a name="dict2obj-viewitems"><strong>viewitems</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-viewitems">viewitems</a>() -> a set-like object providing a view on od's items</tt></dd></dl>
<dl><dt><a name="dict2obj-viewkeys"><strong>viewkeys</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-viewkeys">viewkeys</a>() -> a set-like object providing a view on od's keys</tt></dd></dl>
<dl><dt><a name="dict2obj-viewvalues"><strong>viewvalues</strong></a>(self)</dt><dd><tt>od.<a href="#dict2obj-viewvalues">viewvalues</a>() -> an object providing a view on od's values</tt></dd></dl>
<hr>
Class methods inherited from <a href="collections.html#OrderedDict">collections.OrderedDict</a>:<br>
<dl><dt><a name="dict2obj-fromkeys"><strong>fromkeys</strong></a>(cls, iterable, value<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>OD.<a href="#dict2obj-fromkeys">fromkeys</a>(S[, v]) -> New ordered dictionary with keys from S.<br>
If not specified, the value defaults to None.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="collections.html#OrderedDict">collections.OrderedDict</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
<dl><dt><a name="dict2obj-__cmp__"><strong>__cmp__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__cmp__">__cmp__</a>(y) <==> cmp(x,y)</tt></dd></dl>
<dl><dt><a name="dict2obj-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>D.<a href="#dict2obj-__contains__">__contains__</a>(k) -> True if D has a key k, else False</tt></dd></dl>
<dl><dt><a name="dict2obj-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__ge__">__ge__</a>(y) <==> x>=y</tt></dd></dl>
<dl><dt><a name="dict2obj-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="dict2obj-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
<dl><dt><a name="dict2obj-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__gt__">__gt__</a>(y) <==> x>y</tt></dd></dl>
<dl><dt><a name="dict2obj-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__le__">__le__</a>(y) <==> x<=y</tt></dd></dl>
<dl><dt><a name="dict2obj-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__len__">__len__</a>() <==> len(x)</tt></dd></dl>
<dl><dt><a name="dict2obj-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#dict2obj-__lt__">__lt__</a>(y) <==> x<y</tt></dd></dl>
<dl><dt><a name="dict2obj-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#dict2obj-__sizeof__">__sizeof__</a>() -> size of D in memory, in bytes</tt></dd></dl>
<dl><dt><a name="dict2obj-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#dict2obj-get">get</a>(k[,d]) -> D[k] if k in D, else d. d defaults to None.</tt></dd></dl>
<dl><dt><a name="dict2obj-has_key"><strong>has_key</strong></a>(...)</dt><dd><tt>D.<a href="#dict2obj-has_key">has_key</a>(k) -> True if D has a key k, else False</tt></dd></dl>
<hr>
Data and other attributes inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#dict2obj-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-FWHM"><strong>FWHM</strong></a>(x, y, interpolate<font color="#909090">=False</font>)</dt><dd><tt>Calculate a simple FWHM from a peak</tt></dd></dl>
<dl><dt><a name="-abscor"><strong>abscor</strong></a>(eta<font color="#909090">=0</font>, chi<font color="#909090">=90</font>, delta<font color="#909090">=0</font>, mu<font color="#909090">=0</font>, gamma<font color="#909090">=0</font>, u<font color="#909090">=1.0</font>, disp<font color="#909090">=False</font>, plot<font color="#909090">=False</font>)</dt><dd><tt>Calculate absorption correction<br>
A = <a href="#-abscor">abscor</a>(eta,chi,delta,mu,gamma,u, disp, plot)<br>
eta/chi/delta/mu/gamma = diffractometer angles<br>
u = absoprtion coefficient<br>
disp = True/False - display information<br>
plot = True/False - plot diffractometer/sample orientation<br>
<br>
Usage:<br>
scans = range(584448,584481,1)<br>
eta = <a href="#-getmeta">getmeta</a>(scans,'eta')<br>
delta = <a href="#-getmeta">getmeta</a>(scans,'delta')<br>
chi = <a href="#-getmeta">getmeta</a>(scans,'chi')<br>
A=np.zeros(len(eta))<br>
for n in range(len(eta)): <br>
A[n] = <a href="#-abscor">abscor</a>(eta[n]-4.41, chi[n]+2.43, delta[n],disp=True)<br>
Icorrected = Iexp/A<br>
<br>
From: IT-C Secion 6.3.3 Absorption corrections<br>
Table 6.3.3.1. (1) Reflection from a crystal slab with negligible transmission<br>
A = sin(theta - phi) / mu( sin(theta-phi) + sin(theta+phi) )<br>
<br>
A = Transmission coefficient. (Absorption correction A*=1/A) <br>
"The reduction in the intensity of an x-ray reflection" <br>
Iobs = A*Iorig<br>
Icorrected = Iobs/A<br>
theta = Bragg angle<br>
phi = "the crystal planes are inclined at an angle phi to the extended face and the normal in the plane of the incidnend and diffracted beams"<br>
mu = absorption coefficient</tt></dd></dl>
<dl><dt><a name="-auto_varx"><strong>auto_varx</strong></a>(num)</dt><dd><tt>Determine the scanned variable</tt></dd></dl>
<dl><dt><a name="-auto_vary"><strong>auto_vary</strong></a>(num)</dt><dd><tt>Determine the default scannable</tt></dd></dl>
<dl><dt><a name="-bindata"><strong>bindata</strong></a>(X, Y, binsep<font color="#909090">=0.01</font>, bin_cen<font color="#909090">=None</font>, bin_func<font color="#909090">=<function nanmean></font>)</dt><dd><tt>Bins the data into bins separated by binsep. Values within the bin are averaged <br>
CEN,INT = <a href="#-bindata">bindata</a>(X,Y,binsep=0.01)<br>
or:<br>
CEN,INT = <a href="#-bindata">bindata</a>(X,Y,bin_cen=CEN)<br>
<br>
Note that np.nanmean is used to average values within each bin, which can be used<br>
to only average values with signal in. Other functions can be used by specifying bin_func:<br>
CEN,INT = <a href="#-bindata">bindata</a>(X,Y,0.01,bin_func=np.max)<br>
<br>
E.G.<br>
tth,ival = <a href="#-pixel2tth">pixel2tth</a>(num)<br>
ival[ival<1] = np.nan<br>
CEN,INT = <a href="#-bindata">bindata</a>(tth,ival,0.01)</tt></dd></dl>
<dl><dt><a name="-c2th"><strong>c2th</strong></a>(HKL<font color="#909090">=[0, 0, 1]</font>, scan<font color="#909090">=0</font>)</dt><dd><tt>Calculate the 2-theta value of a reflection at the given scan's energy</tt></dd></dl>
<dl><dt><a name="-checkexp"><strong>checkexp</strong></a>()</dt><dd><tt>Check experiment folder data</tt></dd></dl>
<dl><dt><a name="-checklog"><strong>checklog</strong></a>(time<font color="#909090">=None</font>, mins<font color="#909090">=2</font>, cmd<font color="#909090">=False</font>, find<font color="#909090">=None</font>)</dt><dd><tt>Look at experiment log file <br>
<a href="#-checklog">checklog</a>(time,mins,commands,findstr)<br>
time = None - Uses current time (default)<br>
time = scan number (uses start time of this scan), 0 gives latest scan<br>
time = [hour,(min),(day),(month),(year)], () values set to default, defaults are time of last scan<br>
time = '2015-07-07 13:50:08,000' <br>
mins = log file will display from time-mins to time<br>
mins = 'all' - display whole log from first scan time<br>
commands = True/False - only display command strings<br>
find = only display lines that include findstr</tt></dd></dl>
<dl><dt><a name="-checkpeaks"><strong>checkpeaks</strong></a>(num, test<font color="#909090">=1</font>, vary<font color="#909090">=''</font>)</dt><dd><tt>Check multiple scans for peaks</tt></dd></dl>
<dl><dt><a name="-checkscan"><strong>checkscan</strong></a>(num1<font color="#909090">=None</font>, num2<font color="#909090">=None</font>, showval<font color="#909090">=None</font>)</dt><dd><tt>Get run number information, <br>
checknum(#) Display lots of information about a single scan<br>
checknum(first,last) List all the scans from first to last with brief info<br>
checknum([run1,run2,...]) List all the scans in the list or array<br>
<br>
if # <= 0, # will be given as <a href="#-latest">latest</a>()-#<br>
<br>
checknum(...,showval='phi'): also display infomation from a variable, such as 'phi'</tt></dd></dl>
<dl><dt><a name="-checkscans"><strong>checkscans</strong></a>(num1<font color="#909090">=None</font>, num2<font color="#909090">=None</font>, showval<font color="#909090">=None</font>, find_scans<font color="#909090">=None</font>)</dt><dd><tt>Get brief info about each scan in a list<br>
<br>
<a href="#-checkscans">checkscans</a>([587892,587893,587894])<br>
<br>
<a href="#-checkscans">checkscans</a>(...,showval='phi') >> also display infomation from a variable, such as 'phi'<br>
<br>
<a href="#-checkscans">checkscans</a>(...,find_scans='eta') >> only display 'eta' scans</tt></dd></dl>
<dl><dt><a name="-clear_prev_exp"><strong>clear_prev_exp</strong></a>()</dt><dd><tt>Clear the previous experiment + analysis directories files</tt></dd></dl>
<dl><dt><a name="-conv_gauss"><strong>conv_gauss</strong></a>(y, window_size<font color="#909090">=31</font>, widval<font color="#909090">=0.2</font>)</dt><dd><tt>smooth data using covolution with gaussian</tt></dd></dl>
<dl><dt><a name="-create_analysis_file"><strong>create_analysis_file</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, fit_type<font color="#909090">='pVoight'</font>, bkg_type<font color="#909090">='flat'</font>, peaktest<font color="#909090">=1</font>, norm<font color="#909090">=True</font>, abscor<font color="#909090">=None</font>, plot<font color="#909090">='all'</font>, show_fits<font color="#909090">=True</font>, mask_cmd<font color="#909090">=None</font>, estvals<font color="#909090">=None</font>, xrange<font color="#909090">=None</font>, sortdep<font color="#909090">=True</font>, Nloop<font color="#909090">=10</font>, Binit<font color="#909090">=1e-05</font>, Tinc<font color="#909090">=2</font>, change_factor<font color="#909090">=0.5</font>, converge_max<font color="#909090">=100</font>, min_change<font color="#909090">=0.01</font>, savePLOT<font color="#909090">=False</font>, saveFIT<font color="#909090">=False</font>)</dt><dd><tt>Creates a new python analysis script in the anaysis folder<br>
The script will contain all the python code to call the Py16progs module, load the scan data and<br>
run an automated fit routine.<br>
Inputs: - See fit_scans for a description of the inputs</tt></dd></dl>
<dl><dt><a name="-d2tth"><strong>d2tth</strong></a>(dspace, energy_kev)</dt><dd><tt>Converts array of d-spacings in A to two-theta in degrees</tt></dd></dl>
<dl><dt><strong>error_func</strong> <em>lambda</em> x</dt></dl>
<dl><dt><a name="-exp_list_add"><strong>exp_list_add</strong></a>()</dt><dd><tt>Creates/appends files in the system Temp directory to store previously used experiment folders</tt></dd></dl>
<dl><dt><a name="-exp_list_get"><strong>exp_list_get</strong></a>()</dt><dd><tt>Loads a list of directories of previous experiments</tt></dd></dl>
<dl><dt><a name="-findfile"><strong>findfile</strong></a>(num, topdir<font color="#909090">=None</font>)</dt><dd><tt>Find the experiment directory of a scan number</tt></dd></dl>
<dl><dt><a name="-findranges"><strong>findranges</strong></a>(scannos, sep<font color="#909090">=':'</font>)</dt><dd><tt>Convert a list of numbers to a simple string</tt></dd></dl>
<dl><dt><a name="-fit_scans"><strong>fit_scans</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, fit_type<font color="#909090">='pVoight'</font>, bkg_type<font color="#909090">='flat'</font>, peaktest<font color="#909090">=1</font>, norm<font color="#909090">=True</font>, abscor<font color="#909090">=None</font>, plot<font color="#909090">='all'</font>, show_fits<font color="#909090">=True</font>, mask_cmd<font color="#909090">=None</font>, estvals<font color="#909090">=None</font>, xrange<font color="#909090">=None</font>, sortdep<font color="#909090">=True</font>, Nloop<font color="#909090">=10</font>, Binit<font color="#909090">=1e-05</font>, Tinc<font color="#909090">=2</font>, change_factor<font color="#909090">=0.5</font>, converge_max<font color="#909090">=100</font>, min_change<font color="#909090">=0.01</font>, savePLOT<font color="#909090">=False</font>, saveFIT<font color="#909090">=False</font>)</dt><dd><tt> Automated routine to fit peaks and plot results within runs of multiple scans dependent <br>
on another variable, such as temperature, energy or azimuthal depdences.<br>
<br>
<a href="#-fit_scans">fit_scans</a>(scans,depvar='Ta',vary='',fit_type = 'pVoight',plot='all')<br>
OR<br>
val,err = <a href="#-fit_scans">fit_scans</a>(scans,depvar='Ta',vary='',fit_type = 'pVoight',plot=None)<br>
<br>
INPUTS:<br>
scans : list/array of scan numbers to use<br>
depvar : ('Ta') : Independent variable, e.g. 'Ta','Energy','psi'<br>
vary : ('') : Dependent variable e.g. 'APD', 'roi1_sum', 'peakroi' or '' for automatic<br>
varx : ('') : Independent axis variable e.g. 'eta','chi','delta', or '' for automatic<br>
fit_type : ('pVoight): Type of fit to perform e.g. 'Simple','pVoight','Lorentz','Gauss'<br>
bkg_type : ('flat') : Type of background to use e.g. 'flat','slope','step'<br>
peaktest : (10) : Parameter to determine whether a peak exists, see help(ispeak) <br>
norm : (True) : Data normalised by time, transmission + ring current<br>
abscor : (None) : Absorption coefficient for material, None switches off correction<br>
plot : ('all') : Create plot of fits at end. 'all' plots all paramters, 'int' plot integrated area, None doesn't plot<br>
show_fits : (False) : Generate plots for all scans and show fits (True/False)<br>
mask_cmd : (None) : Define regions to remove, e.g. [ ['x<-1','x>1','np.abs(x-34)>0.1'], [x<-1.2','x>1.2'] ]<br>
estvals : (None) : Define initial estimates of peak parameters, e.g. [height,cen,wid,bkg,slope]<br>
xrange : (None) : Give the plots a specific xrange e.g. [0,300]<br>
sortdep : (True) : Sort the final result by the depdent variable to give better plots (True/False)<br>
Nloop : (100) : Number of RMC iterations of fit to perform, 0 to turn off RMC fitting<br>
Binit : (1e-5) : Initial inverse-temperature for RMC<br>
Tinc : (2) : RMC temperature increase factor<br>
change_factor : (0.5) : RMC - width of normal distribution about which the estimate parameters are randomly varied<br>
converge_max : (100) : RMC is converged when converge_max is reached<br>
min_change : (0.01) : RMC - converge value in increased by one when the relative change is less than this<br>
savePLOT : (None) : Save a jpg of the plot in the default directory (True/'Name.jpg'/None)<br>
saveFIT : (None) : Save a text file of the fits in the default directory (True/'Name.txt'/None)<br>
<br>
OUTPUTS:<br>
val : Fitted values:<br>
val['Scan Number']<br>
val[depvar]<br>
val['Peak Height']<br>
val['Peak Centre']<br>
val['FWHM']<br>
val['Lorz frac']<br>
val['Background']<br>
val['Area']<br>
val['CHI2 per dof']<br>
err : Errors on fitted values<br>
err['Scan Number']<br>
err['Peak Height']<br>
err['Peak Centre']<br>
err['FWHM']<br>
err['Lorz frac']<br>
err['Background']<br>
err['Area']<br>
out['CHI2 per dof']<br>
<br>
NOTES:<br>
> for psi scans, angles will automatically be placed between 0 and 360 degrees, unless xrange is set<br>
> if data has been saved with saveFIT=True, fitted values can be regained using:<br>
val,err = <a href="#-load_fits">load_fits</a>(scans,depvar='Ta',fit_type='pVoight')<br>
<br>
PLOTS:<br>
"plot" keyword accepts the following as a single string or list of strings:<br>
> 'all' - a single figure with subplots of integrated intensity, width, centre, background etc.<br>
> 'int' - a figure with a single axis showing the integrated intensity<br>
> 'wid' - a figure with a single axis showing the fitted FWHM<br>
> 'cen' - a figure with a single axis showing the fitted centre<br>
> 'surface' - *2D fits only!* plots integrated intensities vs x and y data<br>
<br>
MASKS:<br>
> Masks define regions of each scan to remove<br>
> input "mask_cmd" takes string arguments that will be evaluated <br>
> These string arguments should be boolean statements about the variables x, y or dy<br>
> Any TRUE values will be removed<br>
> mask_cmd requires a list of lists as an input, where the each scan has its own list of string arguments<br>
> If only 1 item is given, it will be used in all scans<br>
> E.G.<br>
> mask_cmd = [['x>1']] # will remove values in all scans where x>1<br>
> mask_cmd = [[np.abs(x-1.4)<0.1]] # will remove values in all scans within 0.1 of 1.4<br>
> mask_cmd = [['x>1','x<-1']] # will remove values in all scans where x>1 and where x<-1<br>
> mask_cmd = [['x>1'],['x>2'],['x>1'],...] # Remove different regions in different scans, MUST be same length as scans<br>
<br>
ESTIMATES:<br>
> Estimate the initial parameters of each peak<br>
> input "estvals" takes list of lists, where each list contains initial parameters for each scan<br>
> E.G. For gaussian + slope:<br>
> estvals = [height,cen,wid,bkg,slope] # same for all scans<br>
> estvals = [[height1,cen1,wid1,bkg1,slope1],[height2,cen2,wid2,bkg2,slope2],...] # Different for each scan<br>
<br>
FITTING PROCEDURE:<br>
></tt></dd></dl>
<dl><dt><a name="-fittest"><strong>fittest</strong></a>(x, y, dy<font color="#909090">=None</font>, tryall<font color="#909090">=False</font>, disp<font color="#909090">=False</font>)</dt><dd><tt>Attempt multiple fit types and return the best</tt></dd></dl>
<dl><dt><a name="-frange"><strong>frange</strong></a>(start, stop<font color="#909090">=None</font>, step<font color="#909090">=1</font>)</dt><dd><tt>Like np.arange but ends at stop, rather than stop-step</tt></dd></dl>
<dl><dt><a name="-gauss"><strong>gauss</strong></a>(x, height<font color="#909090">=1</font>, cen<font color="#909090">=0</font>, FWHM<font color="#909090">=0.5</font>, bkg<font color="#909090">=0</font>)</dt><dd><tt>Define Gaussian</tt></dd></dl>
<dl><dt><a name="-gauss2D"><strong>gauss2D</strong></a>((X, Y), height<font color="#909090">=1</font>, cen_x<font color="#909090">=0</font>, cen_y<font color="#909090">=0</font>, FWHM_x<font color="#909090">=0.5</font>, FWHM_y<font color="#909090">=0.5</font>, bkg<font color="#909090">=0</font>)</dt><dd><tt>Define 2D Gaussian</tt></dd></dl>
<dl><dt><a name="-gaussfit2D"><strong>gaussfit2D</strong></a>(cut)</dt><dd><tt>Fit a peak in a pilatus image ***Unfinished***</tt></dd></dl>
<dl><dt><a name="-get_all_scannos"><strong>get_all_scannos</strong></a>()</dt><dd><tt>Returns the scan numbers available in filedir</tt></dd></dl>
<dl><dt><a name="-getdata"><strong>getdata</strong></a>(num<font color="#909090">=None</font>, varx<font color="#909090">=''</font>, vary<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, abscor<font color="#909090">=None</font>)</dt><dd><tt>Get useful values from scans<br>
x,y,dy,varx,vary,ttl,d = <a href="#-getdata">getdata</a>(#/d,'varx','vary')<br>
<br>
vary can also call re-intergrate pilatus regions of interest:<br>
vary = 'nroipeak' - search for peak and create roi around it<br>
vary = 'nroipeakbkg' - subtract average background defined outside roi<br>
vary = 'nroi[110,242,75,67]' - creates roi [ceni,cenj,widi,widj]<br>
vary = 'nroi[31,31]' - creates centred roi with size [widi,widj]<br>
vary = 'nroi' - creates roi2 like roi<br>
vary = 'nroibkg' - as above but with background subtraction</tt></dd></dl>
<dl><dt><a name="-getmeta"><strong>getmeta</strong></a>(nums<font color="#909090">=None</font>, field<font color="#909090">='Energy'</font>)</dt><dd><tt>Get metadata from multiple scans and return array of values<br>
Usage: A = <a href="#-getmeta">getmeta</a>( [nums], 'field')<br>
[nums] = list of scan numbers<br>
field = name of metadata field<br>
A = array of values from each scan with same length as nums<br>
Any scans that do not contain field are returned 0</tt></dd></dl>
<dl><dt><a name="-getmetas"><strong>getmetas</strong></a>(nums<font color="#909090">=[0]</font>, fields<font color="#909090">=['Energy']</font>)</dt><dd><tt>Get several metadata values from multiple scans and return list of values<br>
Usage: A = <a href="#-getmetas">getmetas</a>( [nums], 'field')<br>
[nums] = list of scan numbers / or nums=12345<br>
fields = name or list of metadata field/ fields<br>
A = list of values from each scan with same length as nums<br>
Any scans that do not contain field are returned NaN</tt></dd></dl>
<dl><dt><a name="-getvol"><strong>getvol</strong></a>(num, ROIcen<font color="#909090">=None</font>, ROIsize<font color="#909090">=None</font>)</dt><dd><tt>Load Pilatus images into a single volume: <br>
vol=<a href="#-getvol">getvol</a>(#/d)<br>
# is the scan number or dataloader from readscan<br>
vol is a [n x m x o] sized numpy array, where n and m are the size of the <br>
pilatus detector (195 x 487) and o is the length of the scan.<br>
<br>
The volume from a region of interest can be obtained using:<br>
vol=<a href="#-getvol">getvol</a>(#/d,ROIcen=[110,242],ROIsize=[31,31])</tt></dd></dl>
<dl><dt><a name="-ispeak"><strong>ispeak</strong></a>(Y, dY<font color="#909090">=None</font>, test<font color="#909090">=1</font>, disp<font color="#909090">=False</font>, return_rat<font color="#909090">=False</font>)</dt><dd><tt>Determines whether a peak exists in the given dataset</tt></dd></dl>
<dl><dt><a name="-joindata"><strong>joindata</strong></a>(nums<font color="#909090">=None</font>, varx<font color="#909090">=''</font>, vary<font color="#909090">='Energy'</font>, varz<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, abscor<font color="#909090">=None</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Get useful values from scans, join multiple scans together, output joined arrays<br>
x,y,z,varx,vary,varz,ttl = <a href="#-joindata">joindata</a>([nums],'varx','vary','varz')<br>
<br>
x = nxm array of scanned values, where n is the length of the scan and m is the number of scans<br>
y = nxm array of values that change with each scan<br>
z = nxm array of measured values<br>
varx,vary,varz = names of scan values<br>
ttl = title generated for these scans</tt></dd></dl>
<dl><dt><a name="-labels"><strong>labels</strong></a>(ttl<font color="#909090">=None</font>, xvar<font color="#909090">=None</font>, yvar<font color="#909090">=None</font>, zvar<font color="#909090">=None</font>, size<font color="#909090">='Normal'</font>)</dt><dd><tt>Add good labels to current plot</tt></dd></dl>
<dl><dt><a name="-latest"><strong>latest</strong></a>()</dt><dd><tt>Get the latest run during and experiment</tt></dd></dl>
<dl><dt><a name="-linefit"><strong>linefit</strong></a>(x, y, dy<font color="#909090">=None</font>, disp<font color="#909090">=False</font>)</dt><dd><tt>Fit a line to data, y = mx + c<br>
<br>
fit,err = <a href="#-linefit">linefit</a>(x,y,dy,disp=False)<br>
x,y = arrays of data to fit<br>
dy = error bars on each y value (or leave as None)<br>
disp = True/False display results<br>
<br>
fit/err = dicts of results with entries:<br>
'Gradient' - the gradient of the line (m)<br>
'Intercept' - the intercept (c)<br>
'x' - x values, same as x<br>
'y' - the fitted y values for each x<br>
<br>
Note: a matching line can be generated with:<br>
y = <a href="#-straightline">straightline</a>(x,grad=fit['Gradient'],inter=fit['Intercept'])</tt></dd></dl>
<dl><dt><a name="-load_fits"><strong>load_fits</strong></a>(scans<font color="#909090">=[0]</font>, depvar<font color="#909090">='Ta'</font>, plot<font color="#909090">=None</font>, fit_type<font color="#909090">='pVoight'</font>, file<font color="#909090">=None</font>, disp<font color="#909090">=False</font>, save<font color="#909090">=False</font>, **fitopt)</dt><dd><tt> Load previously fitted data from <a href="#-fit_scans">fit_scans</a>(), assuming it completed succesfully and was saved.<br>
> The inputs are used to determine the automatic filename<br>
> Both the values and error files are read<br>
> Plots can be re-generated<br>
> A typical filename is: 'Ta ScansFIT 00001-00010 pVoight.dat'<br>
<br>
val,err = <a href="#-load_fits">load_fits</a>(scans,depvar='Ta',fit_type = 'pVoight',plot=None)<br>
<br>
INPUTS:<br>
scans : [N,M] : list of scan numbers used in <a href="#-fit_scans">fit_scans</a>(), only the first and final values are required<br>
depvar : 'Ta' : Independent variable, e.g. 'Ta','Energy','psi'<br>
fit_type : 'pVoight : Type of fit to perform e.g. 'Simple','pVoight','Lorentz','Gauss'<br>
plot : None : Plot the loaded fit data, available: [None,'all','int','cen','wid']<br>
file : None : If given, this filename will be used to open the data files<br>
disp : False : If True, prints the data on the console<br>
save : False : If true, saves images of the plots<br>
ALTERNATIVE:<br>
scans : 'filename': Name of .dat file where fit data is stored (no other parameters are required) <br>
OUTPUTS:<br>
val : Fitted values<br>
val['Scan Number']<br>
val[depvar]<br>
val['Peak Height']<br>
val['Peak Centre']<br>
val['FWHM']<br>
val['Lorz frac']<br>
val['Background']<br>
val['Area']<br>
val['CHI2 per dof']<br>
<br>
err : Errors on fitted values<br>
err['Scan Number']<br>
err['Peak Height']<br>
err['Peak Centre']<br>
err['FWHM']<br>
err['Lorz frac']<br>
err['Background']<br>
err['Area']<br>
err['CHI2 per dof']<br>
<br>
E.G. val,err = <a href="#-load_fits">load_fits</a>([572138,572368],depvar=['sx', 'sy'],fit_type='Gauss')<br>
E.G. val,err = <a href="#-load_fits">load_fits</a>('sx sy ScansFIT 572138-572368 Gauss')</tt></dd></dl>
<dl><dt><a name="-loaddata"><strong>loaddata</strong></a>(name)</dt><dd><tt>Load data saved using savedata<br>
x,y,dy = <a href="#-loaddata">loaddata</a>(name)<br>
<br>
name = str as given to savedata, no extention<br>
x,y,dy = arrays of data as saved<br>
<br>
E.G.<br>
x = [1,2,3,4]<br>
y = [2.4,56,43,1e6]<br>
dy = np.sqrt(y)<br>
<a href="#-savedata">savedata</a>('test',x,y,dy,header='lovely data')<br>
x,y,dy = <a href="#-loaddata">loaddata</a>('test')</tt></dd></dl>
<dl><dt><a name="-loadscan"><strong>loadscan</strong></a>(num, vary<font color="#909090">=None</font>)</dt><dd><tt>Load a scan.dat file saved with savescan from the analysis folder</tt></dd></dl>
<dl><dt><a name="-lorentz"><strong>lorentz</strong></a>(x, height<font color="#909090">=1</font>, cen<font color="#909090">=0</font>, FWHM<font color="#909090">=0.5</font>, bkg<font color="#909090">=0</font>)</dt><dd><tt>Define Lorentzian</tt></dd></dl>
<dl><dt><a name="-maskvals"><strong>maskvals</strong></a>(x, y, dy, mask_cmd)</dt><dd><tt>Returns arrays masked by requested rules<br>
Allows you to remove regions of a scan easily.<br>
e.g. x,y,dy = <a href="#-maskvals">maskvals</a>(x,y,dy,['x<0'])<br>
<br>
Masks should be a list of strings<br>
Each string should define an evaluatable statement that defines a region of x or y<br>
Each defined region will be REMOVED<br>
examples: <br>
'x<-1'<br>
'x>1'<br>
'np.abs(x-34)>0.1']<br>
[x<-1.2','x>1.2']</tt></dd></dl>
<dl><dt><a name="-metaprint"><strong>metaprint</strong></a>(d1, d2<font color="#909090">=None</font>)</dt><dd><tt>Print metadata of a scan:<br>
metadata(d)<br>
OR compare metadata of two scans:<br>
metadata(d1,d2)</tt></dd></dl>
<dl><dt><a name="-mini_string_range"><strong>mini_string_range</strong></a>(scannos, sep<font color="#909090">=':'</font>)</dt><dd><tt>Convert a list of numbers to a simple string</tt></dd></dl>
<dl><dt><a name="-numbers2string"><strong>numbers2string</strong></a>(scannos, sep<font color="#909090">=':'</font>)</dt><dd><tt>Convert a list of numbers to a simple string</tt></dd></dl>
<dl><dt><a name="-orderpar"><strong>orderpar</strong></a>(x, Tc<font color="#909090">=100</font>, beta<font color="#909090">=0.5</font>, amp<font color="#909090">=1</font>)</dt><dd><tt>Generate an order paramter</tt></dd></dl>
<dl><dt><a name="-orderparfit"><strong>orderparfit</strong></a>(x, y, dy<font color="#909090">=None</font>, Tc<font color="#909090">=None</font>, disp<font color="#909090">=None</font>)</dt><dd><tt>Fit an order parameter to a temperature dependence y = f(T)</tt></dd></dl>
<dl><dt><a name="-peakfind"><strong>peakfind</strong></a>(Y, cutoff<font color="#909090">=0.01</font>)</dt><dd><tt>Finds peaks in the given 1D spectrum</tt></dd></dl>
<dl><dt><a name="-peakfit"><strong>peakfit</strong></a>(x, y, dy<font color="#909090">=None</font>, type<font color="#909090">='pVoight'</font>, bkg_type<font color="#909090">='flat'</font>, peaktest<font color="#909090">=1</font>, estvals<font color="#909090">=None</font>, Nloop<font color="#909090">=10</font>, Binit<font color="#909090">=1e-05</font>, Tinc<font color="#909090">=2</font>, change_factor<font color="#909090">=0.5</font>, converge_max<font color="#909090">=100</font>, min_change<font color="#909090">=0.01</font>, interpolate<font color="#909090">=False</font>, debug<font color="#909090">=False</font>, plot<font color="#909090">=False</font>, disp<font color="#909090">=False</font>)</dt><dd><tt>General Peak Fitting function to fit a profile to a peak in y = f(x)<br>
Allows several possible profiles to be used and can try to find the best estimates for <br>
fitting parameters using an RMC-based least-squares routine.<br>
<br>
out,err = <a href="#-peakfit">peakfit</a>(x,y)<br>
out,err = <a href="#-peakfit">peakfit</a>(x,y,dy=None,type='pVoight',**fitoptions)<br>
<br>
**fitoptions:<br>
Basic parameters:<br>
x = array of the dependent variable, e.g. eta, mu, phi<br>
y = array of the independent variable, e.g. maxval,roi1_sum, APD<br>
dy = errors on y (default = None)<br>
type = function type. Allowed: 'pVoight' (default), 'Gauss', 'Lorentz', 'Simple'*<br>
bkg_type = background type. Allowed: 'flat' (default), 'slope', 'step'<br>
RMC options:<br>
Nloop = Number of iterations per temperature, default = 0 (RMC off)**<br>
Binit = Initial values of 1/kbT used for RMC, default = 1e-3 (lower = Higher temp)<br>
Tinc = After Nloop steps, the temperature is increased by factor Tinc, default = 2<br>
change_factor = Each parameter is multiplied by a normal distribution around 1 with width change_factor. (Default = 0.5)<br>
converge_max = Iterations will end when convergece reaches converge_max. (Default = 100)<br>
min_change = Relative variation of parameters must be below min_change to increase convergence value. (Default = 0.01)<br>
Output options:<br>
interpolate = True: The output fit will have interpolated (much finer) values in x and y. (Default = False)<br>
debug = True: Output of each iteration is displayed. (Default = False)<br>
disp = True: The final fitted parameters will be displayed in the command line. (Dafault = False)<br>
<br>
Output:<br>
out = dict with fitted parameters<br>
err = dict with errors on fitted paramters<br>
<br>
out.keys() = ['Peak Height','Peak Centre','FWHM','Lorz frac','Background','Area','CHI**2','CHI2 per dof','x','y']<br>
<br>
* selecting type='simple' will not fit the data, just provide a very simple estimation.<br>
** Nloop must be set > 0 for the RMC routine to be used, for Nloop=0 or converge_max=0, a simple gradient decend method from a simple estimation is used.<br>
<br>
Notes on the RMC routine:<br>
- see the code</tt></dd></dl>
<dl><dt><a name="-pil_peaks"><strong>pil_peaks</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, ROIsize<font color="#909090">=[31, 31]</font>, cax<font color="#909090">=None</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Show pilatus peak search results</tt></dd></dl>
<dl><dt><a name="-pilpeak"><strong>pilpeak</strong></a>(vol, disp<font color="#909090">=False</font>)</dt><dd><tt>Find peak in pilatus detector, within peakregion<br>
[pk_i,pk_j],frame = <a href="#-pilpeak">pilpeak</a>(vol)<br>
<br>
Currently uses a very basic search that rebins the volume into courser bins,<br>
averaging the intensities then finding the position of the max bin.</tt></dd></dl>
<dl><dt><a name="-pilpeaks"><strong>pilpeaks</strong></a>(vol, rebin_step<font color="#909090">=[4, 4, 2]</font>, peakheight<font color="#909090">=100</font>, disp<font color="#909090">=False</font>)</dt><dd><tt>Find peak in pilatus detector, within peakregion<br>
[pk_i,pk_j],frame = <a href="#-pilpeak">pilpeak</a>(vol)<br>
<br>
Currently uses a very basic search that rebins the volume into courser bins,<br>
averaging the intensities then finding the position of the max bin.</tt></dd></dl>
<dl><dt><a name="-pilroi"><strong>pilroi</strong></a>(vol, ROIcen<font color="#909090">=None</font>, ROIsize<font color="#909090">=[31, 31]</font>, disp<font color="#909090">=False</font>)</dt><dd><tt>Define new ROI in Pilatus Detector<br>
ROI_sum,ROI_maxval,ROI_bkg = <a href="#-pilroi">pilroi</a>(vol,ROIcen,ROIsize)</tt></dd></dl>
<dl><dt><a name="-pixel2hkl"><strong>pixel2hkl</strong></a>(num, detdim<font color="#909090">=[195, 487]</font>, UB<font color="#909090">=None</font>)</dt><dd><tt>Generate hkl coordinates of detector pixel positions<br>
HHH,KKK,LLL = <a href="#-pixel2hkl">pixel2hkl</a>(#/d, detdim,UB)<br>
<br>
detdim = detector dimesions def=[195,487] (Pilatus 100K)<br>
UB = orientation matrix, def=None (uses UB stored in metadata)<br>
<br>
Uses the pilatus parameters local:"pilpara" to define detector distance, centre etc.<br>
pilpara=[119.536,1904.17,44.4698,0.106948,-0.738038,412.19,-0.175,-0.175]<br>
<br>
Code copied and adapted from Alessandro's readpil.hklmatrix()<br>
<br>
Only works on delta, gam, eta, chi, phi scans - not energy or hkl scans!</tt></dd></dl>
<dl><dt><a name="-pixel2tth"><strong>pixel2tth</strong></a>(num, detdim<font color="#909090">=[195, 487]</font>, centre_only<font color="#909090">=False</font>)</dt><dd><tt>Generate two-theta coordinates of detector pixel positions<br>
TTH,INT = <a href="#-pixel2hkl">pixel2hkl</a>(#/d, detdim)<br>
<br>
detdim = detector dimesions def=[195,487] (Pilatus 100K)<br>
<br>
Uses the pilatus parameters local:"pilpara" to define detector distance, centre etc.<br>
pilpara=[119.536,1904.17,44.4698,0.106948,-0.738038,412.19,-0.175,-0.175]<br>
<br>
To bin the data, use: <br>
bin_tth,bint_int = <a href="#-bindata">bindata</a>(TTH,INT,0.01) <br>
<br>
Only works on delta, gam, eta, chi, phi scans - not energy or hkl scans!</tt></dd></dl>
<dl><dt><a name="-pixel2xyz"><strong>pixel2xyz</strong></a>(num, detdim<font color="#909090">=[195, 487]</font>)</dt><dd><tt>Generate cartesian coordinates of detector pixel positions, in A-1<br>
XXX,YYY,ZZZ = <a href="#-pixel2xyz">pixel2xyz</a>(#/d, detdim)<br>
<br>
detdim = detector dimesions def=[195,487] (Pilatus 100K)<br>
<br>
Uses the pilatus parameters local:"pilpara" to define detector distance, centre etc.<br>
pilpara=[119.536,1904.17,44.4698,0.106948,-0.738038,412.19,-0.175,-0.175]<br>
<br>
Code copied and adapted from Alessandro's readpil.hklmatrix()<br>
<br>
Only works on delta, gam, eta, chi, phi scans - not energy or hkl scans!</tt></dd></dl>
<dl><dt><a name="-plotdwn"><strong>plotdwn</strong></a>(num, save<font color="#909090">=None</font>)</dt><dd><tt>Default plot of I16 data, <a href="#-plotscan">plotscan</a>(#), or <a href="#-plotscan">plotscan</a>(#,save=1)</tt></dd></dl>
<dl><dt><a name="-plotpil"><strong>plotpil</strong></a>(num, cax<font color="#909090">=None</font>, varx<font color="#909090">=''</font>, imnum<font color="#909090">=None</font>, bkg_img<font color="#909090">=None</font>, ROIcen<font color="#909090">=None</font>, ROIsize<font color="#909090">=[75, 67]</font>, show_ROIbkg<font color="#909090">=False</font>, show_peakregion<font color="#909090">=False</font>, log_colors<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Pilatus image viewer, <a href="#-plotpil">plotpil</a>(#)<br>
Displays pilatus image with a slider to looks throught the whole scan<br>
Options:<br>
num : Scan number (0 for latest scan)<br>
cax : [min,max] colour map cut offs, or None for automatic (Default=None)<br>
varx : scannable to use as slider axis, or None for automatic (Default=None)<br>
imnum : Image number to start at - 0-scanlength, or None for middle (Default=None)<br>
bkg_img : If not None, image number bkg_img will be subtracted from all the other images in the scan (Default=None)<br>
ROIcen : Centre of region of interest [-y,x], or None for pp.pil_centre (Default=None)<br>
ROIsize : Size of region of interest to plot [ywid,xwid] (Default=[75,67]-ROI2)<br>
show_ROIbkg : If True, plots the background region of the ROI (Default=False)<br>
show_peakregion : If True, plots the pp.peakregion area (Default=False)<br>
save : If True, saves an image of the resulting figure to pp.savedir (Default=False)<br>
<br>
E.G. <a href="#-plotpil">plotpil</a>(0,[0,1E3],imnum=0,bkg_img=0,ROIcen=[110,242],ROIsize=[21,10],show_peakregion=True)</tt></dd></dl>
<dl><dt><a name="-plotpilSURF"><strong>plotpilSURF</strong></a>(num, varx<font color="#909090">=''</font>, ROIcen<font color="#909090">=None</font>, wid<font color="#909090">=10</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Plot CHI scans from pilatus<br>
***NOT COMPLETE***</tt></dd></dl>
<dl><dt><a name="-plotpilhkl"><strong>plotpilhkl</strong></a>(num)</dt><dd><tt>Plot pilatus frames as 3D surface in reciprocal space<br>
<a href="#-plotpilhkl">plotpilhkl</a>(num)<br>
<br>
pixel2hkl used to generate reciprocal space coordinates, using UB matrix stored<br>
in metadata. Detector position calibration defined by locals: pilpara<br>
<br>
The images are rebinned to allow fast plotting.</tt></dd></dl>
<dl><dt><a name="-plotpiltth"><strong>plotpiltth</strong></a>(num, binsep<font color="#909090">=0.1</font>, centre_only<font color="#909090">=False</font>)</dt><dd><tt>Plot binned two-theta representation of pilatus frames<br>
<a href="#-plotpiltth">plotpiltth</a>(num,binsep,centre_only)<br>
num = scan number or list of scan numbers for muliplt overlaid plots<br>
binsep = width of bins<br>
centre_only = if True, only bins pixels around the centre of the pilatus.<br>
<br>
pixel2tth used to generate reciprocal space coordinates, using UB matrix stored<br>
in metadata. Detector position calibration defined by locals: pilpara</tt></dd></dl>
<dl><dt><a name="-plotpilxyz"><strong>plotpilxyz</strong></a>(num)</dt><dd><tt>Plot pilatus frames as 3D surface in wavevector-transfer space<br>
<a href="#-plotpilxyz">plotpilxyz</a>(num)<br>
<br>
pixel2xyz used to generate reciprocal space coordinates, using UB matrix stored<br>
in metadata. Detector position calibration defined by locals: pilpara<br>
<br>
The images are rebinned to allow fast plotting.</tt></dd></dl>
<dl><dt><a name="-plotscan"><strong>plotscan</strong></a>(num<font color="#909090">=None</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, fit<font color="#909090">=None</font>, norm<font color="#909090">=True</font>, sum<font color="#909090">=False</font>, subtract<font color="#909090">=False</font>, fits<font color="#909090">=False</font>, labels<font color="#909090">=None</font>, logplot<font color="#909090">=False</font>, diffplot<font color="#909090">=False</font>, normalise<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Default plot of I16 data, <a href="#-plotscan">plotscan</a>(#), or <a href="#-plotscan">plotscan</a>(#,save=True)<br>
<br>
Plotting with fits: <a href="#-plotscan">plotscan</a>(#,fit='Gauss') or <a href="#-plotscan">plotscan</a>(#,fit='Lorentz') or <a href="#-plotscan">plotscan</a>(#,fit='pVoight')<br>
<br>
Plotting multiple regions of interest: <a href="#-plotscan">plotscan</a>(#,vary=['roi2_sum','roi1_sum'])<br>
<br>
Subtract regions of interest: <a href="#-plotscan">plotscan</a>(#,vary=['droi[110,240,51,51','droi[110,340,51,51]],subtract=True) = droi1-droi2<br>
<br>
Multi-run plot: <a href="#-plotscan">plotscan</a>([#1,#2,#3,...])<br>
<br>
Multi-run plot with fits: <a href="#-plotscan">plotscan</a>([#1,#2,#3,...],fit='Gauss',fits=True)<br>
<br>
Sum of several scans: <a href="#-plotscan">plotscan</a>([#1,#2],sum=True)</tt></dd></dl>
<dl><dt><a name="-plotscans"><strong>plotscans</strong></a>(scans<font color="#909090">=[]</font>, depvar<font color="#909090">=None</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, fit<font color="#909090">=None</font>, norm<font color="#909090">=True</font>, logplot<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Plot multiple scans of I16 data, <a href="#-plotscans">plotscans</a>([#1,#2,...])<br>
<br>
Plotting with fits: <a href="#-plotscans">plotscans</a>([#1,#2,...],fit='Gauss'), fit can also be 'Lorentz' or 'pVoight'<br>
<br>
Good for plotting many scans as a continuous colormap is used to vary the line colours.</tt></dd></dl>
<dl><dt><a name="-plotscans2D"><strong>plotscans2D</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, logplot<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Plot pcolor of multiple scans</tt></dd></dl>
<dl><dt><a name="-plotscans3D"><strong>plotscans3D</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, logplot<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Plot 3D eta scans of energy or temp dependence</tt></dd></dl>
<dl><dt><a name="-plotscansSURF"><strong>plotscansSURF</strong></a>(scans, depvar<font color="#909090">='Ta'</font>, vary<font color="#909090">=''</font>, varx<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, logplot<font color="#909090">=False</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Plot surface of multiple scans</tt></dd></dl>
<dl><dt><a name="-polenergy"><strong>polenergy</strong></a>(sigsig, sigpi, background<font color="#909090">=None</font>, vary<font color="#909090">=''</font>, bkg_scale<font color="#909090">=None</font>, flipping_ratio<font color="#909090">=None</font>, low_points<font color="#909090">=5</font>, save<font color="#909090">=False</font>)</dt><dd><tt>Create Plot of energy-polarisation scans and calculate the subtraction</tt></dd></dl>
<dl><dt><a name="-polflip"><strong>polflip</strong></a>(sigsig, sigpi, fit<font color="#909090">='Gauss'</font>, output<font color="#909090">=False</font>, plot<font color="#909090">=False</font>)</dt><dd><tt>Calculate flipping ratio ect.</tt></dd></dl>
<dl><dt><a name="-prend"><strong>prend</strong></a>(start<font color="#909090">=0</font>, end<font color="#909090">=None</font>)</dt><dd><tt>Calculate the end time of a run</tt></dd></dl>
<dl><dt><a name="-pvoight"><strong>pvoight</strong></a>(x, height<font color="#909090">=1</font>, cen<font color="#909090">=0</font>, FWHM<font color="#909090">=0.5</font>, LorFrac<font color="#909090">=0.5</font>, bkg<font color="#909090">=0</font>)</dt><dd><tt>Define pseudo-Voight</tt></dd></dl>
<dl><dt><a name="-q2tth"><strong>q2tth</strong></a>(qmag, energy_kev)</dt><dd><tt>Converts array of wavevector transfers in A-1 to two-theta in degrees</tt></dd></dl>
<dl><dt><a name="-read_dat_file"><strong>read_dat_file</strong></a>(filename)</dt><dd><tt>Reads #####.dat files from instrument, returns class instance containing all data<br>
Input: <br>
filename = string filename of data file<br>
Output:<br>
d = class instance with parameters associated to scanned values in the data file, plus:<br>
d.metadata - class containing all metadata from datafile<br>
d.keys() - returns all parameter names<br>
d.values() - returns all parameter values<br>
d.items() - returns parameter (name,value) tuples</tt></dd></dl>
<dl><dt><a name="-readscan"><strong>readscan</strong></a>(num)</dt><dd><tt>Loads Diamond #.dat data file<br>
d=<a href="#-readscan">readscan</a>(#)<br>
d=<a href="#-readscan">readscan</a>(0) - gives current run data<br>
d=<a href="#-readscan">readscan</a>(-n) - gives previous run data<br>
<br>
d is a dataholder storing all scan data. For example:<br>
d.eta = array of eta values in an eta scan<br>
d.APD = array of intensities when using the APD<br>
d.roi2_sum = array of pilatus region sums when using this option<br>
d.metadata gives ancillary data. For example:<br>
d.metadata.cmd = scan command<br>
d.metadata.Ta = current temperature<br>
d.metadata.en = current energy<br>
use d.keys() or d.metadata.keys() to see all values</tt></dd></dl>
<dl><dt><a name="-rebin"><strong>rebin</strong></a>(vol, step<font color="#909090">=[4, 4, 1]</font>)</dt><dd><tt>V = <a href="#-rebin">rebin</a>(volume,[4,4,1])<br>
Rebins the Pilatus array, taking the aveage of multiple pixels</tt></dd></dl>
<dl><dt><a name="-recall_last_exp"><strong>recall_last_exp</strong></a>()</dt><dd><tt>Loads the last saved experiment & analysis directories from the temp directory and sets filedir and savedir</tt></dd></dl>
<dl><dt><a name="-rolling_fun"><strong>rolling_fun</strong></a>(Y, fun<font color="#909090">=<function std></font>)</dt><dd><tt>Performs a rolling verions of the given function across and array<br>
<a href="#-rolling_fun">rolling_fun</a>(Y,fun)<br>
Y = array, e.g. [1,2,3,4]<br>
fun = array function, e.g. np.mean or np.std<br>
Returns an array, of the same length as Y, with function fun performed across every 3 items</tt></dd></dl>
<dl><dt><a name="-rot3D"><strong>rot3D</strong></a>(vec, alpha<font color="#909090">=0.0</font>, beta<font color="#909090">=0.0</font>, gamma<font color="#909090">=0.0</font>)</dt><dd><tt>Rotate 3D vector<br>
vec = <a href="#-rot3D">rot3D</a>(vec,alpha=0.,beta=0.,gamma=0.)<br>
where alpha = angle from X axis to Y axis (Yaw)<br>
beta = angle from Z axis to X axis (Pitch)<br>
gamma = angle from Y axis to Z axis (Roll)<br>
angles in degrees<br>
In a right handed coordinate system.<br>
Z<br>
/| |<br>
|________\Y<br>
\ /<br>
_\/X</tt></dd></dl>
<dl><dt><a name="-sav_list_add"><strong>sav_list_add</strong></a>()</dt><dd><tt>Creates/appends files in the system Temp directory to store previously used save folder</tt></dd></dl>
<dl><dt><a name="-sav_list_get"><strong>sav_list_get</strong></a>()</dt><dd><tt>Loads a list of analysis directories used previously</tt></dd></dl>
<dl><dt><a name="-saveable"><strong>saveable</strong></a>(string)</dt><dd><tt>Removes bad characters from a string, so it can be used as a filename</tt></dd></dl>
<dl><dt><a name="-savedata"><strong>savedata</strong></a>(name, x, y, dy<font color="#909090">=None</font>, header<font color="#909090">=None</font>)</dt><dd><tt>Save data as a formated text file in the analysis directory<br>
<a href="#-savedata">savedata</a>( name, x, y, dy, header )<br>
<br>
name = name of file, not including extention (.dat will be added)<br>
x,y,dy = equal length arrays, dy can be left out<br>
header = header info can be added if required<br>
<br>
Uses: np.savetxt(savefile,(x,y,dy),header=head)<br>
<br>
E.G.<br>
x = [1,2,3,4]<br>
y = [2.4,56,43,1e6]<br>
dy = np.sqrt(y)<br>
<a href="#-savedata">savedata</a>('test',x,y,dy,header='lovely data')</tt></dd></dl>
<dl><dt><a name="-saveplot"><strong>saveplot</strong></a>(name, dpi<font color="#909090">=None</font>)</dt><dd><tt>Saves current figure as a png in the savedir directory</tt></dd></dl>
<dl><dt><a name="-savescan"><strong>savescan</strong></a>(num<font color="#909090">=None</font>, varx<font color="#909090">=''</font>, vary<font color="#909090">=''</font>, norm<font color="#909090">=True</font>, abscor<font color="#909090">=None</font>)</dt><dd><tt>Save scan as .dat file</tt></dd></dl>
<dl><dt><a name="-scanabscor"><strong>scanabscor</strong></a>(num<font color="#909090">=0</font>, u<font color="#909090">=1</font>, eta_offset<font color="#909090">=0.0</font>, chi_offset<font color="#909090">=0.0</font>)</dt><dd><tt>Calculate absorption correction<br>
A = <a href="#-abscor">abscor</a>(num,u)</tt></dd></dl>
<dl><dt><a name="-scanenergy"><strong>scanenergy</strong></a>(num)</dt><dd><tt>Returns the average energy of the chosen scan as a formatted string</tt></dd></dl>
<dl><dt><a name="-scanfile"><strong>scanfile</strong></a>(num)</dt><dd><tt>Returns the full file name of scan #num</tt></dd></dl>
<dl><dt><a name="-scanhkl"><strong>scanhkl</strong></a>(num)</dt><dd><tt>Returns the average HKL of the chosen scan as a formatted string</tt></dd></dl>
<dl><dt><a name="-scanlatt"><strong>scanlatt</strong></a>(num)</dt><dd><tt>Displays the lattice parameters of the chosen scan</tt></dd></dl>
<dl><dt><a name="-scantemp"><strong>scantemp</strong></a>(num, sensor<font color="#909090">=None</font>)</dt><dd><tt>Returns the average temperature of the chosen scan as a formatted string</tt></dd></dl>
<dl><dt><a name="-scantitle"><strong>scantitle</strong></a>(num)</dt><dd><tt>Generate a formatted title for the current scan</tt></dd></dl>
<dl><dt><a name="-scanwl"><strong>scanwl</strong></a>(num)</dt><dd><tt>Returns the initial wavelength of the given scan in Angstroms</tt></dd></dl>
<dl><dt><a name="-simpfit"><strong>simpfit</strong></a>(x, y, disp<font color="#909090">=None</font>)</dt><dd><tt>Simple peak parameters</tt></dd></dl>
<dl><dt><a name="-simpplt"><strong>simpplt</strong></a>(x, height<font color="#909090">=1</font>, cen<font color="#909090">=0</font>, FWHM<font color="#909090">=0.5</font>, bkg<font color="#909090">=0</font>)</dt><dd><tt>Plot an Illustration of simpfit</tt></dd></dl>
<dl><dt><a name="-stfm"><strong>stfm</strong></a>(val, err)</dt><dd><tt>Create standard form string from value and uncertainty"<br>
str = <a href="#-stfm">stfm</a>(val,err)<br>
Examples:<br>
'35.25 (1)' = <a href="#-stfm">stfm</a>(35.25,0.01)<br>
'110 (5)' = <a href="#-stfm">stfm</a>(110.25,5)<br>
'0.0015300 (5)' = <a href="#-stfm">stfm</a>(0.00153,0.0000005)<br>
'1.56(2)E+6' = <a href="#-stfm">stfm</a>(1.5632e6,1.53e4)</tt></dd></dl>
<dl><dt><a name="-straightline"><strong>straightline</strong></a>(x, grad<font color="#909090">=1.0</font>, inter<font color="#909090">=0.0</font>)</dt><dd><tt>Staigh line</tt></dd></dl>
<dl><dt><a name="-tth2d"><strong>tth2d</strong></a>(tth, energy_kev)</dt><dd><tt>Converts two-theta array in degrees to d-spacing in A</tt></dd></dl>
<dl><dt><a name="-tth2q"><strong>tth2q</strong></a>(tth, energy_kev)</dt><dd><tt>Converts two-theta array in degrees to wavevector transfer, Q in A-1</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>datfile_format</strong> = '%i.dat'<br>
<strong>default_sensor</strong> = 'Ta'<br>
<strong>detectors</strong> = ['APD', 'sum', 'maxval']<br>
<strong>dont_normalise</strong> = ['Ta', 'Tb', 'Tc', 'Td', 'ic1monitor', 'rc', 'Cmes', 'Vmes', 'Rmes']<br>
<strong>exp_monitor</strong> = 800.0<br>
<strong>exp_ring_current</strong> = 300.0<br>
<strong>exp_title</strong> = ''<br>
<strong>filedir</strong> = '/dls/i16/data/2017'<br>
<strong>hot_pixel</strong> = 1048476<br>
<strong>normby</strong> = 'rc'<br>
<strong>peakregion</strong> = [7, 153, 186, 332]<br>
<strong>pil_centre</strong> = [104, 205]<br>
<strong>pil_max_size</strong> = 544630784.0<br>
<strong>pilatus_dead_pixels</strong> = array([], shape=(0L, 2L), dtype=int32)<br>
<strong>pilpara</strong> = [119.536, 1904.17, 44.4698, 0.106948, -0.738038, 412.19, -0.175, -0.175]<br>
<strong>plot_colors</strong> = ['b', 'g', 'm', 'c', 'y', 'k', 'r']<br>
<strong>print_function</strong> = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536)<br>
<strong>psutil</strong> = <module 'psutil' from 'C:\Anaconda\lib\site-packages\psutil\__init__.pyc'><br>
<strong>savedir</strong> = '/home/i16user/Desktop'</td></tr></table>
</body></html>