-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanSee__define.pro
2073 lines (1866 loc) · 57.2 KB
/
scanSee__define.pro
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
;*************************************************************************
; Copyright (c) 2002 The University of Chicago, as Operator of Argonne
; National Laboratory.
; Copyright (c) 2002 The Regents of the University of California, as
; Operator of Los Alamos National Laboratory.
; This file is distributed subject to a Software License Agreement found
; in the file LICENSE that is included with this distribution.
;*************************************************************************
;
; this currently read the version1_1 scanSee data format
;
@u_read.pro
@fit_statistic.pro
@readScan.pro
@read_scan.pro.R2
@scan_colorbar.pro
@scan2d_roi.pro
@view3d_2d.pro
@scan2d_overlay.pro
PRO scansee_getLabels,labels,id_def,rank=rank,label_state,def=def
; rank : 0-scanH, 1-scan1, 2-scan2
;
irank = 0
if keyword_set(rank) then irank=rank
id = id_def(4:88,irank)
def = where(id gt 0)
ndet = n_elements(def)
s_array = labels(267*irank:(irank+1)*267-1)
s_array = reform(s_array,89,3)
p_name = s_array(0:3,0)
p_desc = s_array(0:3,1)
p_unit = s_array(0:3,2)
d_name = s_array(4:88,0)
d_desc = s_array(4:88,1)
d_unit = s_array(4:88,2)
label_state = { $
p_name : p_name , $
p_desc : p_desc, $
p_unit : p_unit, $
d_name : d_name , $
d_desc : d_desc, $
d_unit : d_unit, $
ndet : ndet, $
def : def, $
rank : irank $
}
END
PRO scanSee_pick3d,file,image_array,pickDet=pickDet,Dump=dump,Group=group
;+
; NAME:
; scanSee_pick3d
;
; PURPOSE:
; This method allows the user to extract 3D data array for a picked
; detector number, and the widget program view3d_2d slicer will be
; used to view the returned 3D array.
;
; It allows the user to view any axial slice (X / Y / Z) from the
; 3D array. A user can view the 2D cross section data as image,
; or ascii, or sum all the slices.
;
; CALLING SEQUENCE:
; scanSee_pick3d, File, Image_array, PickDet=pickDet [, Dump=dump]
; [,Group=group]
;
; ARGUMENTS:
; FILE - Required input file name to specifies the 3D scan file
; Image_array - Output image data array for the selected detector number
;
; KEYWORD:
; PickDet - specifies the desired detector # for big 3D scan file
; Dump - if specified, dump the read info
; Group - specifies the parent widget ID, the death of the parent
; widget will result the death of this child widget
; EXAMPLE:
;
; In this example extract the 3D data array of the detector 2 from
; a 3D scan file 'cha_0010.mda'
;
; file = '/home/beams/CHA/data/rix/cha_0049.scan'
; v3 = obj_new('scanSee',file=file)
; scanSee_pick3d,file,image_array,/dump,pickDet=2
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, April 26, 2002.
; 07-15-2002 Add x,y,z descriptions view3d_2d program
;-
pick = 16
if keyword_set(pickDet) then pick = pickDet
t1 = systime(1)
r = read_scan(file,Scan,pickDet=pick,dump=dump)
print,'Time used in read detector # ',strtrim(pick,2),' ',systime(1)-t1
if r eq -1 then return
detname = 'D'+ [strtrim(indgen(9)+1,2),'A','B','C','D','E','F' , $
'01','02','03','04','05','06','07','08','09', $
strtrim(indgen(61)+10,2)]
labels = *Scan.labels
id_def = *Scan.id_def
scansee_getLabels,labels,id_def,rank=2,label_state,def=def
zdesc = label_state.p_name(0)
if label_state.p_desc(0) ne '' then zdesc = zdesc + '('+label_state.p_desc(0)+')'
scansee_getLabels,labels,id_def,rank=1,label_state,def=def
ydesc = label_state.p_name(0)
if label_state.p_desc(0) ne '' then ydesc = ydesc + '('+label_state.p_desc(0)+')'
scansee_getLabels,labels,id_def,rank=0,label_state,def=def
xdesc = label_state.d_name(pick-1)
if label_state.p_desc(0) ne '' then xdesc = xdesc + '('+label_state.d_desc(pick-1)+')'
title = strmid(file,rstrpos(file,!os.file_sep)+1,strlen(file)) + $
'('+detname(pick-1)+')'
pa1d= *(*Scan.pa)[2]
pa2d= *(*Scan.pa)[1]
pa3d= *(*Scan.pa)[0]
zv = pa1d(*,0)
yv = pa2d(*,0)
xv = pa3d(*,0)
image_array = *(*Scan.da)[0]
view3d_2d,image_array,0,xv,yv,zv,title=title,Group=group,descs=[xdesc,ydesc,zdesc]
END
PRO scanSee::overlay,list,num_max=num_max,det_sel=det_sel,pick1d=pick1d,xdata=xdata,ydata=ydata,plot=plot,title=title,GROUP=group
;+
; NAME:
; scanSee::Overlay
;
; PURPOSE:
; This method allows the user to extract 1D scan out of scan files
; specified by a list of scan numbers. The keyword XDATA, YDATA
; returns the corresponding X, Y vector array for the list of scans.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]OVERLAY,list [,NUM_MAX=num_max] [,DET_SEL=det_sel]
; [,PICK1D=pick1d] [,XDATA=xdata] [,YDATA=ydata]
;
; ARGUMENTS:
; LIST - Specifies the list of scan numbers to be overlayed
;
; KEYWORD:
; NUM_MAX - Specifies the max number of data points in 1D scan
; (default same as num_pts[0] from the current active object)
; DET_SEL - Specifies the detector number picked (default 1)
; PICK1D - Specifies the 1D line # from the 2D scan (default 1)
; Xdata - Returns X data array xdata(num_max,nline)
; YDATA - Returns Y data array ydata(num_max,nline)
; PLOT - Specifies whether PLOT1D will be called
; TITLE - Specifies the plot tile for PLOT1D
; GROUP - Specifies the parent for PLOT1D window
;
; RESTREICTION:
; It is assumed that the list contains 1D scan file only.
; If 2D scan file detected and PICK1D is not specified then the 1st
; line of 2D image is picked.
; If the DET_SEL is not defined then the detecor 1 is assumed
;
; EXAMPLE:
; Example 1 - Extract 1D scan line # 4 from the 2D scan [2,5, 7] files
; for the detector # 5. The xdata, and ydata returns the
; position and detector array with dimension (num_max,3)
; where num_max is same as the X dim of the v1 object.
; Call obj_new is required only if v1 never been defined.
;
; v1 = obj_new('scanSee',file='/home/beams/CHA/data/xxx/cha:_0002.scan')
; v1->overlay,[2,5,7],DET_SET=5,PICK1D=4,xdata=xdata,ydata=ydata
;
; Example 2 - Extract and overlay plot the detector 5's first line scan
; from the following list of 1D/2D scan [1,2,5,7]
;
; v1->overlay,[1,2,5,7],DET_SET=5,xdata=xdata,ydata=ydata,/plot
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, June 1, 2001.
; xx-xx-xxxx comment
;-
if keyword_set(det_sel) eq 0 then det_sel = 1
if keyword_set(pick1d) eq 0 then pick1d = 1
if obj_valid(self) then begin
nfile = n_elements(list)
num_pts = *(*self.gD).num_pts
numx = num_pts(0)
if keyword_set(num_max) then numx = num_max
ydata = make_array(numx,nfile)
xdata = make_array(numx,nfile)
nms=''
for i=0,nfile-1 do begin
scanno = list(i)
nms = nms + strtrim(scanno,2)+','
if scanno lt 10000 then begin
str = '0000'
st = strtrim(scanno,2)
len = strlen(st)
strput,str,st,4-len
endif else str = strtrim(scanno,2)
filename = self.prefix+str+self.suffix
print,filename
self->Next,scanno
self->Read,dim=dim,pa1d=pa1d,da1d=da1d,da2d=da2d,pa2d=pa2d,cpt=cpt, $
id_def=id_def,num_pts=num_pts,da3d=da3d,pa3d=pa3d
;help,pa1d,da1d,pa2d,da2d,pa3d,da3d
; self->ascii2d,det_sel,/view
if dim eq 1 then begin
pt1 = cpt(0)
if pt1 gt numx then pt1 = numx
x = pa1d(*,0)
xdata(0:pt1-1,i) = x(0:pt1-1)
end
if dim ge 2 then begin
pt1 = num_pts(0)
if dim eq 3 then pt1 = num_pts(1)
if pt1 gt numx then pt1 = numx
x = pa2d(*,0)
xdata(0:pt1-1,i) = x(0:pt1-1)
end
if det_sel le (self.nd+1) then begin
v = make_array(pt1)
if dim eq 1 then v = da1d(0:pt1-1,det_sel-1)
if dim eq 2 then v = da2d(0:pt1-1,pick1d-1,det_sel-1)
if dim eq 3 then begin
if pick1d lt num_pts(2) then $
v = da2d(0:pt1-1,pick1d-1,det_sel-1)
end
ydata(0:pt1-1,i) = v(0:pt1-1)
end
end
if n_elements(title) eq 0 then $
title = 'SCAN:'+nms+ '(Detector # '+strtrim(det_sel,2) + ', Line # '+strtrim(pick1d,2)+')'
if keyword_set(plot) then plot1d,xdata,ydata,/data,title=title,group=group
end
END
PRO scanSee::Ezfit,detno=detno,row=row,column=column,group=group
view=0
if keyword_set(detno) then view=detno
lineno=0
if keyword_set(row) then lineno = row-1
self->read,dim=dim,cpt=cpt,labels=labels,id_def=id_def, $
da1d=da,pa1d=pa,da2d=da2d,pa2d=pa2d, $
view=view,x=xa,y=ya,im=im
if self.dim eq 2 then begin
wd = n_elements(xa)
ht = n_elements(ya)
im2 = im(*,0:ht-1)
if keyword_set(column) then $
ez_fit,xarray=xa,yarray=ya,im=im2,group=group,inpath=self.path, $
ipick=column-1 else $
ez_fit,xarray=xa,yarray=ya,im=im2,group=group,inpath=self.path, $
jpick=lineno
end
if dim eq 1 then begin
ez_fit,xarray=xa,yarray=ya,im=da,group=group,inpath=self.path
return
xa = pa(*,0)
def = id_def(*,0)
def = def(4:n_elements(def)-1)
nd = fix(total(def)+.1)
ya = make_array(cpt(0),nd)
id =0
for i=0,nd-1 do begin
if def(i) gt 0 then begin
ya(*,id) = da(*,i)
id = id + 1
end
end
ez_fit,xarray=xa,yarray=ya,group=group,inpath=self.path
end
END
PRO scanSee::Statistic,VX,VY,C_MASS=c_mass,X_PEAK=x_peak,Y_PEAK=y_peak, $
Y_HPEAK=y_hpeak, X_HWDL=x_hwdl,X_HWDR=x_hwdr, FWHM=fwhm,LIST=LIST, $
row=row,DETECTOR=detector,FIT=FIT,REPORT=REPORT,TITLE=TITLE,GROUP=group
;+
; NAME:
; scanSee::Statistic
;
; PURPOSE:
; This method allows the user to calculate peak,fwhm width
;
; CALLING SEQUENCE:
; Obj->[scanSee::]STATISTIC [,X,Y] ,C_MASS=c_mass,X_PEAK=x_peak, $
; Y_PEAK=y_peak,Y_HPEAK=y_hpeak, $
; X_HWDL=x_hwdl,X_HWDR=x_hwdr,FWHM=fwhm, $
; [,Row=row] [,DETECTOR=detector]
;
; ARGUMENTS:
; VX - specifies/returns the independent variable X
; VY - specifies/returns the dependent variable Y
;
; KEYWORDS:
; ROW - specifies the 1D scan row sequence number valid only if
; 2D scan file opened
; COLUMN - specifies the column number valid only if
; 2D scan file opened
; DETECTOR- specifies the desired detector number , default to 1
; C_MASS - returns the center of mass of the Y curve
; X_PEAK - returns the X coordinate corresponding to peak Y value
; Y_PEAK - returns the peak Y value
; Y_HPEAK - returns the Y value at the FWHM width
; X_FWDL - returns the left end of X coordinate of the FWHM width
; X_FWDR - returns the right end of X coordinate of the FWHM width
; FWHM - returns the full width of the half peak
; FIT - specifies whether fitting is desired before the statistic calculation
; REPORT - specifies whether rpt.listing button of data is desired
; GROUP - specifies the parent widget ID if plot desired
;
; EXAMPLE:
; Example 1 will calucultate the FWHM value for the 6th scan line and
; 2nd detector. The calculated value for center of mass, peak x, peak y,
; half peak y value, half peak x values, and width are all returned.
;
; The object v1 need to be defined only if it is not yet defined.
;
; v1 = obj_new('scanSee',file='filename.scan')
; v1->statistic,VX,VY,c_mass=cx,x_peak=xp,y_peak=yp, $
; y_hpeak=yhp,x_hwdl=xl,x_hwdr=xr,fwhm=fwhm,ROW=6,DET=2
;
; Example 2 will calucultate the FWHM value for the know vectors VY versus
; VX. The calculated value for center of mass, peak x, peak y,
; half peak y value, half peak x values, and width are all returned.
;
; v1->statistic,VX,VY,c_mass=cx,x_peak=xp,y_peak=yp, $
; y_hpeak=yhp,x_hwdl=xl,x_hwdr=xr,fwhm=fwhm
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Feb. 11, 2000.
; xx-xx-xxxx comment
;-
if n_params() eq 1 then begin
VY = VX
VX = indgen(n_elements(VY))
end
if n_params() eq 0 then begin
self->read,pa1d=pa,da1d=da,pa2d=pa2d,da2d=da2d
det=0
no=1
if keyword_set(row) then no = row
if keyword_set(detector) then det=detector-1
VX = pa(*,0)
VY = da(*,det)
if self.dim eq 2 then begin
vx = pa2d(*,0,0)
im = da2d(*,*,det)
vy = im(*,0)
if no gt 1 then vy = im(*,no-1)
if keyword_set(column) then vy = im(column-1,*)
end
end
if max(vy) eq min(vy) then begin
st = ['Not available for Detector '+strtrim(detector,2), $
'because of constant data']
r=dialog_message(st,/info)
return
end
if keyword_set(report) then $
statistic_1d,VX,VY,c_mass,x_peak,y_peak,y_hpeak,fwhm,xl,xr,/plot,list=list,report=report,TITLE=title,GROUP=group else $
statistic_1d,VX,VY,c_mass,x_peak,y_peak,y_hpeak,fwhm,xl,xr,/plot,list=list,TITLE=title,GROUP=group
if n_elements(xl) then x_hwdl = xl
if n_elements(xr) then x_hwdr = xr
END
PRO scanSee::Read,errcode,view=view,dim=dim,num_pts=num_pts,cpt=cpt,pv=pv, $
labels=labels,id_def=id_def,pa1d=pa1d,da1d=da1d,pa2d=pa2d,da2d=da2d, $
pa3d=pa3d,da3d=da3d,scanno=scanno,IP=IP,JP=JP,X=x,Y=y,Z=z,im=im, $
class=class,outpath=outpath
;+
; NAME:
; scanSee::Read
;
; PURPOSE:
; This method allows the user to get the scan data as IDL variables
; from a defined scanSee object.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]Read [,Errcode] [,Dim=dim] [, Num_pts=num_pts]
; [,Cpt=cpt] [,Pv=pv] [,Labels=Labels] [,Id_def=id_def]
; [,Pa1d=pa1d] [,Da1d=da1d] [,Pa2d=pa2d] [,Da2d=da2d]
; [,Pa3d=pa3d] [,Da3d=da3d]
; [,View=detno] [,X=x], [,Y=y] [,Im=im]
; [,Class=class] [,Outpath=outpath]
;
; ARGUMENTS:
; ERRCODE - Specifies the return code of this method.
; It is an optional input, it returns 0 for success,
; -1 for failure.
;
; KEYWORDS:
; SCANNO - returns the scan #
; DIM - returns the type of scan, 1 for 1D, 2 for 2D
; NUM_PTS - returns the requested positioner points in 1D/2D scan
; CPT - returns the actual positioner points in 1D/2D scan
; PV - returns the scan PV names
; LABELS - LABELS[267] or LABELS[267,2] returns the string
; description arrays of the 1D/2D scan for 4 positioners (X)
; and 85 detectors (Y)
; LABELS[0:3,0] - x_names
; LABELS[4:88,0] - y_names
; LABELS[89:92,0] - x_descs
; LABELS[93:177,0] - y_descs
; LABELS[178:181,0] - x_engus
; LABELS[182:266,0] - y_engus
; ID_DEF - ID_DEF[19,DIM] or returns the indicator for
; defined positoner/detector of the 1D/2D/3D scan,
; if value 0 not present, 1 present in scan record
; PA1D - PA1D[CPT[DIM-1],4] returns positional array for scan1 record
; or scan2 record for 1D/2D scan
; DA1D - PA1D[CPT[DIM-1],15] returns detector array for scan1 record
; or scan2 record for 1D/2D scan
; PA2D - PA2D[NUM_PTS[DIM-2],NUM_PTS[DIM-1],4] returns positional array
; for 2D scan
; DA2D - DA2D[NUM_PTS[DIM-2],NUM_PTS[DIM-1],15] returns detector array
; 2D scan
; PA3D - PA3D[NUM_PTS[DIM-3],NUM_PTS[DIM-2],NUM_PTS[DIM-1],4] returns
; positional array for 3D scan
; DA3D - DA3D[NUM_PTS[DIM-3],NUM_PTS[DIM-2],NUM_PTS[DIM-1],4] returns
; detector array for 3D scan
; VIEW - specifies the image of the detector # to be plotted
; X - returns the X vector of Positioner 1 of scan1 record
; Y - returns the Y vector of Positioner 1 of scan2 record
; Z - returns the Z vector of Positioner 1 of scan3 record
; IM - returns the image array for the selected detector of 2D scan
; CLASS - returns the class file name of the file
; OUTPATH - returns the write permissive output file path
;
; EXAMPLE:
; Following example reads the IOC created scan file and returns the
; IDL variables pa2d,pa1d,da2d.
; The object v2 need to be defined only if it is not yet defined.
;
; file='/home/sricat/CHA/data/rix/cha:_0010.scan'
; v2 = obj_new('scanSee',file=file)
; v2->read,da2d=da2d,pa2d=pa2d,pa1d=pa1d
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Jan 19, 2000.
; 03-02-2000 PA1D, DA1D returns actual number of points saved
;-
errcode = -1
scanno = -1
if self.scanno lt 0 or self.dim lt 1 then return
errcode = 0
scanno = *(*self.gD).scanno
dim = *(*self.gD).dim
num_pts = *(*self.gD).num_pts
cpt = *(*self.gD).cpt
pv = *(*self.gD).pv
labels = *(*self.gD).labels
id_def = *(*self.gD).id_def
if dim gt 3 then return
ndim = n_elements(id_def)/dim
nd = ndim - 4
for i=4,ndim-1 do begin
if id_def(i) gt 0 then nd=i-4
end
self.nd = nd
pa1 = *(*self.gD).pa1D
da1 = *(*self.gD).da1D
pa3d = *(*self.gD).pa3D
da3d = *(*self.gD).da3D
pa2d = *(*self.gD).pa2D
da2d = *(*self.gD).da2D
pa1d = *(*self.gD).pa1D
da1d = *(*self.gD).da1D
if dim eq 1 then begin
w = cpt(0)
if cpt(0) eq 0 then w = num_pts(0)
pa1D = pa1(0:w-1,*)
da1D = da1(0:w-1,*)
x = pa1D(*,0) ;pa1D(0:w-1,0)
end
if dim eq 2 then begin
h = cpt(DIM-1)
if h eq 0 then h = num_pts(DIM-1)
pa1D = pa1(0:h-1,*)
da1D = da1(0:h-1,*)
x = pa2d(*,0) ;pa2D(*,0,0)
y = pa1D(*,0)
detector=1
im = da2d(*,*,0)
if keyword_set(view) then begin
if view gt 1 then detector = view
sz = size(da2d)
if sz(3) lt detector then detector = sz(3)
im = da2d(*,*,detector-1)
dname = self.detname(detector-1)
scan2Ddata,self.gD,detector,/view,xarr=xarr,yarr=yarr,im=im,dname=dname
end
end
if dim eq 3 then begin
w = cpt(DIM-3)
if w eq 0 then w = num_pts(DIM-3)
x = pa3D(*,0) ;pa3D(0:w-1,0,0,0)
h = cpt(DIM-2)
if h eq 0 then h = num_pts(DIM-2)
y = pa2D(*,0) ;pa2D(0:h-1,0,0)
d = cpt(DIM-1)
if d eq 0 then d = num_pts(DIM-1)
; pa1D = pa1(0:d-1,*)
; da1D = da1(0:d-1,*)
z = pa1D(*,0) ;pa1D(0:d-1,0)
self.width = num_pts(0)
self.height = num_pts(1)
end
class = self.name
outpath = self.outpath
;help,pa3d,da3d,pa2d,da2d,pa1d,da1d,x,y,z
;help,labels,pv,id_def
END
PRO scanSee::view3d_panImage,slice,rank,data,tiff=tiff,reverse=reverse,pict=pict,xdr=xdr,group=group,SEL=SEL
;+
; NAME:
; scanSee::VIEW3D_PANIMAGE
;
; PURPOSE:
;
; CATEGORY:
; Widgets.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]VIEW3D_PANIMAGE, Slice [,Rank] [,Data] [,/TIFF]
; [,/REVERSE] [,/XDR] [,/PICT] [,GROUP=group]
;
; ARGUMENTS:
; Slice - Specifies the slice # in the viewing direction
; RANK - Specifies the viewing axis direction, 0-X axis, 1-Y axis,
; 2-Z axis, default is Z axis
; DATA - returns the panimage data array
;
; KEYWORDS:
; TIFF - specifies the output tiff filename
; REVERSE - indicates the reverse tiff is desired
; PICT - specifies the output pict filename
; XDR - specifies the output XDR filename
; GROUP - specifies the parent widget ID
; SEL - provides selection dialog for panimage
;
; RESTRICTION:
; The scanSee object must be a 3D scan object.
;
; EXAMPLE:
; Following example examines the various 2D slice for detector number 1
; for a given 3D scan object v2
;
; v2 = obj_new('scanSee',file='/home/sricat/CHA/data/rix/cha:_0049.scan')
; v2->view3d_panimage
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, April 7, 2000.
; 11-03-2000 Remove GIF file generation
; Add panimage_sel support
; Add u_read,u_write,u_open XDR data format
;
;-
if self.dim ne 3 then begin
r = dialog_message('Error! The object is not a 3D scan',/error)
return
end
if n_elements(rank) eq 0 then rank = 2
no = (*(*self.gD).num_pts)[rank]
kindex = 0
if n_elements(slice) ne 0 then kindex = slice
if kindex ge no then return
filename = self.file
xyz = *(*self.gD).da3D
if n_elements(xyz) lt 3 then return
id_def = self.def
if rank eq 2 then data = reform(xyz(*,*,kindex,*))
if rank eq 1 then data = reform(xyz(*,kindex,*,*))
if rank eq 0 then data = reform(xyz(kindex,*,*,*))
scanno = '.panZ'
if rank eq 0 then scanno = '.panX'
if rank eq 1 then scanno = '.panY'
scanno = scanno + '_'+strtrim(kindex,2)
title = '3D Scan #'+strtrim(self.scanno,2)+scanno
class = self.name
if keyword_set(TIFF) then $
tiff = self.outpath+'TIFF'+!os.file_sep+class+ $
scanno+'.tiff'
if keyword_set(REVERSE) then $
tiff = self.outpath+'TIFF'+!os.file_sep+class+ $
scanno+'.rtiff'
if keyword_set(XDR) then $
xdr = self.outpath+'XDR'+!os.file_sep+class+ $
scanno+'.xdr'
if keyword_set(PICT) then $
pict = self.outpath+'PICT'+!os.file_sep+class+ $
scanno+'.pict'
nw = self.win
if keyword_set(SEL) then $
panImage_sel,data,id_def,new_win=nw,tiff=tiff,title=title else $
panImage,data,id_def,new_win=nw,tiff=tiff,reverse=reverse,pict=pict,xdr=xdr,title=title
self.win = nw
END
PRO scanSee::view3d_2d,det,group=group,title=title,slicer3=slicer3
;+
; NAME:
; scanSee::VIEW3D_2D
;
; PURPOSE:
; This method allows the user flexiblely examine any 2D slice out
; from a defined scanSee 3D scan object. It allows the user view the
; 2D slice as various 1D/2D plots or ASCII output.
;
; CATEGORY:
; Widgets.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]VIEW3D_2D, Det [,GROUP=group] [,TITLE=title]
; [,SLICER3=slicer3]
;
; ARGUMENTS:
; Det - Specifies detecotr #, extracts the 3D array asscocited with
; the the detector #
;
; KEYWORDS:
; GROUP - Specifies the parent widget ID
; TITLE - Overrides default VIEW3D_2D window title by this specification
; SLICER3 - Specifies whether view the 3D array by the SLICER3 program
;
; RESTRICTION:
; The scanSee object must be a 3D scan object.
;
; EXAMPLE:
; Following example examines the various 2D slice for detector number 1
; for a given 3D scan object v2
;
; v2 = obj_new('scanSee',file='/home/sricat/CHA/data/rix/cha:_0049.scan')
; v2->view3d_2d,1
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, April 4, 2000.
; 12-01-2000 Add scan # to title
; 07-10-2002 Add X,Y,Z axis label description to view3d_2d
;
;-
if self.dim ne 3 then begin
r = dialog_message('Error! The object is not a 3D scan',/error)
return
end
detector = 1
if n_elements(det) then detector = det
if detector le 0 or detector gt 85 then detector = 1
da3d = *(*self.gD).da3D
cpt = *(*self.gD).cpt
npts = *(*self.gD).num_pts
pv = *(*self.gD).pv
labels = *(*self.gD).labels
id_def = *(*self.gD).id_def
scansee_getLabels,labels,id_def,rank=2,label_state,def=def
zdesc = label_state.p_name(0)
if label_state.p_desc(0) ne '' then zdesc = zdesc + '('+label_state.p_desc(0)+')'
scansee_getLabels,labels,id_def,rank=1,label_state,def=def
ydesc = label_state.p_name(0)
if label_state.p_desc(0) ne '' then ydesc = ydesc + '('+label_state.p_desc(0)+')'
scansee_getLabels,labels,id_def,rank=0,label_state,def=def
xdesc = label_state.d_name(detector-1)
if label_state.p_desc(0) ne '' then xdesc = xdesc + '('+label_state.d_desc(detector-1)+')'
sz = size(da3d)
if sz(0) eq 4 then begin
if cpt(2) lt npts(2) then $
data = da3d(*,*,0:cpt[2],detector-1) else $
data = da3d(*,*,*,detector-1)
endif else data = da3d
if keyword_set(title) eq 0 then title='3D Scan# '+strtrim(self.scanno,2)+', '+pv(0)+', ('+self.detname(detector-1) +')'
view3d_2d,data,group=group,title=title,slicer3=slicer3,descs=[xdesc,ydesc,zdesc]
END
PRO scanSee::Images,image_array,def,vmax,vmin,X=x,Y=y,panimage=panimage
;+
; NAME:
; scanSee::Images
;
; PURPOSE:
; This method allows the user to get the complete 2D scan image array
; from a defined scanSee object.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]Images,Image_array [,Def] [,Vmax] [,Vmin]
; [,X=x] [,Y=y] [,/PANIMAGE]
;
; ARGUMENTS:
; IMAGE_ARRAY - returns the complete set of image array for a 2D scan
; IMAGE_ARRAY[NUM_PTS[0],NUM_PTS[1],15]
; DEF[15] - returns the vector of indicators for detectors
; 0 - not defined, 1 - defined
; VMAX[15] - returns the maximum of image_array(*,*,i)
; VMAX[15] - returns the minimu of image_array(*,*,i)
;
; KEYWORDS:
; PANIMAGE - if specified the panimage window will pop up
; X - returns the X position vector
; Y - returns the Y position vector
;
; EXAMPLE:
; Following example extracts the image_array from the input file and also
; plot the 2D panimage.
; The object v2 need to be defined only if it is not yet defined.
;
; v2 = obj_new('scanSee',file=file)
; v2->images,image_array,/panimage
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Jan 19, 2000.
; xx-xx-xxxx comment
;-
if self.dim eq 1 then return
image_array = *(*self.gD).da2D
pa1D = *(*self.gD).pa1D
pa2D = *(*self.gD).pa2D
x = pa2D(*,0,0)
y = pa1D(*,0)
def = self.def
nd = self.nd
id_def = *(*self.gD).id_def
if self.dim eq 3 then def = id_def(4:88,1)
vmin = make_array(nd+1,/float)
vmax = make_array(nd+1,/float)
for i=0,nd do begin
if def(i) gt 0 then begin
vmax(i) = max(image_array(*,*,i))
vmin(i) = min(image_array(*,*,i))
end
end
if keyword_set(panimage) then begin
if self.dim eq 3 then begin
panImage,image_array,def
endif else self->panImage
end
END
PRO scanSee::panImage,SEL=SEL,TIFF=TIFF,XDR=XDR,PICT=PICT,REVERSE=REVERSE
;+
; NAME:
; scanSee::PanImage
;
; PURPOSE:
; This method allows the user to view detector images in a pop up window.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]PanImage] [,SEL=SEL] [,TIFF=TIFF] [,REVERSE=REVERSE]
; [,PICT=PICT] [,XDR=XDR]
;
; ARGUMENTS:
; None.
;
; KEYWORDS:
; TIFF - specifies the output tiff filename
; REVERSE - indicates the reverse tiff is desired
; PICT - specifies the output pict filename
; XDR - specifies the output xdr filename
; GROUP - specifies the parent widget ID
; SEL - specifies the selection dialog
;
; EXAMPLE:
; Following example pops up the panimage window for the input scanSee file
; and also save as a TIFF file in reverse order.
; The object v2 need to be defined only if it is not yet defined.
;
; v2 = obj_new('scanSee',file=file)
; v2->panImage,tiff='file.tiff',/reverse
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Jan 19, 2000.
; xx-xx-xxxx comment
; 11-03-2000 Add the panImage selection option
;-
; pops up pan images
image_array = *(*self.gD).da2D
sz = size(image_array)
seq = self.scanno
id_def = *(*self.gD).id_def
if self.dim eq 3 then def = id_def(4:4+sz(3)-1,1) else $
def = self.def(0:sz(3)-1)
title=self.name+' SCAN # '+strtrim(seq,2)
catch,error_status
if error_status ne 0 then begin
if !error_state.name eq 'IDL_M_CNTOPNFIL' then begin
r = dialog_message([!error_state.msg,!error_state.sys_msg,$
string(!error_state.code)],/error)
return
end
self.win = -1
return
end
if self.win ne -1 then wdelete,self.win
self.win = -1
if keyword_set(SEL) then begin
nw = self.win
panImage_sel,image_array,def,new_win=nw,title=title
self.win = !d.window
return
end
update:
width = 60
height = 60
old_win = !D.window
if n_elements(factor) then begin
if factor lt .1 then factor = 1
width = width * factor
height = height * factor
end
ND = sz(3) ; 85
NC = 8
NR = ND/8 + 1
NL = NR*NC - 1
if self.win lt 0 then begin
window,/free, xsize = NC*width, ysize=NR*height, $
title=title,retain=2
for i=0,ND-1 do begin
ii = NL-i
xi=(i mod NC)*width+width/2 - 5
yi=height/2+ii/NC*height
xyouts, xi,yi,self.detname(i),/device
end
end
new_win = !D.window
self.win = new_win
wset,new_win
for sel=0,ND-1 do begin
if def(sel) gt 0 then begin
v_max = max(image_array(*,*,sel),min=v_min)
if v_max eq v_min then begin
temp = !d.table_size * image_array(*,*,sel)
TV,congrid(temp,width,height),sel
endif else begin
temp = congrid(image_array(*,*,sel), width, height)
TVSCL, temp, sel
end
end
end
for i=1,NR-1 do plots,[0,NC*width],[i*height,i*height],/device
for i=1,NC-1 do plots,[i*width,i*width],[0,NR*height],/device
if keyword_set(TIFF) then begin
tvlct,r,g,b,/get
tiffname = strtrim(tiff,2)
if keyword_set(reverse) then $
write_tiff,tiffname,reverse(TVRD(),2),1,red=r,green=g,blue=b $
else write_tiff,tiffname,TVRD(),red=r,green=g,blue=b
end
if keyword_set(XDR) then begin
xdrname = strtrim(xdr,2)
u_openw,unit,xdrname,/XDR,error=error
u_write,unit,image_array
u_close,unit
end
if keyword_set(PICT) then begin
tvlct,r,g,b,/get
gifname = strtrim(pict,2)
write_pict,gifname,TVRD(),r,g,b
end
wset,old_win
if old_win eq 0 then wdelete,0
END
PRO scanSee::Next,seqno,filename,error=error,pickDet=pickDet
;+
; NAME:
; scanSee::Next
;
; PURPOSE:
; This method points to the next scan # file saved by IOC.
;
; CALLING SEQUENCE:
; Obj->[scanSee::]Next [,Seqno]
;
; ARGUMENTS:
; SEQNO - jumps to the scan # seqno file if it is specified.
; FILENAME - returns the new filename
;
; KEYWORD:
; ERROR - returns the error code, non-zero if not found
; PICKDET - control the 3D data array returned
; pickdet=-1 no 3D data will be returned
;
; EXAMPLE:
; Following examples replace the current object by next scan number.
; If current file is 'cha:_0010.scan' then the object will be replaced
; by 'cha:_0011.scan' in Example 1.
; Example 2 jumps to the 'cha:_0100.scan' file.
;
; v2->Next
; v2->Next,100
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Jan 19, 2000.
; xx-xx-xxxx comment
;-
error=0
scanno = self.scanno + 1
if n_elements(seqno) gt 0 then scanno = seqno
if scanno lt 10000 then begin
str = '0000'
st = strtrim(scanno,2)
len = strlen(st)
strput,str,st,4-len
endif else str = strtrim(scanno,2)
filename = self.prefix+str+self.suffix
print,filename
; if next seqno found then replace the current
found = findfile(filename,count=ct)
if ct gt 0 then begin
self->delete
self = obj_new('scanSee',file=filename,pickDet=pickDet)
endif else begin
res = dialog_message(filename+' not found!',/Error)
error=-1
end
if n_elements(seqno) then seqno = seqno + 1
END
PRO scanSee::Prev,seqno,filename,error=error,pickDet=pickDet