-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscan_plotter.m
More file actions
2347 lines (1980 loc) · 105 KB
/
scan_plotter.m
File metadata and controls
2347 lines (1980 loc) · 105 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
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% script for reading and plotting a general guide_bot scan.
clear all;close all;clc;
% EXPLANATION
clear all
% This script can be used to plot large amounts of data made with guide_bot
% in order to get an overview. Because it is made for large data sets, it
% is "uncrashable"^TM. Every time something is done, it is saved to disk,
% and if the process crash or is killed it will start from where it was
% killed the next time it is started. I usually run this script over night,
% as it can take 5 hours or more for reasonable data sets.
% If the process somehow fails and you want to start over, delete the
% progress.mat file in this folder.
% HOW TO USE IT:
% Simply navigate to the output/analysis folder and run this script. It
% will automaticly detect any files made by guide_bot and run the analyzse
% script while recording the overall performance from each script. Remember
% to set meaningful wavelength ranges, if Wmax is above what is recoreded
% it will fail.
% START INPUT SECTION
% Option to plot the scans at the end. 1 = Yes, 0 = No.
plot_options.plot_results = 1;
% Using this script with plot_results = 0 is like analyze_all with a system to save progress.
%plot_options.nickname = 'complex';
% Which of the above wavelength ranges to plot performance for?
plot_options.wavelength_range = 7;
% Calculate performance in these intervals:
%calculate.Wmax = [8 0.5 1.0 2.0 3.0 4];
%calculate.Wmin = [4 0.1 0.5 1.0 2.0 1];
% Pascale
%calculate.Wmax = [9.0 5.0 5.0 2.0 3.00 4.00 5.00 6.00];% 7.00 8.00 9.00];
%calculate.Wmin = [1.0 1.0 1.5 1.0 2.00 3.00 4.00 5.00];% 6.00 7.00 8.00];
% CAMEA
%calculate.Wmax = [6.40 3.00 2.0 3.00 4.00 5.00 6.00 7.00];
%calculate.Wmin = [1.65 1.65 1.0 2.00 3.00 4.00 5.00 6.00];
% ODIN
%calculate.Wmax = [7 4 7 2.0 3.00 4.00 5.00 6.00 7.00 7.99];
%calculate.Wmin = [1 1 4 1.0 2.00 3.00 4.00 5.00 6.00 6.99];
% Werner Thermal
%calculate.Wmax = [2.4 1.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5]
%calculate.Wmin = [0.8 0.8 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0]
% Werner Cold
%calculate.Wmax = [10.0 4.0 2.0 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00];
%calculate.Wmin = [2.40 2.4 1.0 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.000 10.00 11.00 12.00 13.00 14.00 15.00 16.00];
% Heimdal
%calculate.Wmax = [2.27 2.40 1.00 2.0 2.4 3.00 4.00 5.00 6.00];
%calculate.Wmin = [0.60 0.60 0.60 1.0 2.0 2.00 3.00 4.00 5.00];
% Heimdal cold
%calculate.Wmax = [10.0 10.0 5.00 6.00 7.00 8.00 9.00 10.00];
%calculate.Wmin = [4.00 6.00 4.00 5.00 6.00 7.00 8.00 9.000];
% Fundamental Old
%calculate.Wmax = [16.0 4.00 2.0 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00];
%calculate.Wmin = [2.00 2.00 1.0 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.000 10.00 11.00 12.00 13.00 14.00 15.00];
% Fundamental
%calculate.Wmax = [8.00 4.00 2.0 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00];
%calculate.Wmin = [3.00 2.00 1.0 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.000 10.00 11.00 12.00 13.00 14.00 15.00];
% Minimalist
%calculate.Wmax = [4 8 8 8 8 2.0 3.00 4.00 5.00 6.00 7.00 8];
%calculate.Wmin = [1 1 3 4 5 1.0 2.00 3.00 4.00 5.00 6.00 7];
% Thesis complicated 1
%calculate.Wmax = [4.00 8.00 2.0 3.00 4.00 5.00 6.00 7.00 8.00];
%calculate.Wmin = [1.50 4.00 1.0 2.00 3.00 4.00 5.00 6.00 7.00];
% Thesis complicated feeder
%calculate.Wmax = [10.00 10.00 2.0 3.00 4.00 5.00 6.00 7.00 8.00];
%calculate.Wmin = [2.00 4.00 1.0 2.00 3.00 4.00 5.00 6.00 7.00];
% Thesis complicated 1
%calculate.Wmax = [4.00 8.00 2.0 3.00 4.00 5.00 6.00 7.00 8.00];
%calculate.Wmin = [1.25 4.00 1.0 2.00 3.00 4.00 5.00 6.00 7.00];
% Wiebke CSPEC
%calculate.Wmax = [10.0 10.0 5.0 5.0 2.0 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00];
%calculate.Wmin = [1.00 2.00 1.0 2.0 1.0 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.000];
% ESSENSE
%calculate.Wmax = [25.0 25.0 6 8 10.0 12 16];
%calculate.Wmin = [4.00 6.00 4 6 8.00 10 12];
% Werner singleXmagnetism
%calculate.Wmax = [8.00 3.00 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0]
%calculate.Wmin = [0.70 0.70 0.7 1.0 2.0 3.0 4.0 5.0 6.0 7.0]
% WANSE
%calculate.Wmax = [10.0 10.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0]
%calculate.Wmin = [2.00 4.00 1.0 2.0 3.0 4.0 5.0 6.0 7.0]
% MIRACLES
%calculate.Wmax = [8.00 16.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0]
%calculate.Wmin = [2.00 8.00 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
% LOKI
%calculate.Wmax = [13.00 13.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0]
%calculate.Wmin = [2.000 4.00 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
% BiSpecChopper TREX
%calculate.Wmax = [7.20 2.00 7.2 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0];
%calculate.Wmin = [0.80 0.80 2.0 0.8 1.0 2.0 3.0 4.0 5.0 6.0 7.0];
% NMX
calculate.Wmax = [3.3 2.0 3.3 2.00 3.00 4.00 5.00 6.00 7.00];
calculate.Wmin = [1.5 1.5 2.0 1.00 2.00 3.00 4.00 5.00 6.00];
% DREAM
%calculate.Wmax = [4.6 2.0 4.6 2.00 3.00 4.00 5.00 6.00 7.00];
%calculate.Wmin = [0.8 0.8 2.0 1.00 2.00 3.00 4.00 5.00 6.00];
% HOD
%calculate.Wmax = [2.0 3.0 4.0 5.0 6.0 7.0 8.0]
%calculate.Wmin = [1.2 2.0 3.0 4.0 5.0 6.0 7.0]
% VERITAS
%calculate.Wmax = [10.0 10.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0]
%calculate.Wmin = [2.00 4.00 1.0 2.0 3.0 4.0 5.0 6.0 7.0]
% Thermal Chopper Spectrometer
%calculate.Wmax = [3.0 1.5 1.0 1.5 2.0 2.5 3.0]
%calculate.Wmin = [0.6 0.6 0.5 1.0 1.5 2.0 2.5]
% SLEIPNIR
%calculate.Wmax = [19.00 16.5 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 12.0 14 16 18]
%calculate.Wmin = [3.000 3.00 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 12 14 16]
% SKADI
%calculate.Wmax = [10.00 9.5 9.5 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
%calculate.Wmin = [2.000 2.0 4.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.00]
% Vibrational
%calculate.Wmax = [6.0 3.0 6.0 1.0 1.5 2.0 2.5 3.0 4 5 6]
%calculate.Wmin = [0.4 0.4 3.0 0.5 1.0 1.5 2.0 2.5 3 4 5]
% VESPA
%calculate.Wmax = [4.7 2.0 4.7 1.0 1.5 2.0 2.5 3.0 4 5]
%calculate.Wmin = [0.6 0.6 2.0 0.5 1.0 1.5 2.0 2.5 3 4]
% Micron
%calculate.Wmax = [8.5 8.5 1.0 1.5 2.0 2.5 3.0 4 5 6 7 8 9];
%calculate.Wmin = [0.5 1.0 0.5 1.0 1.5 2.0 2.5 3 4 5 6 7 8];
% FREIA
%calculate.Wmax = [10.0 5.0 3.5 4.5 5.5 6.5 7.5 8.5 10 ];
%calculate.Wmin = [2.5 2.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5];
% RESPECT
%calculate.Wmax = [6.0 10.0 3 4 5 6 7 8 9 10];
%calculate.Wmin = [2.0 2.00 2 3 4 5 6 7 8 9];
% D7
%calculate.Wmax = [6.0 3.0 3 4 5 6]
%calculate.Wmin = [2.0 2.0 2 3 4 5]
% Mark
%calculate.Wmax = [3.5 6.8 4 5 6 7 8];
%calculate.Wmin = [3.1 6.2 3 4 5 6 7];
% Undervisning
%calculate.Wmax = [4.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0];
%calculate.Wmin = [2.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0];
% Katsuaki
%calculate.Wmax = [8.0 2.0 8.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0]
%calculate.Wmin = [0.5 0.5 2.0 0.5 1.0 2.0 3.0 4.0 5.0 6.0 7.0]
%calculate.Wmax = [2.0 1.0 1.5 2.0 3.0 4.0 5.0 6.0];
%calculate.Wmin = [1.0 0.5 1.0 1.5 2.0 3.0 4.0 5.0];
% What figures do you want? [3 5] recomended.
% 1: Performance from simple source
% 2: 1 with degraded guide
% 3: ESS
% 4: 3 with degraded guide
% 5: Brilliance transfer from uniform source (equal I on all wavelengths)
% 6: 5 with degraded guide
plot_options.fig_choice = [5 3 7];
% Colormap to distinguish different guides, hot and jet are ok.
plot_options.colormap_choice = jet;
% If nxm 2D plot, plot n 1D graphs with m points instead if force_1d = 1.
plot_options.force_1D = 1;
% If reverse_order = 1 and force_1D = 1, it will plot m 1D graphs with n points.
plot_options.reverse_order = 1;
% Text size, FSL (large) and FS (small)
plot_options.FSL = 14;
plot_options.FS = 12;
% Algorithm for cleaning up in data from optimizer which can fail.
% cleanup_low_points should be zero when looking at the data for the first time
% when one, it will remove points which is below tollerance*data(i-1) and
% tollerance*data(i+1), meaning failled optimizations.here 0
plot_options.cleanup_low_points = 1;
plot_options.tollerance = 0.70;
% There is hardcoded data for the unperterped moderator gains for pancake
% moderators in this script. It will only be applied if moderator_size_y is
% scanned. Enable this by setting the following command to one.
plot_options.apply_flux = 0;
% the keyword field can be used to add comments to some of the tested
% guides. These will apear in the legend.
%plot_options.keyword.EGSlitGE = '50mm';
%plot_options.keyword.PGSlitGE = '15mm';
%plot_options.keyword.PGSlitGE_alt1 = '20mm';
%plot_options.keyword.PGSlitGE_alt2 = '25mm';
%plot_options.keyword.PGSlitGE_alt3 = '50mm';
% Werner cold2
%plot_options.keyword.EGSelene = ' no m limit';
%plot_options.keyword.EGSelene_alt1 = 'm 2.5 limit';
%plot_options.keyword.EGSelene_alt2 = 'm 2.0 limit';
%plot_options.keyword.SCGSelene = ' no m limit';
%plot_options.keyword.SCGSelene_alt1 = 'm 2.5 limit';
%plot_options.keyword.SCGSelene_alt2 = 'm 2.0 limit';
%plot_options.keyword.Selene = ' no m limit';
%plot_options.keyword.Selene = '2 m slit m=4.3';
%plot_options.keyword.Selene_alt1 = '2 m slit m=3.0 limit';
%plot_options.keyword.Selene_alt1 = 'moderator focus m=4.3';
%plot_options.keyword.Selene_alt3 = 'moderator focus m=3.0 limit';
%plot_options.keyword.PGSCSCGP = '2 m start focusing end';
%plot_options.keyword.PGSCSCGP_alt1 = '3.5 m start focusing end';
%plot_options.keyword.PGSCSCGS = '2 m start straight end';
%plot_options.keyword.PGSCSCGS_alt1 = '3.5 m start straight end';
plot_options.keyword.PGESKSE = 'Proposal guide';
%plot_options.keyword.PGPSP = '(STAP) 0 los';
%plot_options.keyword.PGPCP = '(STAP) 1 los';
%plot_options.keyword.PGPCP_alt1 = '(STAP) 2 los';
%plot_options.keyword.ECE = '6.1 m start - 1 los';
%plot_options.keyword.ECP = '6.1 m start - 1 los';
%plot_options.keyword.PCP = '6.1 m start - 1 los';
%plot_options.keyword.PCE = '6.1 m start - 1 los';
%plot_options.keyword.PGECE = 'free start - 1 los';
%plot_options.keyword.PGECP = 'free start - 1 los';
%plot_options.keyword.PGPCP = 'free start - 1 los';
%plot_options.keyword.PGPCE = 'free start - 1 los';
%plot_options.keyword.PGPCP = 'no pinhole - 1 los';
%plot_options.keyword.PGPCP_alt1 = 'no pinhole - 2 los';
%plot_options.keyword.PGSlitGPCP = '15mm pinhole - 1 los';
%plot_options.keyword.PGSlitGPCP_alt1 = '20mm pinhole - 1 los';
%plot_options.keyword.PGSlitGPCP_alt2 = '25mm pinhole - 1 los';
%plot_options.keyword.PGSlitGPSP = '15mm pinhole - 0 los';
%plot_options.keyword.PGSlitGPSP_alt1 = '20mm pinhole - 0 los';
%plot_options.keyword.PGSlitGPSP_alt2 = '25mm pinhole - 0 los';
%plot_options.keyword.PGECE = '3.0 cm pinhole - 1 los';
%plot_options.keyword.PGECE_alt1 = '3.0 cm pinhole - 2 los';
%plot_options.keyword.PGPCP = '3.0 cm pinhole - 1 los';
%plot_options.keyword.PGECE_alt2 = '4.5 cm pinhole - 1 los';
%plot_options.keyword.PGECE_alt3 = '4.5 cm pinhole - 2 los';
%plot_options.keyword.PGPCP_alt1 = '4.5 cm pinhole - 1 los';
% ODIN6 input names
% plot_options.keyword.PGSlitGECE = ' 1.5 cm slit 1 channel';
% plot_options.keyword.PGSlitGECE_alt1 = ' 1.5 cm slit 3 channels';
% plot_options.keyword.PGSlitGECE_alt2 = ' 1.5 cm slit 5 channels';
% plot_options.keyword.PGSlitGECE_alt3 = ' 2.0 cm slit 1 channel';
% plot_options.keyword.PGSlitGECE_alt4 = ' 2.0 cm slit 3 channels';
% plot_options.keyword.PGSlitGECE_alt5 = ' 2.0 cm slit 5 channels';
% plot_options.keyword.PGSlitGECE_alt6 = ' 2.5 cm slit 1 channel';
% plot_options.keyword.PGSlitGECE_alt7 = ' 2.5 cm slit 3 channels';
% plot_options.keyword.PGSlitGECE_alt8 = ' 2.5 cm slit 5 channels';
% plot_options.keyword.PGSlitGPCP = ' 1.5 cm slit 1 channel';
% plot_options.keyword.PGSlitGPCP_alt1 = ' 1.5 cm slit 3 channels';
% plot_options.keyword.PGSlitGPCP_alt2 = ' 1.5 cm slit 5 channels';
% plot_options.keyword.PGSlitGPCP_alt3 = ' 2.0 cm slit 1 channel';
% plot_options.keyword.PGSlitGPCP_alt4 = ' 2.0 cm slit 3 channels';
% plot_options.keyword.PGSlitGPCP_alt5 = ' 2.0 cm slit 5 channels';
% plot_options.keyword.PGSlitGPCP_alt6 = ' 2.5 cm slit 1 channel';
% plot_options.keyword.PGSlitGPCP_alt7 = ' 2.5 cm slit 3 channels';
% plot_options.keyword.PGSlitGPCP_alt8 = ' 2.5 cm slit 5 channels';
%plot_options.keyword.EGECE = ' 2.0 m from moderator';
%plot_options.keyword.EGECE_alt1 = '1.0 m from moderator';
%plot_options.keyword.EGE_alt2 = '1.0 m from moderator';
plot_options.keyword.EGESE = ' 2.0 m from moderator';
plot_options.keyword.EGESE_alt1 = '1.5 m from moderator';
plot_options.keyword.EGESE_alt2 = '1.0 m from moderator';
plot_options.keyword.EGPCEGP=' 2.0 m from moderator';
plot_options.keyword.EGPCEGP_alt1= '1.0 m from moderator';
%plot_options.keyword.SCSCS = ' 2.0 m from moderator';
%plot_options.keyword.SCSCS_alt1 = '1.5 m from moderator';
%plot_options.keyword.SCSCS_alt2 = '1.0 m from moderator';
%plot_options.keyword.EGSlitGESE = ' 2.0 m from moderator';
%plot_options.keyword.EGSlitGESE_alt1 = '1.0 m from moderator';
%plot_options.keyword.EGSlitGE = ' 2.0 m from moderator';
%plot_options.keyword.EGSlitGE_alt1 = '1.0 m from moderator';
%plot_options.plot_logical.ESE = 0;
%plot_options.plot_logical.ESE_alt1 = 0;
%plot_options.plot_logical.ES_alt3 = 0;
%plot_options.plot_logical.PSP = 0;
%plot_options.plot_logical.PSP_alt1 = 0;
%plot_options.plot_logical.ESE = 0;
%plot_options.plot_logical.ESE_alt1 = 0;
plot_options.keyword.SCCS = ' 1.0 m from moderator vertical bend';
plot_options.keyword.SCCS_alt1 = '2.0 m from moderator vertical bend';
plot_options.keyword.SCCS_alt2 = '1.0 m from moderator horizontal bend';
plot_options.keyword.SCCS_alt3 = '2.0 m from moderator horizontal bend';
% END INPUT SECTION
plot_options.keyword.ES = ' 2.0 m from moderator';
plot_options.keyword.ES_alt1 = '1.0 m from moderator';
plot_options.keyword.S = ' 2.0 m from moderator';
plot_options.keyword.S_alt1 = '1.0 m from moderator';
plot_options.keyword.SSS = ' 2.0 m from moderator';
plot_options.keyword.SSS_alt1 = '1.0 m from moderator';
plot_options.keyword.ESESelene = '4 m Selene';
plot_options.keyword.ESKSESelene = '4 m Selene';
plot_options.keyword.PGECESelene = '4 m Selene';
plot_options.keyword.ESESelene_alt1 = '8 m Selene';
plot_options.keyword.ESKSESelene_alt1 = '8 m Selene';
plot_options.keyword.PGECESelene_alt1 = '8 m Selene';
plot_options.keyword.SCSCSP = ' 4 channels - 2 los at 11.8 m';
plot_options.keyword.SCSCSP_alt1 = '4 channels - 2 los at 15.0 m';
plot_options.keyword.SCSCSP_alt2 = '- 2 channels - 2 los at 11.8';
plot_options.keyword.SCSCSP_alt3 = '- 1 channels - 2 los at 11.8';
plot_options.keyword.SCSCSP_alt4 = '- 4 channels - 2 los at 15.0';
plot_options.keyword.SCSCSP_alt5 = '- 3 channels - 2 los at 15.0';
plot_options.keyword.SCSCSP_alt6 = '- 2 channels - 2 los at 15.0';
plot_options.keyword.SCSCSP_alt7 = '- 1 channels - 2 los at 15.0';
plot_options.keyword.SCCSP = '- No middle S - 3 channels - 2 los at 11.8';
plot_options.keyword.SCCSP_alt1 = '- No middle S - 3 channels - 2 los at 15.0';
plot_options.keyword.S = 'Straight guide';
plot_options.keyword.E = 'Elliptic guide';
plot_options.keyword.SCS = 'Curved guide';
plot_options.keyword.PCP = 'Balistic guide: parabolic';
plot_options.keyword.ECE = 'Balistic guide: elliptic';
% Code for identifying the different instruments
% find all .mat files in the directory
% look for unique names before the first underscore
% Code for identifying the different scanned variables
% count the number of underscores in the names
% check against a list of possible scan names (Hdiv, moderator_size_y)
% conclude which values were scanned
% could add wavemax / wavemin to the list.
possible_scan_names={'Hdiv' 'Vdiv' 'Hsize' 'Vsize' 'WaveLmin' 'WaveLmax' 'moderator_size_x' 'moderator_size_y' 'minimalist_factor'};
possible_scan_names_mcstas={'divreq_x' 'divreq_y' 'sizeX' 'sizeY' 'WaveMin' 'WaveMax' 'mod_x' 'mod_y' 'minimalist_factor'};
possible_scan_units={'[Deg]' '[Deg]' '[m]' '[m]' '[AA]' '[AA]' '[m]' '[m]' ''};
dir_output = dir;
verbose = 0;
no_scan = 0;
% This code does not work for _alt versions!
for ii = 3:length(dir_output) % . and .. are ellements.
if length(dir_output(ii).name) > 4
if strcmp(dir_output(ii).name(end-3:end),'.mat')
disp(ii)
disp(dir_output(ii).name)
%if strcmp(dir_output(ii).name,'progress.mat'); verbose = 1; else; verbose = 0; end;
for j = 1:length(dir_output(ii).name)
if strcmp(dir_output(ii).name(j),'_')
underscore{ii}(j) = 1;
else
underscore{ii}(j) = 0;
end
end
if verbose; underscore{ii}
end;
if sum(underscore{ii}) ~= 0
if verbose; disp('in underscore search'); end;
underscore_index{ii} = find(underscore{ii});
if strcmp(dir_output(ii).name(underscore_index{ii}(1)+1:underscore_index{ii}(1)+3),'alt')
pre{ii} = dir_output(ii).name(1:underscore_index{ii}(2)-1);
else
pre{ii} = dir_output(ii).name(1:underscore_index{ii}(1)-1);
end
not_found = 1;
interesting = 1;
limit = 0;
while not_found
limit = limit + 1;
for k = 1:length(possible_scan_names)
lower = underscore_index{ii}(end)-limit-1;
if lower > 2
if strcmp(dir_output(ii).name(lower:underscore_index{ii}(end)-1),possible_scan_names{k})
not_found = 0;
scan_dim(1).name = possible_scan_names{k};
scan_dim(1).name_mcstas = possible_scan_names_mcstas{k};
scan_dim(1).index = k;
end
else
not_found = 0;
interesting = 0;
% not interesting
end
end
end
if strcmp(dir_output(ii).name(length(pre{ii})+1:end),'_all.mat')
% In here if the file is made by guide_bot and not
% in a scan.
% Safe to assume there is no scan in this folder
no_scan = 1;
relevant(ii) = true;
if exist('scan_pre')
scan_pre{end+1} = pre{ii};
else
scan_pre{1} = pre{ii};
end
end
if interesting
relevant(ii) = true;
%disp(ii)
% need to extract the scan number, what number is t
lower_underscore = underscore_index{ii} < lower;
previous_underscore = max(underscore_index{ii}(lower_underscore));
value1 = str2num(dir_output(ii).name(previous_underscore+1:lower-1));
if sum(ismember(fieldnames(scan_dim(1)),'values')) > 0.5
scan_dim(1).values(end+1) = value1;
scan_pre{end+1}=pre{ii};
else
scan_dim(1).values(1) = value1;
scan_pre{1}=pre{ii};
end
% Need to check if there is another dimension or not.
% is there underscore between length(pre) and first letter in scan name?
logic1 = underscore_index{ii} > length(pre{ii}) + 1; % check
logic2 = underscore_index{ii} < underscore_index{ii}(end) - length(scan_dim(1).name); % check
logic_combine = logic1 & logic2;
sum(logic_combine);
if sum(logic_combine) > 0.5
% this is a two dimensional scan!
% store name in scan_dim(2).name and index in scan_dim(2).index
% store somewhere that this is a two dimensional scan
underscore_after = max(underscore_index{ii}(logic2));
not_found = 1;
limit = 0;
interesting = 0;
while not_found
limit = limit + 1;
for k = 1:length(possible_scan_names)
lower = underscore_after-limit-1;
if lower > 2
if strcmp(dir_output(ii).name(lower:underscore_after-1),possible_scan_names{k})
not_found = 0;interesting = 1;
scan_dim(2).name = possible_scan_names{k};
scan_dim(2).name_mcstas = possible_scan_names_mcstas{k};
scan_dim(2).index = k;
end
else
interesting = 0;
not_found = 0;
end
end
end
if interesting
lower_underscore = underscore_index{ii} < lower;
previous_underscore = max(underscore_index{ii}(lower_underscore));
value2 = str2num(dir_output(ii).name(previous_underscore+1:lower-1));
if sum(ismember(fieldnames(scan_dim(2)),'values')) > 0.5
scan_dim(2).values(end+1) = value2;
else
scan_dim(2).values(1) = value2;
end
end
end
end
end
end
end
end
% As the names are taken from the back of the string, they are swithced if
% there were two.
if no_scan == 1
size_select = 0;
% need to build up nessecary variables
list{1}=1;
list{2}=1;
name{1} = scan_pre{1};
for ii = 1:length(scan_pre)
new = 1;
for jj = 1:length(name)
if strcmp(name{jj},scan_pre{ii})
new = 0;
end
end
if new
name{end+1} = scan_pre{ii};
end
end
else
if length(scan_dim) == 2
temp = scan_dim(1);
scan_dim(1) = scan_dim(2);
scan_dim(2) = temp;
size_select = 2;
else
size_select = 1;
end
% Need to tie pre names together with values
name{1} = scan_pre{1};
for ii = 1:length(scan_pre)
new = 1;
for jj = 1:length(name)
if strcmp(name{jj},scan_pre{ii})
new = 0;
end
end
if new
name{end+1} = scan_pre{ii};
end
end
list{1}(1) = scan_dim(1).values(1);
for ii = 1:length(scan_dim(1).values)
new = 1;
for jj = 1:length(list{1})
if list{1}(jj) == scan_dim(1).values(ii)
new = 0;
end
end
if new
list{1}(end+1) = scan_dim(1).values(ii);
end
end
% wrong
if length(scan_dim) == 2
list{2}(1) = scan_dim(2).values(1);
for ii = 1:length(scan_dim(2).values)
new = 1;
for jj = 1:length(list{2})
if list{2}(jj) == scan_dim(2).values(ii)
new = 0;
end
end
if new
list{2}(end+1) = scan_dim(2).values(ii);
end
end
else
list{2} = 1;
end
end
% Code for looping over the analyse scripts (can read from analyse_all)
% check for program state file.
% for i = all instruments
% for j = all 1st_scan_variable
% for k = all 2nd_scan_variable
% check if the data, script and brill_ref exists
% run the analyse script
% save relevant data (B,B_deg,ESS,ESS_deg)
% clear irrelevant data
% save new program state
% end
% end
% end
% Update the following code to use brill transfer and user defined
% wavelength interval.
% Length of Wmax should equal Wmin.
%Wmax = [6.4 10 2.27 2.27 8 3];
%Wmin = [1.65 1.0 0.6 0.4 2 2];
% CAMEA
%Wmax = [6.4 6.40 2.00 1.65];
%Wmin = [1.65 1.00 1.65 1.00];
% ODIN
%Wmax = [8 2 3 4 10];
%Wmin = [1.0 1 2 3 2];
% Selene
%Wmax = [6.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 8.00];
%Wmin = [1.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 4.00];
% Applying the inputs
Wmax = calculate.Wmax;
Wmin = calculate.Wmin;
% Before we start, check if any progress is saved
DONE = 0;
if exist('progress.mat') > 0.5;
load('progress.mat')
instr = 1;
while DONE == 0 && sum(sum(progress_logic(instr,:,:))) == length(progress_logic(1,:,1))*length(progress_logic(1,1,:));
instr = instr + 1;
if instr > length(name); disp('Allready done!'); DONE = 1; end;
end
if DONE == 0;
current_instr = instr;
instr_range = current_instr:length(name);
% make standard to do list first, then remove what have been done.
for i = 1:length(name); iindex_range{i} = 1:length(list{1}); end;
for i = 1:length(name); for j = 1:length(list{1}); jindex_range{i,j} = 1:length(list{2}); end; end;
% current_instr needs to be updated
current_iindex = 1;
while sum(progress_logic(current_instr,current_iindex,:)) == length(list{2})
current_iindex = current_iindex + 1;
end
iindex_range{current_instr} = current_iindex:length(list{1});
current_jindex = sum(progress_logic(current_instr,current_iindex,:))+1;
jindex_range{current_instr,current_iindex} = current_jindex:length(list{2});
end
disp('Using saved progress, to disable, delete progress.mat')
disp(['Starting from instrument number: ' num2str(instr_range(1))]);
disp(['Starting from iindex number: ' num2str(iindex_range{instr_range(1)}(1))]);
disp(['Starting from jindex number: ' num2str( jindex_range{instr_range(1),iindex_range{instr_range(1)}(1)})]);
disp(['Using Wmax/Wmin'])
disp(Wmax)
disp(Wmin)
else
instr_range = 1:length(name);
for i = 1:length(name); iindex_range{i} = 1:length(list{1}); end;
for i = 1:length(name); for j = 1:length(list{1}); jindex_range{i,j} = 1:length(list{2}); end; end;
progress_logic = zeros(length(name),length(list{1}),length(list{2}));
end
% Init variables
ALLW_B_wave(1,1).startup=0;
ALLW_d_B_wave(1,1).startup = 0;
save('before_main.mat')
% REMOVE WHEN DONE
% TEMP CODE
%iindex_range{1} = 1:5;
%jindex_range{1} = 1:10;
if DONE == 0;
for instrument=instr_range
for iindex=iindex_range{instrument}
for jindex=jindex_range{instrument,iindex}
% size_select = 0 => no scan. = 1 => one dimensional scan. = 2 => two dimensional scan
if size_select == 2
logic_req1 = exist([name{instrument} '_' num2str(iindex) scan_dim(1).name '_' num2str(jindex) scan_dim(2).name '_ifit_analyse']) > 0.5;
logic_req2 = exist([name{instrument} '_' num2str(iindex) scan_dim(1).name '_' num2str(jindex) scan_dim(2).name '_all.mat']) > 0.5;
elseif size_select == 1
logic_req1 = exist([name{instrument} '_' num2str(iindex) scan_dim(1).name '_ifit_analyse']) > 0.5;
logic_req2 = exist([name{instrument} '_' num2str(iindex) scan_dim(1).name '_all.mat']) > 0.5;
elseif size_select == 0
logic_req1 = exist([name{instrument} '_ifit_analyse']) > 0.5;
logic_req2 = exist([name{instrument} '_all.mat']) > 0.5;
end
if (logic_req1 + logic_req2 == 2)
close all;
clearvars -except ALLW_wave ALLW_d_wave ESS_wave ESS_d_wave ESS_lim_wave ESS_d_lim_wave ALLW_B_wave ALLW_d_B_wave scan_dim name list iindex jindex instrument Wmax Wmin wavband progress_logic jindex_range iindex_range instr_range size_select calculate plot_options
if size_select == 2
eval([name{instrument} '_' num2str(iindex) scan_dim(1).name '_' num2str(jindex) scan_dim(2).name '_ifit_analyse']);
temp_name = [name{instrument} '_' num2str(iindex) scan_dim(1).name '_' num2str(jindex) scan_dim(2).name];
elseif size_select == 1
eval([name{instrument} '_' num2str(iindex) scan_dim(1).name '_ifit_analyse']);
temp_name = [name{instrument} '_' num2str(iindex) scan_dim(1).name ];
elseif size_select == 0
eval([name{instrument} '_ifit_analyse']);
temp_name = [name{instrument}];
end
% This will be done when all local variables of the script are
% accesable. Extract usefull info and move on to the next.
%I_ALLW(iindex,jindex,instrument) = monitor_ALLW(10).Data.values(1);
%I_ALLW_d(iindex,jindex,instrument) = monitor_ALLW_degraded(10).Data.values(1);
%I_ESS(iindex,jindex,instrument) = monitor_ESSW(10).Data.values(1);
%I_ESS_d(iindex,jindex,instrument) = monitor_ESSW_degraded(10).Data.values(1);
if 1==2
% hardcoded plotting extend for ODIN
monitor_num_image = 20;
close all;
figure_handle = figure(1);
set(figure_handle, 'Position', [0 0 1800 1800])
axes1 = axes('Parent',figure_handle,'YDir','reverse','Position',[0 0 1 1],'Layer','top');
object = monitor_ESSW(monitor_num_image);
signal_data = object.signal;
%x_data = object.x;
%y_data = object.y;
x_data = object{2};
y_data = object{1};
imagesc(x_data,y_data,signal_data)
colormap('gray')
axis off
%surf(peaks)
% control the image pixel size by manipulating the paper size and number of dots per inch
output_size = [1250 1250];%Size in pixels
resolution = 300;%Resolution in DPI
set(gcf,'paperunits','inches','paperposition',[0 0 output_size/resolution]);
% use 300 DPI
print([filename '_image_allW.tif'],'-dtiff',['-r' num2str(resolution)]);
for aa = 1:length(fieldnames(monitor_W_ess))
close all;
figure_handle = figure(1);
set(figure_handle, 'Position', [0 0 1800 1800])
axes1 = axes('Parent',figure_handle,'YDir','reverse','Position',[0 0 1 1],'Layer','top');
names = fieldnames(monitor_W_ess);
object = monitor_W_ess.(names{aa})(monitor_num_image);
signal_data = object.signal;
%x_data = object.x;
%y_data = object.y;
x_data = object{2};
y_data = object{1};
imagesc(x_data,y_data,signal_data)
colormap('gray')
axis off
%surf(peaks)
% control the image pixel size by manipulating the paper size and number of dots per inch
output_size = [1250 1250];%Size in pixels
resolution = 300;%Resolution in DPI
set(gcf,'paperunits','inches','paperposition',[0 0 output_size/resolution]);
% use 300 DPI
print([filename '_image_W' num2str(aa) '.tif'],'-dtiff',['-r' num2str(resolution)]);
end
end
disp(['reflogic = ' num2str(reflogic)])
%monitor_num = 11;
%monitor_num_ess = 20;
% Write txt files with wavelength and intensity /
% brilliance transfer
% Lmon naming
ALLW_ifit = assign_by_title('Lmon_sample_B.',monitor_ALLW);
ALLW_d_ifit = assign_by_title('Lmon_sample_B.',monitor_ALLW_degraded);
ESS_ifit = assign_by_title('Lmon_sample.',monitor_ESSW);
ESS_d_ifit = assign_by_title('Lmon_sample.',monitor_ESSW_degraded);
ESS_lim_ifit = assign_by_title('Lmon_sample_B.',monitor_ESSW);
ESS_d_lim_ifit = assign_by_title('Lmon_sample_B.',monitor_ESSW_degraded);
if reflogic
%brilliance_ifit = monitor_ALLW(monitor_num)/monitor_ALLW_ref(monitor_num);
LAMBDA_B_ref=assign_by_title('Lmon_sample_B.',monitor_ALLW_ref);
ALLW_B_ifit = ALLW_ifit/LAMBDA_B_ref.Data.Mean;
ALLW_d_B_ifit = ALLW_d_ifit/LAMBDA_B_ref.Data.Mean;
%LAMBDA_B_ref=assign_by_title('Lmon_sample_B.',monitor_ALLW_ref);
%brilliance_ifit=assign_by_title('Lmon_sample_B.',monitor_ALLW)/LAMBDA_B_ref.Data.Mean;
wavelength = ALLW_B_ifit{1};
brilliance = ALLW_B_ifit.signal;
%ESS_fom_ifit = monitor_ESSW(monitor_num);
ESS_fom_ifit= assign_by_title('Lmon_sample_B.',monitor_ESSW);
ESS_fom = ESS_fom_ifit.signal;
%ESS_all_ifit = monitor_ESSW(monitor_num);
ESS_all_ifit = assign_by_title('Lmon_sample.',monitor_ESSW);
ESS_all = ESS_all_ifit.signal;
% open file
fid = fopen([temp_name '.txt'], 'w');
% header line
% Works for all monitor_num
%mod_x = monitor_ALLW(monitor_num).data.mod_x;
%mod_y = monitor_ALLW(monitor_num).data.mod_y;
mod_x = ALLW_ifit.data.mod_x;
mod_y = ALLW_ifit.data.mod_y;
%sizeX = monitor_ALLW(monitor_num).data.sizeX;
%sizeY = monitor_ALLW(monitor_num).data.sizeY;
sizeX = ALLW_ifit.data.sizeX;
sizeY = ALLW_ifit.data.sizeY;
%divreq_x = monitor_ALLW(monitor_num).data.divreq_x;
%divreq_y = monitor_ALLW(monitor_num).data.divreq_y;
divreq_x = ALLW_ifit.data.divreq_x;
divreq_y = ALLW_ifit.data.divreq_y;
h_line = ['guide_bot inputstring = ' inputstring '\n'];
fprintf(fid,h_line);
h_line = ['moderator height [cm] = ' num2str(mod_y*100) '\n'];
fprintf(fid,h_line);
h_line = ['moderator width [cm] = ' num2str(mod_x*100) '\n'];
fprintf(fid,h_line);
h_line = ['sample width [cm] = ' num2str(sizeX*100) '\n'];
fprintf(fid,h_line);
h_line = ['sample height [cm] = ' num2str(sizeY*100) '\n'];
fprintf(fid,h_line);
h_line = ['horizontal divergence (plus/minus) [deg] = ' num2str(divreq_x) '\n'];
fprintf(fid,h_line);
h_line = ['vertical divergence (plus/minus) [deg] = ' num2str(divreq_y) '\n'];
fprintf(fid,h_line);
h_line = ['-------- DATA ------------ \n'];
fprintf(fid,h_line);
h_line = ['wavelength [AA], brilliance transfer [unitless], intensity within fom [n/s] (in wavelength bin), intensity on sample [n/s] (in wavelength bin)\n'];
fprintf(fid,h_line);
% write data
for ii = 1:length(wavelength)
fprintf(fid,[num2str(wavelength(ii),'%10.6f') '\t' num2str(brilliance(ii),'%6.5f') '\t' num2str(ESS_fom(ii),'%10e') '\t' num2str(ESS_all(ii),'%10e') '\n'])
end
fclose(fid)
end
for wavband = 1:length(Wmax)
%ALLW=xlim(monitor_ALLW(monitor_num),[Wmin(wavband) Wmax(wavband)]);
ALLW=xlim(ALLW_ifit,[Wmin(wavband) Wmax(wavband)]);
ALLW_wave(instrument,wavband).signal(iindex,jindex)=sum(ALLW);
ALLW_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ALLW.error.^2));
ALLW_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ALLW_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ALLW_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ALLW_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ALLW_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
if reflogic
ALLW_B = xlim(ALLW_B_ifit,[Wmin(wavband) Wmax(wavband)]);
ALLW_B_wave(instrument,wavband).signal(iindex,jindex)=mean(ALLW_B);
ALLW_B_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ALLW_B.error.^2))/length(ALLW_B.error);
ALLW_B_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ALLW_B_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ALLW_B_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ALLW_B_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ALLW_B_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
end
%ALLW_d=xlim(monitor_ALLW_degraded(monitor_num),[Wmin(wavband) Wmax(wavband)]);
ALLW_d=xlim(ALLW_d_ifit,[Wmin(wavband) Wmax(wavband)]);
ALLW_d_wave(instrument,wavband).signal(iindex,jindex)=sum(ALLW_d);
ALLW_d_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ALLW_d.error.^2));
ALLW_d_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ALLW_d_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ALLW_d_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ALLW_d_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ALLW_d_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
if reflogic
ALLW_d_B = xlim(ALLW_d_B_ifit,[Wmin(wavband) Wmax(wavband)]);
ALLW_d_B_wave(instrument,wavband).signal(iindex,jindex)=mean(ALLW_d_B);
ALLW_d_B_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ALLW_d_B.error.^2))/length(ALLW_d_B.error);
ALLW_d_B_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select < 0.5;
ALLW_d_B_wave(instrument,wavband).name = name{instrument};
else
ALLW_d_B_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ALLW_d_B_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ALLW_d_B_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ALLW_d_B_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
end
ESS=xlim(ESS_ifit,[Wmin(wavband) Wmax(wavband)]);
ESS_wave(instrument,wavband).signal(iindex,jindex)=sum(ESS);
ESS_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ESS.error.^2));
ESS_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ESS_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ESS_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ESS_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ESS_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
ESS_d=xlim(ESS_d_ifit,[Wmin(wavband) Wmax(wavband)]);
ESS_d_wave(instrument,wavband).signal(iindex,jindex)=sum(ESS_d);
ESS_d_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ESS_d.error.^2));
ESS_d_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ESS_d_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ESS_d_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ESS_d_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ESS_d_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
ESS_lim=xlim(ESS_lim_ifit,[Wmin(wavband) Wmax(wavband)]);
ESS_lim_wave(instrument,wavband).signal(iindex,jindex)=sum(ESS_lim);
ESS_lim_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ESS_lim.error.^2));
ESS_lim_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ESS_lim_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ESS_lim_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ESS_lim_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ESS_lim_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
ESS_d_lim=xlim(ESS_d_lim_ifit,[Wmin(wavband) Wmax(wavband)]);
ESS_d_lim_wave(instrument,wavband).signal(iindex,jindex)=sum(ESS_d_lim);
ESS_d_lim_wave(instrument,wavband).error(iindex,jindex)=sqrt(sum(ESS_d_lim.error.^2));
ESS_d_lim_wave(instrument,wavband).waveinfo = [Wmin(wavband) Wmax(wavband)];
if size_select > 0.5;
ESS_d_lim_wave(instrument,wavband).scan(1).name = scan_dim(1).name;
ESS_d_lim_wave(instrument,wavband).scan(1).value(iindex) = str2num(p.(scan_dim(1).name_mcstas));
if size_select == 2
ESS_d_lim_wave(instrument,wavband).scan(2).name = scan_dim(2).name;
ESS_d_lim_wave(instrument,wavband).scan(2).value(jindex) = str2num(p.(scan_dim(2).name_mcstas));
end
end
end
else
% Do I need to do anything specific to ensure zeros in the
% scan?
end
progress_logic(instrument,iindex,jindex) = 1;
if exist('ALLW_wave') > 0.5
if exist('scan_dim') > 0.5
save('progress.mat','ALLW_wave','ALLW_d_wave','ESS_wave','ESS_d_wave','ESS_lim_wave','ESS_d_lim_wave','ALLW_B_wave','ALLW_d_B_wave','scan_dim','name','list','iindex','jindex','instrument','Wmax','Wmin','wavband','progress_logic','jindex_range','iindex_range','instr_range','size_select');
else
save('progress.mat','ALLW_wave','ALLW_d_wave','ESS_wave','ESS_d_wave','ESS_lim_wave','ESS_d_lim_wave','ALLW_B_wave','ALLW_d_B_wave','name','list','iindex','jindex','instrument','Wmax','Wmin','wavband','progress_logic','jindex_range','iindex_range','instr_range','size_select');
end
end
end
end
end
end
% Includes all for debugging, can be reduced heavily.
clearvars -except ALLW_wave ALLW_d_wave ESS_wave ESS_d_wave ESS_lim_wave ESS_d_lim_wave ALLW_B_wave ALLW_d_B_wave scan_dim name list iindex jindex instrument Wmax Wmin wavband progress_logic jindex_range iindex_range instr_range size_select calculate plot_options
% Checking the .signal matrices are all the same size. If an entire row
% fails, it can lead to nasty results.
for instr = 1:length(ALLW_wave(:,1))
size_test_array(instr,:) = size(ALLW_wave(instr,1).signal);
end