-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.pro
1388 lines (1299 loc) · 62.5 KB
/
gui.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
; *******************************************************************
; Multfit efficient processing of 2D diffraction images
; Copyright (C) 2000-2014 S. Merkel, Universite Lille 1
; http://merkel.zoneo.net/Multifit/
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
; *******************************************************************
; ******************************************************************
; Saves and reads basic information about multifit in hidden file for future
; uses
;
pro readdefault
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common experiment, wavelength, detectordistance, experimenttype
common inputfiles, inputfiles, activeset
defaultdir = GETENV('HOME')
; set default values
datadirectory = defaultdir
outputdirectory = defaultdir
defaultdirectory = defaultdir
jcpdsdirectory = defaultdir
extension = '.chi'
wavelength=0.4000
detectordistance=200.
experimenttype = "General"
; If we are using UNIX, try to see if we saved a default file
if (STRUPCASE(!VERSION.OS_FAMILY) eq 'UNIX') then begin
default = GETENV('HOME') + "/" + ".multifit"
if (file_test(default)) then begin
openr, lun, default, /get_lun
while ~ EOF(lun) do begin
row = ""
readf, lun, row
word = strsplit(row, COUNT=nn, /EXTRACT)
if (nn gt 1) then begin
label = STRUPCASE(word[0])
CASE label OF
"WORK_DIRECTORY:": defaultdirectory = word[1]
"JCPDS_DIRECTORY:": jcpdsdirectory = word[1]
"DATA_DIRECTORY:": datadirectory = word[1]
"OUTPUT_DIRECTORY:": outputdirectory = word[1]
"EXTENSTION:": extension = word[1]
"WAVELENGTH:": wavelength = float(word[1])
"DETECTORDISTANCE:": detectordistance = float(word[1])
"EXPERIMENTTYPE:": experimenttype = word[1]
'INPUTFILES': begin
inpufiles = strsplit(words[1], ';', /EXTRACT)
activeset = 0
end
else:
endcase
endif
endwhile
free_lun, lun
endif
endif
end
pro savedefaults
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common experiment, wavelength, detectordistance, experimenttype
common inputfiles, inputfiles, activeset
if (!D.NAME eq 'WIN') then newline = string([13B, 10B]) else newline = string(10B)
str = "# Multifit default parameters" + newline
str += "WORK_DIRECTORY: " + defaultdirectory + newline
str += "JCPDS_DIRECTORY: " + jcpdsdirectory + newline
str += "DATA_DIRECTORY: " + datadirectory + newline
str += "OUTPUT_DIRECTORY: " + outputdirectory + newline
str += "EXTENSTION: " + extension + newline
str += "WAVELENGTH: " + string(wavelength) + newline
str += "DETECTORDISTANCE: " + string(detectordistance) + newline
str += "EXPERIMENTTYPE: " + experimenttype + newline
if (size(inputfiles, /TYPE) ne 0) then begin
input = STRJOIN( inputfiles, ';' )
str += '# Input files' + newline
str += 'INPUTFILES|' + input + newline
endif
if (STRUPCASE(!VERSION.OS_FAMILY) eq 'UNIX') then begin
default = GETENV('HOME') + "/" + ".multifit"
; print, "Trying to write " + str
openw, lun, default, /get_lun
printf, lun, str
free_lun, lun
endif
end
; ********************************* LOAD_DEFAULTS *********************************
PRO load_defaults_startup
common fonts, titlefont, boldfont, mainfont, avFontHeight
; default color palette and font for plots
OS = strupcase(!VERSION.OS)
OS = strmid(OS,0,3)
if (OS ne 'WIN') then device, true_color=24
device, decomposed=0
loadct, 15, /SILENT
DEVICE, SET_FONT='Helvetica Bold', /TT_FONT, SET_CHARACTER_SIZE=[8,10]
; default for plots
!P.MULTI = 0
; Fonts
if (OS ne 'WIN') then begin
mainfont = '-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*'
titlefont = '-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*'
boldfont = '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*'
; calculating conversion between font size in and number of pixels
; need for some user interface stuff
scale = !D.X_PX_CM ; how many pixels in a cm
; There are 72 pt per inch. Main font is 12 pt, therefore, average font
; height will be
avFontHeight = fix(12.*scale*2.54/72.)
endif else begin
titlefont = 'helvetica*bold*14'
boldfont = 'helvetica*bold*12'
mainfont = 'helvetica*14'
; calculating conversion between font size in and number of pixels
; need for some user interface stuff
scale = !D.X_PX_CM ; how many pixels in a cm
; There are 72 pt per inch. Main font is 12 pt, therefore, average font
; height will be
avFontHeight = fix(12.*scale*2.54/72.)
; we divide it by 2 in windows. Things look better
avFontHeight = fix(avFontHeight/2)
endelse
WIDGET_CONTROL, DEFAULT_FONT=mainfont
; Read other things from a default file
readdefault
end
; ****************************************** about window **************
PRO aboutWindow_event, ev
WIDGET_CONTROL, ev.TOP, /DESTROY
END
pro aboutWindow, base
common fonts, titlefont, boldfont, mainfont, avFontHeight
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base, Title='About Multifit')
infobase = WIDGET_BASE(basedialog,/COLUMN)
la = WIDGET_TEXT(infobase, XSIZE=80, YSIZE=20, /ALIGN_LEFT, /EDITABLE, /WRAP)
ccr = STRING(13B) ; Carriage Return
clf = STRING([10B]) ; line feed
text = "Multifit" + ccr + clf
text += "Homepage: http://merkel.zoneo.net/Multifit-Polydefix" + ccr + clf + ccr + clf
text += "Multifit/Polydefix is an open-source IDL software package for an efficient processing of diffraction data obtained in deformation apparatuses at synchrotron beamlines. It is a compound of three different packages that can be run independently. Multifit is dedicated to the fitting of two-dimensional (2-D) diffraction data. It will extract d-spacings, intensities, and half-widths for peaks of a given material, for multiple azimuthal slices and over multiple diffraction images." + ccr + clf + ccr + clf
text += "Copyright S. Merkel, N. Hilairet Universite Lille 1, France" + ccr + clf
text += "Multifit is open source software, licensed under the GPL Version 2." + ccr + clf
text += "" + ccr + clf
text += "If you use results of Multifit/Polydefix in scientific publications, please refer to the following paper" + ccr + clf + ccr + clf
text += "S. Merkel and N. Hilairet, Multifit/Polydefix: a Framework for the Analysis of Polycrystal Deformation using X-Rays, Journal of Applied Crystallography, 48, 1307-1313 (2015) [doi: 10.1107/S1600576715010390]."
WIDGET_CONTROL, la, SET_VALUE=text, /APPEND
WIDGET_CONTROL, la, SET_TEXT_TOP_LINE=0
buttons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(buttons, VALUE='Ok', UVALUE='OK', xsize=80)
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'aboutWindow', basedialog
end
; ****************************************** LOGIT **************
PRO logit, log, txt
text = txt
WIDGET_CONTROL, log, SET_VALUE=text, /APPEND
END
; ****************************************** SAVEPARAMS ********************************
PRO saveparams, base, log
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common experiment, wavelength, detectordistance, experimenttype
common inputfiles, inputfiles, activeset
filename=dialog_pickfile(title='Save parameters into...', path=defaultdirectory, DIALOG_PARENT=base, DEFAULT_EXTENSION='.par', FILTER=['*.par'], /WRITE, /OVERWRITE_PROMPT)
if (filename ne '') then begin
filename = addextension(filename, 'par')
openw, lun, filename, /get_lun
printf, lun, '# Parameter file for multfit'
printf, lun, '# Directory with chi and idl files'
printf, lun, 'directory|'+datadirectory
printf, lun, '# Directory with image fits'
printf, lun, 'outputdirectory|'+outputdirectory
printf, lun, '# Wavelength (Angstroms)'
printf, lun, 'wavelength|'+ STRING(wavelength, /PRINT)
printf, lun, '# Detector distance (mm)'
printf, lun, 'detectordistance|' + STRING(detectordistance, /PRINT)
printf, lun, '# Experiment type ("General")'
printf, lun, 'experimenttype|' + experimenttype
if (size(inputfiles, /TYPE) ne 0) then begin
input = STRJOIN( inputfiles, ';' )
printf, lun, '# Input files'
printf, lun, 'inputfiles|'+input
endif
free_lun, lun
logit, log, "Parameters save in " + filename
FDECOMP, filename, disk, dir, name, qual, version
defaultdirectory = disk+dir
endif
END
PRO readparams, base, log, listSets, stash
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common experiment, wavelength, detectordistance, experimenttype
;stash = {base: base, log:log, baseoptions: baseoptions, $
; inputDirText:inputDirText, outputDirText:outputDirText, waveText:waveText, ipDistanceText: ipDistanceText, $
; listSets: listSets, defaultBase:defaultBase, bottom:bottom, listBase:listBase, listLa:listLa, mapplot:mapplot, plotactive:plotactive }
filename=dialog_pickfile(title='Read parameters from...', path=defaultdirectory, DIALOG_PARENT=base, FILTER=['*.par','*.*'], /must_exist)
if (filename ne '') then begin
; print, "Want to open ", filename
openr, lun, filename, /get_lun
while ~ EOF(lun) do begin
row = ""
readf, lun, row
words = strsplit(row, '|', /EXTRACT)
case words[0] of
'directory': begin
datadirectory = words[1]
WIDGET_CONTROL, stash.inputDirText, SET_VALUE=datadirectory
end
'outputdirectory': begin
outputdirectory = words[1]
WIDGET_CONTROL, stash.outputDirText, SET_VALUE=outputdirectory
end
'wavelength': begin
wavelength = float(words[1])
WIDGET_CONTROL, stash.waveText, SET_VALUE=strtrim(string(wavelength),2)
end
'detectordistance': begin
detectordistance = float(words[1])
WIDGET_CONTROL, stash.ipDistanceText, SET_VALUE=strtrim(string(detectordistance),2)
end
'inputfiles': inpufilesFromList, log, listSets, strsplit(words[1], ';', /EXTRACT)
'experimenttype': experimenttype = words[1]
else:
endcase
endwhile
close, lun
logit, log, "Parameters read from " + filename
FDECOMP, filename, disk, dir, name, qual, version
defaultdirectory = disk+dir
endif
end
; ****************************************** CHGINPUTDIR *********************************
PRO chgInputDir, base, log, widget
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
result=dialog_pickfile(/DIRECTORY,title='Select input directory', path=datadirectory, DIALOG_PARENT=base)
if (result ne '') then begin
datadirectory = result
inputDirLabel = 'Input directory: ' + datadirectory
WIDGET_CONTROL, widget, SET_VALUE=datadirectory
logit, log, inputDirLabel
endif
END
; ****************************************** CHGOUTPUTDIR *************************************
PRO chgOutputDir, base, log, widget
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
result=dialog_pickfile(/DIRECTORY,title='Select output directory', path=outputdirectory, DIALOG_PARENT=base)
if (result ne '') then begin
outputdirectory=result
outputDirLabel = 'Output directory: ' + outputdirectory
WIDGET_CONTROL, widget, SET_VALUE=outputdirectory
logit, log, outputDirLabel
endif
END
; ****************************************** CHGWAVELENGTH *************************************
PRO chgWavelength_event, ev
common experiment, wavelength, detectordistance, experimenttype
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.waveText, GET_VALUE=wavelength
wavlength = float(wavelength)
waveLabel = 'Wavelength: ' + STRING(wavelength, /PRINT) + ' angstroms'
WIDGET_CONTROL, stash.widget, SET_VALUE=STRTRIM(STRING(wavelength, /PRINT),2)
logit, stash.log, waveLabel
endif
WIDGET_CONTROL, ev.TOP, /DESTROY
END
PRO chgWavelength, base, log, widget
common experiment, wavelength, detectordistance, experimenttype
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
waveBase = WIDGET_BASE(basedialog,/ROW)
waveLa = WIDGET_LABEL(waveBase, VALUE='Wavelength (in angstroms)', /ALIGN_LEFT)
waveText = WIDGET_TEXT(waveBase, XSIZE=10, VALUE=STRING(wavelength,/PRINT), /EDITABLE)
waveButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(waveButtons, VALUE='Ok', UVALUE='OK')
cancel = WIDGET_BUTTON(waveButtons, VALUE='Cancel', UVALUE='CANCEL')
stash = {widget:widget, waveText:waveText, log:log}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'chgWavelength', basedialog
END
; ****************************************** CHGDETECTORDISTANCE *************************************
PRO chgDetectorDistance_event, ev
common experiment, wavelength, detectordistance, experimenttype
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.waveText, GET_VALUE=detectordistance
detectordistance = float(detectordistance)
waveLabel = 'Detector Distance: ' + STRING(detectordistance, /PRINT) + ' mm'
WIDGET_CONTROL, stash.widget, SET_VALUE=STRTRIM(STRING(detectordistance, /PRINT),2)
logit, stash.log, waveLabel
endif
WIDGET_CONTROL, ev.TOP, /DESTROY
END
PRO chgDetectorDistance, base, log, widget
common experiment, wavelength, detectordistance, experimenttype
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
waveBase = WIDGET_BASE(basedialog,/ROW)
waveLa = WIDGET_LABEL(waveBase, VALUE='Sample-Detector distance (in mm)', /ALIGN_LEFT)
waveText = WIDGET_TEXT(waveBase, XSIZE=10, VALUE=STRING(detectordistance,/PRINT), /EDITABLE)
waveButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(waveButtons, VALUE='Ok', UVALUE='OK')
cancel = WIDGET_BUTTON(waveButtons, VALUE='Cancel', UVALUE='CANCEL')
stash = {widget:widget, waveText:waveText, log:log}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'chgDetectorDistance', basedialog
END
; ****************************************** READ AND CONVERT CHI FILES **************
; Convert one series of chi files created by Fit2d multi-chi output
PRO convertonemultichi_event, ev
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.startiText, GET_VALUE=starti
WIDGET_CONTROL, stash.endiText, GET_VALUE=endi
WIDGET_CONTROL, stash.slicesText, GET_VALUE=slices
WIDGET_CONTROL, stash.nameText, GET_VALUE=basename
logit, log, "Read series of text files: " + basename + " with angles from " + starti + " to " + endi + " with " + slices + " slices"
startiFlt = FLOAT(starti)
endiFlt = FLOAT(endi)
slicesInt = FIX(FLOAT(slices))
; print, slicesInt, typename(slicesInt), n_elements(slicesInt)
result = read_multichi(basename, startiFlt, endiFlt, slicesInt[0], log)
if (result eq 1) then begin
logit, log, "Read series of text files: success"
outputname = basename + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
WIDGET_CONTROL, ev.TOP, /DESTROY
endif else begin
tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result, /ERROR)
logit, log, "Read series of text files: failed"
endelse
endif else begin
logit, log, "Read series of text files: canceled"
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
END
; Convert one series of chi files created by Fit2d multi-chi output
PRO convertonemultichi, base, log
common inputinfo, string
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
nameLa = WIDGET_LABEL(nameBase, VALUE='Base for name of chi files', /ALIGN_LEFT)
startiLa = WIDGET_LABEL(nameBase, VALUE='First azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Last azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Number of slices', /ALIGN_LEFT)
nameText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
startiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
slicesText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
stash = {log:log, nameText:nameText, slicesText:slicesText, startiText:startiText, endiText:endiText}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'convertonemultichi', basedialog
END
; Convert series of chi files created by Fit2d multi-chi output for a whole load of images
PRO converfileseriesmultichi_event, ev
common inputfiles, inputfiles, activeset
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
; HELP, /STRUCTURE, ev
; Catching return keys in WIDGET_TEXT
tn = tag_names(ev)
index = where(tn eq "TYPE", nmatch)
if (nmatch gt 0) then if (ev.TYPE eq 0) then uval='OK'
;
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.startiText, GET_VALUE=starti
WIDGET_CONTROL, stash.endiText, GET_VALUE=endi
WIDGET_CONTROL, stash.fimageText, GET_VALUE=firstimage
WIDGET_CONTROL, stash.limageText, GET_VALUE=lastimage
WIDGET_CONTROL, stash.slicesText, GET_VALUE=slices
WIDGET_CONTROL, stash.nameText, GET_VALUE=basename
logit, log, "Read series of images created with multi-chi ouput: " + basename + ", image " + firstimage + " to " + lastimage + " with angles from " + starti + " to " + endi + " with " + slices + " slices"
startiFlt = FLOAT(starti)
endiFlt = FLOAT(endi)
slicesInt = FIX(FLOAT(slices))
fimage = FIX(FLOAT(firstimage[0]))
limage = FIX(FLOAT(lastimage[0]))
; print, slicesInt, typename(slicesInt), n_elements(slicesInt)
noclose = 1
error = 0
for i = fimage,limage do begin
file = basename + "_" + intformat(i,3)
result = read_multichi(file, startiFlt, endiFlt, slicesInt[0], log)
if (isa(result,/number)) then begin
if (result eq 1) then begin
logit, log, "Read chi files data for " + file
outputname = file + ".idl"
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Saved data in MULTIFIT format to " + outputname
noclose = 0
endif else begin
; tmp = DIALOG_MESSAGE(res, /ERROR)
error = 1
logit, log, "Save data in MULTIFIT format failed for " + outputname
endelse
endif else begin
; tmp = DIALOG_MESSAGE(result, /ERROR)
error = 1
logit, log, "Failed reading chi files for " + file + ". Skipping to next dataset."
endelse
endif else begin
; tmp = DIALOG_MESSAGE(result, /ERROR)
error = 1
logit, log, "Failed reading chi files for " + file + ". Skipping to next dataset."
endelse
endfor
if (noclose eq 0) then begin
n = 0
inputText = strarr(limage-fimage+1)
for j=fimage,limage do begin
fileindex = intformat(j,3);
filenameshort = strtrim(basename) + "_" + fileindex + ".idl"
filename = datadirectory + filenameshort
if (FILE_TEST(filename) eq 1) then begin
inputText[n] = filenameshort
n = n + 1
endif
endfor
inputText2 = inputText[0:(n-1)]
WIDGET_CONTROL, stash.listwidget, SET_VALUE=inputText2
inputfiles = inputText
logit, log, "Set multipe datasets: " + strtrim(basename) + "_" + intformat(fimage,3) + ".idl to " + strtrim(basename) + "_" + intformat(limage,3) + ".idl"
changeActiveSet, log, stash.listwidget, 0
if (error eq 1) then tmp = DIALOG_MESSAGE("Finished converting but there were some error. Have a look at the log window.", /ERROR)
WIDGET_CONTROL, ev.TOP, /DESTROY
endif else tmp = DIALOG_MESSAGE("Error: no conversion. Have a look at the log window.", /ERROR)
endif else begin
logit, log, "Read series of text files: canceled"
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
END
; Convert series of chi files created by Fit2d multi-chi output for a whole load of images
PRO convertfileseriesmultichi, base, log, listwidget
common inputinfo, string
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
nameLa = WIDGET_LABEL(nameBase, VALUE='Base for name of file name', /ALIGN_LEFT)
nameLa = WIDGET_LABEL(nameBase, VALUE='First image number', /ALIGN_LEFT)
nameLa = WIDGET_LABEL(nameBase, VALUE='Last image number', /ALIGN_LEFT)
startiLa = WIDGET_LABEL(nameBase, VALUE='First azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Last azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Number of slices', /ALIGN_LEFT)
nameText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
fimageText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
limageText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
startiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
slicesText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
stash = {log:log, listwidget:listwidget, nameText:nameText, slicesText:slicesText, startiText:startiText, endiText:endiText, fimageText: fimageText, limageText:limageText}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'converfileseriesmultichi', basedialog
END
PRO convertonechi_event, ev
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.startiText, GET_VALUE=starti
WIDGET_CONTROL, stash.endiText, GET_VALUE=endi
WIDGET_CONTROL, stash.intervalText, GET_VALUE=interval
WIDGET_CONTROL, stash.nameText, GET_VALUE=basename
logit, log, "Read series of text files: " + basename + " with angles from " + starti + " to " + endi + " with interval " + interval
startiInt = FIX(FLOAT(starti))
endiInt = FIX(FLOAT(endi))
intervalInt = FIX(FLOAT(interval))
result = read_all(basename, startiInt, endiInt, intervalInt, log)
if (result eq 1) then begin
logit, log, "Read series of text files: success"
outputname = basename + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
WIDGET_CONTROL, ev.TOP, /DESTROY
endif else begin
tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result, /ERROR)
logit, log, "Read series of text files: failed"
endelse
endif else begin
logit, log, "Read series of text files: canceled"
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
END
PRO convertonechi, base, log
common inputinfo, string
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
nameLa = WIDGET_LABEL(nameBase, VALUE='Base for name of chi files', /ALIGN_LEFT)
startiLa = WIDGET_LABEL(nameBase, VALUE='First azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Last azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Interval', /ALIGN_LEFT)
nameText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
startiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
intervalText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
stash = {log:log, nameText:nameText, intervalText:intervalText, startiText:startiText, endiText:endiText}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'convertonechi', basedialog
END
PRO convertfileseries_event, ev
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.startiText, GET_VALUE=starti
WIDGET_CONTROL, stash.endiText, GET_VALUE=endi
WIDGET_CONTROL, stash.numberDigitsText, GET_VALUE=numberDigits
WIDGET_CONTROL, stash.nameText, GET_VALUE=basename
logit, log, "Read series of chi files: " + basename + " starting from " + starti + " to " + endi
startiInt = FIX(FLOAT(starti))
endiInt = FIX(FLOAT(endi))
numberDigitsInt = FIX(FLOAT(numberDigits))
result = read_all_fixed_digits(basename, startiInt, endiInt, numberDigitsInt, log)
if (result eq 1) then begin
logit, log, "Read series of text files: success"
outputname = basename + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
WIDGET_CONTROL, ev.TOP, /DESTROY
endif else begin
tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result, /ERROR)
logit, log, "Read series of text files: failed"
endelse
endif else begin
logit, log, "Read series of text files: canceled"
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
END
PRO convertfileseries, base, log
common inputinfo, string
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
nameLa = WIDGET_LABEL(nameBase, VALUE='Base for name of files', /ALIGN_LEFT)
startiLa = WIDGET_LABEL(nameBase, VALUE='First file', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Last file', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Number of digits for files', /ALIGN_LEFT)
nameText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
startiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
numberDigitsText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
stash = {log:log, nameText:nameText, numberDigitsText:numberDigitsText, startiText:startiText, endiText:endiText}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'convertfileseries', basedialog
END
PRO convertmultiplechi_event, ev
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.startiText, GET_VALUE=starti
WIDGET_CONTROL, stash.endiText, GET_VALUE=endi
WIDGET_CONTROL, stash.intervalText, GET_VALUE=interval
WIDGET_CONTROL, stash.nameText, GET_VALUE=basename
WIDGET_CONTROL, stash.startImText, GET_VALUE=startImage
WIDGET_CONTROL, stash.endImText, GET_VALUE=endImage
WIDGET_CONTROL, stash.ndigits, GET_VALUE=ndigits
logit, log, "Read multiple series of chi files: " + basename + " from number " + startImage + " to number " + endImage + " with angles from " + starti + " to " + endi + " with interval " + interval
startiInt = FIX(FLOAT(starti))
endiInt = FIX(FLOAT(endi))
intervalInt = FIX(FLOAT(interval))
startImageInt = FIX(FLOAT(startImage[0]))
endImageInt = FIX(FLOAT(endImage[0]))
ndigitsInt = FIX(FLOAT(ndigits))
nchi = STRTRIM(STRING((endiInt-startiInt)*(endImageInt-startImageInt)/intervalInt,/PRINT), 2)
messages = nchi + " chi files to process. Please wait..."
progressBar = Obj_New("SHOWPROGRESS", message=messages)
progressBar->Start
for i=startImageInt, endImageInt do begin
fileindex = intformat(i,ndigitsInt);
chibase = strtrim(basename) + "_" + strtrim(fileindex)
logit, log, "Read series of text files: " + chibase + " with angles from " + starti + " to " + endi + " with interval " + interval
result = read_all(chibase, startiInt, endiInt, intervalInt, log)
if (result ne 1) then goto, error
outputname = basename + "_" + strtrim(fileindex) + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
result = savedata(outputname)
if (result ne 1) then goto, error
percent = 100.*(i-startImageInt)/(endImageInt-startImageInt)
progressBar->Update, percent
endfor
progressBar->Destroy
Obj_Destroy, progressBar
logit, log, "Save multiple sets of chi data files in MULTIFIT format: success"
WIDGET_CONTROL, ev.TOP, /DESTROY
return
endif else begin
logit, log, "Read series of text files: canceled"
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
error: tmp = DIALOG_MESSAGE(result, /ERROR)
progressBar->Destroy
Obj_Destroy, progressBar
logit, log, "Failed"
END
PRO convertmultiplechi, base, log
common inputinfo, string
basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
nameLa = WIDGET_LABEL(nameBase, VALUE='Base for name of images files', /ALIGN_LEFT)
startImLa = WIDGET_LABEL(nameBase, VALUE='First image file number', /ALIGN_LEFT)
endImLa = WIDGET_LABEL(nameBase, VALUE='Last image file number', /ALIGN_LEFT)
digitsImLa = WIDGET_LABEL(nameBase, VALUE='Number of digits for image files', /ALIGN_LEFT)
startiLa = WIDGET_LABEL(nameBase, VALUE='First azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Last azimuth angle', /ALIGN_LEFT)
intervalLa = WIDGET_LABEL(nameBase, VALUE='Interval for azimuths', /ALIGN_LEFT)
nameText = WIDGET_TEXT(nameBase, XSIZE=10, /EDITABLE)
startImText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endImText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
digitsImText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
startiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
endiText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
intervalText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
stash = {log:log, nameText:nameText, startImText:startImText, endImText:endImText, ndigits:digitsImText, intervalText:intervalText, startiText:startiText, endiText:endiText}
WIDGET_CONTROL, basedialog, SET_UVALUE=stash
WIDGET_CONTROL, basedialog, /REALIZE
XMANAGER, 'convertmultiplechi', basedialog
END
;PRO createmultiplefitfromdat, base, log
;common files, extension, directory, outputdirectory
;common inputinfo, string
;basedialog = WIDGET_BASE(/COLUMN, /MODAL, GROUP_LEADER=base)
;nameBase = WIDGET_BASE(basedialog,COLUMN=2, /GRID_LAYOUT, FRAME=1)
;nSpLabel = WIDGET_LABEL(nameBase, VALUE='number of subpatterns', /ALIGN_LEFT)
;nSpText = WIDGET_TEXT(nameBase, XSIZE=5, /EDITABLE)
;extButtons = WIDGET_BASE(basedialog,/ROW, /GRID_LAYOUT, /ALIGN_CENTER)
;ok = WIDGET_BUTTON(extButtons, VALUE='Ok', UVALUE='OK', xsize=80)
;cancel = WIDGET_BUTTON(extButtons, VALUE='Cancel', UVALUE='CANCEL', xsize=80)
;stash = {log:log, nSpText:nSpText}
;WIDGET_CONTROL, basedialog, SET_UVALUE=stash
;WIDGET_CONTROL, basedialog, /REALIZE
;XMANAGER, 'createmultiplefitfromdat', basedialog
;END
; ****************************************** DIOPTAS TXT CAKE FILES: FILE SERIES **************
PRO manyInputDioptasFile, widgetBase, widgetList, widgetDataDir, widgetOutputDir, log
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common inputfiles, inputfiles, activeset
common diotasfilesparameter, rebinFactor, setRebinFactor
result=dialog_pickfile(title='Select all Dioptas txt cake file...', path=datadirectory, DIALOG_PARENT=base, FILTER=['*.txt','*.*'], /must_exist, /MULTIPLE_FILES)
if (n_elements(result) gt 0) then begin
nfiles = n_elements(result)
setRebinFactor = 1 ; need to set a rebin factor at first file
for i=0, nfiles-1 do begin
FDECOMP, result[i], disk, dir, name, qual, version
filename = datadirectory + name + "." + Qual
filenameshort = name + "." + Qual
if (FILE_TEST(result[i])) then begin
logit, log, "Reading dioptas cake file from from: " + result[i]
resultread = read_dioptas_txt_cake(result[i], widgetBase, log)
if (resultread eq 1) then begin
logit, log, "Read dioptas cake file: success"
setRebinFactor = 0 ; no need to set a rebin factor for next file
if (i eq 0) then begin
; Forcing data and output directory to be where we are
datadirectory = disk + dir
inputDirLabel = 'Input directory set to: ' + datadirectory
WIDGET_CONTROL, widgetDataDir, SET_VALUE=datadirectory
logit, log, inputDirLabel
outputdirectory = disk + dir
outputDirLabel = 'Output directory set to: ' + outputdirectory
WIDGET_CONTROL, widgetOutputDir, SET_VALUE=outputdirectory
logit, log, outputDirLabel
endif
outputname = name + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
if (i eq 0) then begin ; will be used to fill the gui
inputText = strarr(nfiles)
endif
inputText(i) = outputname
endif else begin
; tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
logit, log, "Reading of dioptas cake file failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result + " not found.", /ERROR)
logit, log, "Set one dataset: failed"
endelse
endfor
; Setting a new list of files in the gui
inputfiles = inputText
WIDGET_CONTROL, widgetList, SET_VALUE=inputText
activeset = 0
WIDGET_CONTROL, widgetList, SET_LIST_SELECT=activeset
endif else begin
logit, log, "Read file in dioptas format: canceled"
endelse
END
; ****************************************** DIOPTAS TXT CAKE FILES: ONE FILE **************
; this function is not used anymore. We only the use the one above, manyInputDioptasFile, which can work with one or many files
pro oneInputDioptasFile, widgetBase, widgetList, widgetDataDir, widgetOutputDir, log
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common inputfiles, inputfiles, activeset
result=dialog_pickfile(title='Input data from Dioptas txt cake file...', path=datadirectory, DIALOG_PARENT=base, FILTER=['*.txt','*.*'], /must_exist)
if (result ne '') then begin
FDECOMP, result, disk, dir, name, qual, version
filename = datadirectory + name + "." + Qual
filenameshort = name + "." + Qual
if (FILE_TEST(result)) then begin
logit, log, "Reading dioptas cake file from from: " + result
resultread = read_dioptas_txt_cake(result, widgetBase, log)
if (resultread eq 1) then begin
logit, log, "Read dioptas cake file: success"
; Forcing data and output directory to be where we are
datadirectory = disk + dir
inputDirLabel = 'Input directory set to: ' + datadirectory
WIDGET_CONTROL, widgetDataDir, SET_VALUE=datadirectory
logit, log, inputDirLabel
outputdirectory = disk + dir
outputDirLabel = 'Output directory set to: ' + outputdirectory
WIDGET_CONTROL, widgetOutputDir, SET_VALUE=outputdirectory
logit, log, outputDirLabel
outputname = name + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
; WIDGET_CONTROL, ev.TOP, /DESTROY
inputText = strarr(1)
inputText(0) = outputname
inputfiles = inputText
WIDGET_CONTROL, widgetList, SET_VALUE=inputText
activeset = 0
WIDGET_CONTROL, widgetList, SET_LIST_SELECT=activeset
endif else begin
; tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
logit, log, "Reading of dioptas cake file failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result + " not found.", /ERROR)
logit, log, "Set one dataset: failed"
endelse
endif else begin
logit, log, "Read file in MULTIFIT format: canceled"
endelse
END
; ****************************************** DIOPTAS BATCH NXS: ONE FILE **************
; Reads HDF5 created by Batch mode in dioptas. Usually not related to stress-strain analysis, but most probably a time dependent measurement
pro inputDioptasBatchNXS, widgetBase, widgetList, widgetDataDir, widgetOutputDir, log
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common inputfiles, inputfiles, activeset
result=dialog_pickfile(title='Input data from Dioptas Batch NXS file...', path=datadirectory, DIALOG_PARENT=base, FILTER=['*.nxs','*.*'], /must_exist)
if (result ne '') then begin
FDECOMP, result, disk, dir, name, qual, version
filename = datadirectory + name + "." + Qual
filenameshort = name + "." + Qual
if (FILE_TEST(result)) then begin
logit, log, "Reading dioptas Batch NXS from from: " + result
resultread = read_dioptas_Batch_NXS(result, widgetBase, log)
if (resultread eq 1) then begin
logit, log, "Read dioptas Batch NXS: success"
; Forcing data and output directory to be where we are
datadirectory = disk + dir
inputDirLabel = 'Input directory set to: ' + datadirectory
WIDGET_CONTROL, widgetDataDir, SET_VALUE=datadirectory
logit, log, inputDirLabel
outputdirectory = disk + dir
outputDirLabel = 'Output directory set to: ' + outputdirectory
WIDGET_CONTROL, widgetOutputDir, SET_VALUE=outputdirectory
logit, log, outputDirLabel
outputname = name + ".idl"
logit, log, "Saving data in MULTIFIT format into " + outputname
res = savedata(outputname)
if (res eq 1) then begin
logit, log, "Save data in MULTIFIT format to " + outputname + ": success"
; WIDGET_CONTROL, ev.TOP, /DESTROY
inputText = strarr(1)
inputText(0) = outputname
inputfiles = inputText
WIDGET_CONTROL, widgetList, SET_VALUE=inputText
activeset = 0
WIDGET_CONTROL, widgetList, SET_LIST_SELECT=activeset
endif else begin
; tmp = DIALOG_MESSAGE(res, /ERROR)
logit, log, "Save data in MULTIFIT format: failed"
endelse
endif else begin
logit, log, "Reading of dioptas Batch NXS file failed"
endelse
endif else begin
tmp = DIALOG_MESSAGE(result + " not found.", /ERROR)
logit, log, "Set one dataset: failed"
endelse
endif else begin
logit, log, "Read file in MULTIFIT format: canceled"
endelse
END
; ****************************************** SETUP INPUT (DATA) FILES **************
pro oneInputFile, widget, log
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common inputfiles, inputfiles, activeset
result=dialog_pickfile(title='Input data from...', path=datadirectory, DIALOG_PARENT=base, FILTER=['*.idl','*.*'], /must_exist)
if (result ne '') then begin
FDECOMP, result, disk, dir, name, qual, version
filename = datadirectory + name + "." + Qual
filenameshort = name + "." + Qual
if (FILE_TEST(filename)) then begin
inputText = strarr(1)
inputText(0) = filenameshort
WIDGET_CONTROL, widget, SET_VALUE=inputText
inputfiles = inputText
logit, log, "Set one dataset: " + filename
changeActiveSet, log, widget, 0
endif else begin
tmp = DIALOG_MESSAGE(filenameshort + " is not in your data directory.", /ERROR)
logit, log, "Set one dataset: failed"
endelse
endif else begin
logit, log, "Read file in MULTIFIT format: canceled"
endelse
END
pro inpufilesFromList, log, list_widget, list
common inputfiles, inputfiles, activeset
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
n = n_elements(list)
inputText = strarr(n)
for j=0,n-1 do begin
filenameshort = list[j]
filename = datadirectory + filenameshort
if (FILE_TEST(filename) ne 1) then begin
tmp = DIALOG_MESSAGE(filenameshort + " is not in your data directory.", /ERROR)
logit, log, "Failed setting input files: failed on " + filenameshort
return
endif
inputText[j] = filenameshort
endfor
WIDGET_CONTROL, list_widget, SET_VALUE=inputText
inputfiles = inputText
logit, log, "Set multipe datasets from parameter file."
changeActiveSet, log, list_widget, 0
end
PRO multipleInputFiles_event, ev
common inputfiles, inputfiles, activeset
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
log=stash.log
error = 0
if (uval eq 'OK') then begin
WIDGET_CONTROL, stash.inputFilesBaseSt, GET_VALUE=base
WIDGET_CONTROL, stash.inputFilesFirstSt, GET_VALUE=firstS
WIDGET_CONTROL, stash.inputFilesLastSt, GET_VALUE=lastS
WIDGET_CONTROL, stash.inputFilesDigitsSt, GET_VALUE=digitsS
first = FIX(FLOAT(firstS[0]))
last = FIX(FLOAT(lastS[0]))
digits = FIX(FLOAT(digitsS[0]))
inputText = strarr(last-first+1)
n = 0
for j=first,last do begin
fileindex = intformat(j,digits);
filenameshort = strtrim(base) + "_" + fileindex + ".idl"
filename = datadirectory + filenameshort
if (FILE_TEST(filename) ne 1) then begin
logit, log, "Error: " + filenameshort + " is not in your data directory."
error = 1
endif else begin
inputText[n] = filenameshort
n = n + 1
endelse
endfor
inputText2 = inputText[0:(n-1)]
WIDGET_CONTROL, stash.widget, SET_VALUE=inputText2
inputfiles = inputText
logit, log, "Set multipe datasets: " + strtrim(base) + "_" + intformat(first,digits) + ".idl to " + strtrim(base) + "_" + intformat(last,digits) + ".idl"
changeActiveSet, log, stash.widget, 0
if (error eq 1) then tmp=DIALOG_MESSAGE("Finished loading. Some files were missing. Details in log window.", /ERROR)
WIDGET_CONTROL, ev.TOP, /DESTROY
endif else begin
logit, log, "Setting multipe input files... Cancel."
WIDGET_CONTROL, ev.TOP, /DESTROY
endelse
END
PRO multipleInputFiles, base, widget, log
common fonts, titlefont, boldfont, mainfont, avFontHeight
input = WIDGET_BASE(/COLUMN, Title='Set multipe input files', /MODAL, GROUP_LEADER=base)
inputMacLa = WIDGET_LABEL(input, VALUE='Set multipe input files', /ALIGN_CENTER, font=titlefont)