-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffIntensityWindow2.pro
More file actions
executable file
·179 lines (174 loc) · 7.55 KB
/
diffIntensityWindow2.pro
File metadata and controls
executable file
·179 lines (174 loc) · 7.55 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
; *******************************************************************
; PolydefixED stress, strain, and texture analysis for experiment in
; energy dispersive geometry
; Copyright (C) 2000-2011 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.
;
; *******************************************************************
; ***************************************************************************
; plot plotDspacVsChi function
; prepares a plot with a test of lattice strains fits
; **************************************************************************
;
; Changed 10/2011, allow plot vs. strain
; Changed 10/2011, option to normalize intensities
; if vswhat=0, plot vs. step number
; vswhat=1, plot vs. strain
pro plotIntVsImage, base, globalbase, sets, peaks, correctintensity, vswhat
common experimentwindow, set, experiment
common default, defaultdir
usePeak = WHERE(peaks, nUsePeak)
nAngles = N_ELEMENTS(sets)
angleList = experiment->getAngleList()
if ((sets[0] eq -1) or (nUsePeak eq 0)) then begin
result = DIALOG_MESSAGE( "Error: no image or no diffraction line selected!", /CENTER , DIALOG_PARENT=base, /ERROR)
return
endif
; fetching data to plot
nPattern = experiment->getnumberDatasets()
legend=strarr(nAngles*nUsePeak)
data = fltarr(nAngles*nUsePeak,nPattern)
x = intarr(nPattern)
progressBar = Obj_New("SHOWPROGRESS", message='Processing, please wait...')
progressBar->Start
if (vswhat eq 0) then begin
for i=0, nPattern-1 do x[i] = i
xlabel = 'Dataset number'
title = 'intensities vs. dataset number'
endif else begin
for i=0,nPattern-1 do x[i] = experiment->getStepStrain(i)
xlabel = 'Strain'
title = 'intensities vs. strain'
endelse
ylabel='Intensity'
for i=0, nAngles-1 do begin
for j=0, nUsePeak-1 do begin
data[i*nUsePeak+j,*] = (experiment->getIPeakVsSet(usePeak[j],sets[i],correctintensity,/used))[*]
legend[i*nUsePeak+j] = strtrim(string(angleList[sets[i]]),2)+'-'+ experiment->getPeakName(usePeak[j],/used)
percent = 100.*i/nAngles
progressBar->Update, percent
endfor
endfor
progressBar->Destroy
Obj_Destroy, progressBar
; calling the plot window
plotinteractive1D, base, x, data, title=title, xlabel=xlabel, ylabel=ylabel, legend=legend
end
; Changed 10/2011, option to normalize intensities
pro exportIntVsImageCSV, base, sets, peaks, correctintensity
common experimentwindow, set, experiment
common default, defaultdir
result=dialog_pickfile(title='Save results as', path=defaultdir, DIALOG_PARENT=base, DEFAULT_EXTENSION='.csv', FILTER=['*.csv'], /WRITE, get_path = newdefaultdir)
if (result ne '') then begin
defaultdir = newdefaultdir
if (FILE_TEST(result) eq 1) then begin
tmp = DIALOG_MESSAGE("File exists. Overwrite?", /QUESTION)
if (tmp eq 'No') then return
endif
progressBar = Obj_New("SHOWPROGRESS", message='Calculating, please wait...')
progressBar->Start
usePeak = WHERE(peaks, nUsePeak)
nAngles = N_ELEMENTS(sets)
nPattern = experiment->getnumberDatasets()
angleList = experiment->getAngleList()
data = fltarr(nAngles*nUsePeak,nPattern)
legend=strarr(nAngles*nUsePeak)
for i=0, nAngles-1 do begin
for j=0, nUsePeak-1 do begin
data[i*nUsePeak+j,*] = (experiment->getIPeakVsSet(usePeak[j],sets[i], correctintensity,/used))[*]
legend[i*nUsePeak+j] = strtrim(string(angleList[sets[i]]),2)+'-'+ experiment->getPeakName(usePeak[j],/used)
endfor
endfor
openw, lun, result, /get_lun
printf, lun, "# Intensities as a function of image number for one peak and one orientation"
line = "# image name, strain, intensity for (angle-peak)"
for i=0, nAngles*nUsePeak-1 do line += " " + legend[i]
printf, lun, line
for step=0,nPattern-1 do begin
printf, lun, experiment->getDatasetName(step), STRING(9B), experiment->getStepStrain(step), STRING(9B), fltformatD(data[*,step])
endfor
free_lun, lun
progressBar->Destroy
Obj_Destroy, progressBar
endif
end
; *********************************************************************** Interface ****************
pro diffIntensityWindow2_event, ev
; Get the 'stash' structure.
WIDGET_CONTROL, ev.TOP, GET_UVALUE=stash
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
sets = WIDGET_INFO(stash.listSets, /LIST_SELECT)
WIDGET_CONTROL, stash.plotwhatPeak, GET_VALUE=peaks
CASE ev.id OF
stash.input:
else: begin
WIDGET_CONTROL, stash.plotwhat, GET_VALUE=correctintensity ;Caro 07/01/11
WIDGET_CONTROL, stash.plotvswhat, GET_VALUE=vswhat ;Caro 20/01/11
CASE uval OF
'PLOT': plotIntVsImage, stash.input, stash.base, sets, peaks, correctintensity, vswhat
'DONE': WIDGET_CONTROL, stash.input, /DESTROY
'ASCII': exportIntVsImageCSV, stash.input, sets, peaks, correctintensity
else:
ENDCASE
endcase
endcase
end
; Changed 10/2011, allow plot vs. strain
; Changed 10/2011, option to normalize intensities
pro diffIntensityWindow2, base
common experimentwindow, set, experiment
common fonts, titlefont, boldfont, mainfont
; check if experiment material properties are set
if (set eq 0) then begin
result = DIALOG_MESSAGE( "Error: you have to input some data first!", /CENTER , DIALOG_PARENT=base, /ERROR)
return
endif
if (experiment->materialset() eq 0) then begin
result = DIALOG_MESSAGE( "Error: you have to set some material properties first!", /CENTER , DIALOG_PARENT=base, /ERROR)
return
endif
; base GUI
input = WIDGET_BASE(Title='Intensities vs image numbers', /COLUMN, GROUP_LEADER=base)
inputLa = WIDGET_LABEL(input, VALUE='Intensities vs image numbers', /ALIGN_CENTER, FONT=titlefont)
fit = WIDGET_BASE(input, /ROW, FRAME=0)
; listing datasets
alist = WIDGET_BASE(fit,/COLUMN, /ALIGN_CENTER, FRAME=1,XSIZE=200, YSIZE=400)
anglelist = experiment->getAngleList()
anglelistStr = STRING(anglelist)
listLa = WIDGET_LABEL(alist, VALUE='Datasets', /ALIGN_CENTER)
listSets = Widget_List(alist, VALUE=anglelistStr, UVALUE='NOTHING', /MULTIPLE, SCR_XSIZE=190, SCR_YSIZE=360)
; Options
right = WIDGET_BASE(fit,/COLUMN, /ALIGN_CENTER, FRAME=1, YSIZE=400)
; peak list
values = experiment->getPeakList(/used)
plotwhatPeak = CW_BGROUP(right, values, /COLUMN, /NONEXCLUSIVE, LABEL_TOP='hkl', UVALUE='NOTHING', /SCROLL, Y_SCROLL_SIZE=320, SET_VALUE=0)
; Options
buttons2 = WIDGET_BASE(input,/ROW, /ALIGN_CENTER, /GRID_LAYOUT)
values = ['Plot raw intensity', 'Plot corrected intensity']
plotwhat = CW_BGROUP(buttons2, values, /COLUMN, /EXCLUSIVE, UVALUE='NOTHING', SET_VALUE=0)
values2 = ['Plot vs. step', 'Plot vs. strain'] ;Caro 20/01/11
plotvswhat = CW_BGROUP(buttons2, values2, /COLUMN, /EXCLUSIVE, UVALUE='NOTHING', SET_VALUE=0) ;Caro 20/01/11
; buttons2
buttons2 = WIDGET_BASE(input,/ROW, /ALIGN_CENTER, /GRID_LAYOUT)
plot1 = WIDGET_BUTTON(buttons2, VALUE='Plot', UVALUE='PLOT')
close = WIDGET_BUTTON(buttons2, VALUE='Close window', UVALUE='DONE')
export = WIDGET_BUTTON(buttons2, VALUE='Export to ASCII', UVALUE='ASCII')
stash = {base: base, input: input, plotwhatPeak:plotwhatPeak, listSets:listSets, plotwhat:plotwhat, plotvswhat:plotvswhat}
WIDGET_CONTROL, input, SET_UVALUE=stash
WIDGET_CONTROL, input, /REALIZE
XMANAGER, 'diffIntensityWindow2', input
end