Blame view

src/idl/dustemwrap_plot.pro 55.5 KB
392ede91   Jean-Philippe Bernard   included an help ...
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
PRO dustemwrap_plot,p_dim,st, $
                    dustem_sed,SED_spec, $
                    dustem_qsed,Q_spec, $
                    dustem_used,U_spec, $
                    dustem_polsed,P_spec, $
                    dustem_polfrac,SP_spec, $
                    dustem_psi_em,PSI_spec, $
                    dustem_ext,EXT_spec, $
                    dustem_qext,QEXT_spec, $
                    dustem_uext,UEXT_spec, $
                    dustem_polext,POLEXT_spec, $
                    dustem_fpolext,SPEXT_spec, $
                    dustem_psi_ext,PSIEXT_spec, $
                    _extra=_extra,help=help

;+
; NAME:
;    dustemwrap_plot
; PURPOSE:
;    plots dustemwrap observed sed, predicted sed, predicted spectra for total Intensity, polarization in emission and extinction
; CATEGORY:
;    DustEMWrap
; CALLING SEQUENCE:
;    dustemwrap_plot,p_dim,st,dustem_sed,SED_spec,dustem_qsed,Q_spec,dustem_used,U_spec,dustem_polsed,P_spec,dustem_polfrac,SP_spec,dustem_psi_em,PSI_spec,dustem_ext,EXT_spec,dustem_qext,QEXT_spec,dustem_uext,UEXT_spec,dustem_polext,POLEXT_spec,dustem_fpolext,SPEXT_spec,dustem_psi_ext,PSIEXT_spec,_extra=_extra 
; INPUTS:
;    p_dim
; OPTIONAL INPUT PARAMETERS:
;    st
;    dustem_sed
;    dustem_qsed
;    dustem_used
;    dustem_polsed
;    dustem_polfrac
;    dustem_psi_em
;    dustem_ext
;    dustem_qext
;    dustem_uext
;    dustem_polext
;    dustem_fpolext
;    dustem_psi_ext
; OUTPUTS:
;    dustem_sed
;    dustem_qsed
;    dustem_used
;    dustem_polsed
;    dustem_polfrac
;    dustem_psi_em
;    dustem_ext
;    dustem_qext
;    dustem_uext
;    dustem_polext
;    dustem_fpolext
;    dustem_psi_ext
;    SED_spec
;    Q_spec
;    U_spec
;    P_spec
;    SP_spec
;    PSI_spec
;    EXT_spec
;    QEXT_spec
;    UEXT_spec
;    POLEXT_spec
;    SPEXT_spec
;    PSIEXT_spec
; OPTIONAL OUTPUT PARAMETERS:
;    
392ede91   Jean-Philippe Bernard   included an help ...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
; ACCEPTED KEY-WORDS:
;    help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    Does a plot
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by Ilyes Choubani
;    Evolution details on the DustEMWrap gitlab.
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustemwrap_plot'
  goto,the_end
END
67bd858a   Ilyes Choubani   Replication of th...
90

40597848   Ilyes Choubani   Plotting of numbe...
91
;This is also necessary for the plotting of the results of the fit (Last iteration) 
2910e8ce   Ilyes Choubani   Draft version of ...
92
93
IF not keyword_set(st) THEN BEGIN
  ;Activation of the plugins is needed because of the plotting of the total emission model that includes them. 
07372e26   Ilyes Choubani   Corrected huge pl...
94
  dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values),st  ; 0/0 division case?
fcb6eade   Ilyes Choubani   general update - ...
95
  
dc1d037e   Ilyes Choubani   Small fixes to st...
96
  ;# Emission
afde94a3   Ilyes Choubani   general update
97
  ;if isa(!dustem_data.sed) then begin ;using !dustem_data instead of !dustem_show because in this release the user is compelled to fit IQU whether in M or X
0068116a   Ilyes Choubani   General update + ...
98
  if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin ;better test?
afde94a3   Ilyes Choubani   general update
99
  
dc1d037e   Ilyes Choubani   Small fixes to st...
100
      dustem_sed = dustem_compute_sed(p_dim,st,SED_spec)
fcb6eade   Ilyes Choubani   general update - ...
101
      
dc1d037e   Ilyes Choubani   Small fixes to st...
102
103
104
105
      if !run_pol && !run_lin then begin
          
          dustem_polsed = dustem_compute_polsed(p_dim,st,P_spec,SP_spec,dustem_polfrac)
          toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec,PSI_spec,dustem_psi_em) 
5cb00808   Jean-Philippe Bernard   added some commen...
106
          ;stop
dc1d037e   Ilyes Choubani   Small fixes to st...
107
          
07372e26   Ilyes Choubani   Corrected huge pl...
108
      endif         
dc1d037e   Ilyes Choubani   Small fixes to st...
109
110
111
  endif
  
  ;# Extinction
afde94a3   Ilyes Choubani   general update
112
;   if isa(!dustem_data.ext) then begin
0068116a   Ilyes Choubani   General update + ...
113
  if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin
dc1d037e   Ilyes Choubani   Small fixes to st...
114
      dustem_ext = dustem_compute_ext(p_dim,st,EXT_spec)
fcb6eade   Ilyes Choubani   general update - ...
115
      
dc1d037e   Ilyes Choubani   Small fixes to st...
116
117
118
119
120
121
122
123
      if !run_pol && !run_lin then begin
          
          dustem_polext = dustem_compute_polext(p_dim,st,POLEXT_spec,SPEXT_spec,dustem_fpolext)
          toto = dustem_compute_stokext(p_dim,st,dustem_qext,dustem_uext,QEXT_spec,UEXT_spec,PSIEXT_spec,dustem_psi_ext) 
          
      endif
  endif
  
40597848   Ilyes Choubani   Plotting of numbe...
124
ENDIF ELSE BEGIN ;st is provided 
5cb00808   Jean-Philippe Bernard   added some commen...
125
126
    ;stop

dc1d037e   Ilyes Choubani   Small fixes to st...
127
    ;# Emission
afde94a3   Ilyes Choubani   general update
128
    ;if isa(!dustem_data.sed) then begin
0068116a   Ilyes Choubani   General update + ...
129
    if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin
40597848   Ilyes Choubani   Plotting of numbe...
130
        dustem_sed = dustem_compute_sed(p_dim,st,SED_spec)
40597848   Ilyes Choubani   Plotting of numbe...
131
        
dc1d037e   Ilyes Choubani   Small fixes to st...
132
133
134
135
        if !run_pol && !run_lin then begin
            
            dustem_polsed = dustem_compute_polsed(p_dim,st,P_spec,SP_spec,dustem_polfrac)
            toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec,PSI_spec,dustem_psi_em) 
5cb00808   Jean-Philippe Bernard   added some commen...
136
            ;stop    
dc1d037e   Ilyes Choubani   Small fixes to st...
137
138
139
140
        endif
    endif
    
    ;# Extinction
afde94a3   Ilyes Choubani   general update
141
142
    ;if isa(!dustem_data.ext) then begin
    
0068116a   Ilyes Choubani   General update + ...
143
    if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin
afde94a3   Ilyes Choubani   general update
144
    
dc1d037e   Ilyes Choubani   Small fixes to st...
145
        dustem_ext = dustem_compute_ext(p_dim,st,EXT_spec)
40597848   Ilyes Choubani   Plotting of numbe...
146
        
dc1d037e   Ilyes Choubani   Small fixes to st...
147
148
149
150
        if !run_pol && !run_lin then begin
            
            dustem_polext = dustem_compute_polext(p_dim,st,POLEXT_spec,SPEXT_spec,dustem_fpolext)
            toto = dustem_compute_stokext(p_dim,st,dustem_qext,dustem_uext,QEXT_spec,UEXT_spec,PSIEXT_spec,dustem_psi_ext) 
40597848   Ilyes Choubani   Plotting of numbe...
151
            
dc1d037e   Ilyes Choubani   Small fixes to st...
152
        endif
40597848   Ilyes Choubani   Plotting of numbe...
153
    endif
dc1d037e   Ilyes Choubani   Small fixes to st...
154
    
40597848   Ilyes Choubani   Plotting of numbe...
155
ENDELSE 
dfc68a85   Ilyes Choubani   Fixed some plotti...
156

1b0519fd   Jean-Philippe Bernard   added a mouchard
157

bffa7018   Ilyes Choubani   update
158
;IC: Will come back for this to include all datasets and their associated data.
1b0519fd   Jean-Philippe Bernard   added a mouchard
159

7704bf8d   Jean-Philippe Bernard   fixed for new for...
160
161
162
dd=(*(*!dustem_data).sed).values
ss=(*(*!dustem_data).sed).sigma
recomputed_chi2_sed   = total((dd-dustem_sed)^2/ss^2)
3b1e2e39   Jean-Philippe Bernard   replaced V2.0 by ...
163
164
dof= n_elements((*(*!dustem_data).sed).values) - n_elements(*(*!dustem_fit).PARAM_DESCS)
recomputed_rchi2_sed  = recomputed_chi2_sed / dof
1b0519fd   Jean-Philippe Bernard   added a mouchard
165

9eb53891   Jean-Philippe Bernard   modified call to ...
166
;print,'recomputed chi^2:',!dustem_iter.act,recomputed_rchi2_sed,recomputed_chi2_sed
1b0519fd   Jean-Philippe Bernard   added a mouchard
167
168
169
170
171
mouchard=*!iteration_mouchard
new_mouchard=mouchard[0]
new_mouchard.iteration=!dustem_iter.act
new_mouchard.chi2=(*!dustem_fit).chi2
new_mouchard.rchi2=(*!dustem_fit).rchi2
392ede91   Jean-Philippe Bernard   included an help ...
172
173
174
;new_mouchard.recomputed_chi2=recomputed_chi2_sed
;new_mouchard.recomputed_rchi2=recomputed_rchi2_sed

bffa7018   Ilyes Choubani   update
175
176
177
178
179

;IC: I've commented this test below but it was uncommented. I don't understand its function. 
;Current parameter values including plugins have been available at each iteration prior to commenting this.
;Leaving as is.

392ede91   Jean-Philippe Bernard   included an help ...
180
181
;JPB: need here to store values of current parameter values (including plugins) into !iteration_mouchard
help,(*!dustem_fit).CURRENT_PARAM_VALUES   ;This is not currently filled up ...
bffa7018   Ilyes Choubani   update
182

392ede91   Jean-Philippe Bernard   included an help ...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;Below will work only for non plugin parameters
goto,skip1
param_descs=*(*!dustem_fit).param_descs
params_current=[0.D0]
FOR i=0L,n_elements(param_descs)-1 DO BEGIN
    str='params_current=[params_current,'+param_descs[i]+']'
    print,str
    toto=execute(str)
ENDFOR
params_current=params_current[1:*]
print,params_current

stop
skip1:
bffa7018   Ilyes Choubani   update
197
 
1b0519fd   Jean-Philippe Bernard   added a mouchard
198
199
200
mouchard=[mouchard,new_mouchard]
!iteration_mouchard=ptr_new(mouchard)

2910e8ce   Ilyes Choubani   Draft version of ...
201
202
203

;LIST OF TESTS THAT NEED TO BE RAN SO THAT THE PLOTTING OF THE MODEL SPECTRA OCCURS

0068116a   Ilyes Choubani   General update + ...
204
205
test_sed = isa((*!dustem_show).sed)
test_ext = isa((*!dustem_show).ext)
b5314324   Ilyes Choubani   updating the plot...
206
if !run_pol then begin
0068116a   Ilyes Choubani   General update + ...
207
208
209
210
211
212
213
214
215
216
    test_polext = isa((*!dustem_show).polext)
    test_polsed = isa((*!dustem_show).polsed)
    test_polfrac = isa((*!dustem_show).polfrac)
    test_fpolext = isa((*!dustem_show).fpolext)
    test_psi_em = isa((*!dustem_show).psi_em)
    test_psi_ext = isa((*!dustem_show).psi_ext)
    test_qsed = isa((*!dustem_show).qsed)
    test_used = isa((*!dustem_show).used)
    test_qext = isa((*!dustem_show).qext)
    test_uext = isa((*!dustem_show).uext)
b5314324   Ilyes Choubani   updating the plot...
217
    test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em
67bd858a   Ilyes Choubani   Replication of th...
218
    test_x = test_ext or test_polext or test_fpolext or test_qext or test_uext or test_psi_ext
b5314324   Ilyes Choubani   updating the plot...
219
220
221
222
endif else begin
    test_m = test_sed 
    test_x = test_ext 
endelse
18e4331f   Ilyes Choubani   general update (f...
223

2910e8ce   Ilyes Choubani   Draft version of ...
224
;testing on the fitting of emission vs extinction data
2910e8ce   Ilyes Choubani   Draft version of ...
225

b5314324   Ilyes Choubani   updating the plot...
226
n_plgns = n_tags(*!dustem_plugin)
2910e8ce   Ilyes Choubani   Draft version of ...
227

5f04fa07   Ilyes Choubani   general update
228
229
230
231
frmt0='(A36)'
frmt1='(1E10.2)'
frmt2='(10F10.2)'

bffa7018   Ilyes Choubani   update
232
233
dustem_set_plot_range,test_sed, test_ext,_extra= _extra

2910e8ce   Ilyes Choubani   Draft version of ...
234
235
236
;I have decided to keep track of the command index manually as I did not find any command online that does this.
cmdind_m = 0 ;for emission
cmdind_x = 0 ;for extinction
5f04fa07   Ilyes Choubani   general update
237
238
239
;trying to do the same thing for parameters and plugins
cmdind_prms = 0 ;for parameters
cmdind_plgns = 0 ;for plugins
2910e8ce   Ilyes Choubani   Draft version of ...
240

2910e8ce   Ilyes Choubani   Draft version of ...
241
;ADDING PLUGIN(S) TO SPECTRUM----------------
2910e8ce   Ilyes Choubani   Draft version of ...
242
243
244
245

;these following indices will be used to change the keep the same information in the _extra structure
;this is an initial solution until I finish coding the _extra-filtering procedure. 

2910e8ce   Ilyes Choubani   Draft version of ...
246
247
248
iswinsed = !dustemcgwin_id.sed EQ la_undef()
iswinext = !dustemcgwin_id.ext EQ la_undef()

5f04fa07   Ilyes Choubani   general update
249
250
251
252
253
254
255
;trying to do the same thing for parameters and plugins
;But we need to know if the extinction or the emission mode is on.
;so the use of ths pointer will be different than the others
iswinprms = !dustemcgwin_id.prms EQ la_undef()
iswinplgns = !dustemcgwin_id.plgns EQ la_undef()


18e4331f   Ilyes Choubani   general update (f...
256
257
258
;plotstrct = !p
degtorad = !pi/180 ;factor that the arctan will be devided by in order to have an axis in degrees. Talk to JP maybe he wants angle in radians.

5f04fa07   Ilyes Choubani   general update
259
260
261
262
;I think I will test over the presence of the errors because they are not computed at that point.

;errors = ((*!dustem_fit).current_param_errors)
if isa((*!dustem_fit).current_param_errors) then begin
fcb6eade   Ilyes Choubani   general update - ...
263
    errors = (*(*!dustem_fit).current_param_errors) * (*(*!dustem_fit).param_init_values)
5f04fa07   Ilyes Choubani   general update
264
endif else begin
dfc68a85   Ilyes Choubani   Fixed some plotti...
265
    errors = (*(*!dustem_fit).param_init_values)*0.;+la_undef();Initialized to 0 instead of la_undef() 
5f04fa07   Ilyes Choubani   general update
266
267
268
269
270
271
272
273
274
275
276
277
278
279
ENDELSE 

if isa((*!dustem_fit).chi2) then begin
    chi2 = (*!dustem_fit).chi2    
endif else begin
    chi2 = la_undef();maybe not the best initialization 
endelse 

if isa((*!dustem_fit).rchi2) then begin
    rchi2 = (*!dustem_fit).rchi2    
endif else begin
    rchi2 = la_undef();maybe not the best initialization 
endelse 

707e83c5   Ilyes Choubani   updating dustewra...
280

fcb6eade   Ilyes Choubani   general update - ...
281
if isa(p_dim) then begin
dfc68a85   Ilyes Choubani   Fixed some plotti...
282
283
284
285
286
287
288
289
290
291
    
    if isa((*!dustem_fit).current_param_values) then begin
        
        res  = (*(*!dustem_fit).current_param_values) 
        
    endif else begin  
    
        res = p_dim    
    
    endelse
fcb6eade   Ilyes Choubani   general update - ...
292
293
endif else begin
    
dfc68a85   Ilyes Choubani   Fixed some plotti...
294
   res = (*(*!dustem_fit).param_init_values)*0.;+la_undef()
fcb6eade   Ilyes Choubani   general update - ...
295
296
    
endelse
5cb00808   Jean-Philippe Bernard   added some commen...
297
;stop
dba085c0   Jean-Philippe Bernard   fixed windows pos...
298

1b0519fd   Jean-Philippe Bernard   added a mouchard
299
;==== These are arameters for window positioning
dba085c0   Jean-Philippe Bernard   fixed windows pos...
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
if !run_pol then BEGIN
    wdelta_x=60
    main_wxsize=910
    main_wysize=658

    param_wxpos=main_wxsize+wdelta_x
    param_wypos=15
    param_wxsize=350
    param_wysize=200

    plugin_wxpos=main_wxsize+wdelta_x
    plugin_wypos=300
    plugin_wxsize=350
    plugin_wysize=200
ENDIF ELSE BEGIN
    wdelta_x=60
    main_wxsize=640  ;default of cgwindow
    main_wysize=512  ;default of cgwindow

    param_wxpos=main_wxsize+wdelta_x;700
    param_wypos=15
    param_wxsize=350
    param_wysize=200

    plugin_wxpos=main_wxsize+wdelta_x;700
    plugin_wypos=300
    plugin_wxsize=350
    plugin_wysize=200
ENDELSE

2910e8ce   Ilyes Choubani   Draft version of ...
330
if test_m then begin
2910e8ce   Ilyes Choubani   Draft version of ...
331
332
    ;Generating emission window and saving window ID
    
5cb00808   Jean-Philippe Bernard   added some commen...
333
    if iswinsed then begin    ;This is when the cgwindow does not exist already
dfc68a85   Ilyes Choubani   Fixed some plotti...
334
        
3b1e2e39   Jean-Philippe Bernard   replaced V2.0 by ...
335
        if !run_pol then cgwindow,wxsize=main_wxsize,wysize=main_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)' else cgwindow,wxsize=main_wxsize,wysize=main_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)';, wback='grey';,wobject=winobj_m
2910e8ce   Ilyes Choubani   Draft version of ...
336
337
338
        winid_m = cgquery(dimensions=dim_m,/current) ;this has to be changed because the dimensions of this array change with the data sets present (extinction/emission).
        !dustemcgwin_id.sed = winid_m
        
5f04fa07   Ilyes Choubani   general update
339
340
341
342
343
344
        cgcontrol, winid_m, execute=0
        ;cgset, winid_m
        ;Plotting model string (legend)
        xxpos = 0.015
        yypos = 0.97
        ;Plotting Hydrogen column density string (legend)
abebbdf3   Ilyes Choubani   General update: A...
345
        cgtext, xxpos, yypos,'Model : '+!dustem_model,color=0,/normal,charsize = 1.2,/addcmd ;& cmdind_m+=1 This is the first command in the window
5f04fa07   Ilyes Choubani   general update
346
        yypos = 0.95
abebbdf3   Ilyes Choubani   General update: A...
347
        cgtext, xxpos, yypos,textoidl('N_{H}')+textoidl(' (H/cm^2) : ')+strmid(string(*!dustem_HCD,format='(1E10.2)'),2),color=0,/normal,charsize = 1.2,/addcmd & cmdind_m+=1
5f04fa07   Ilyes Choubani   general update
348
        
40597848   Ilyes Choubani   Plotting of numbe...
349
350
351
352
353
        ;Plotting of the number of iterations completed by the fitter
        
        ;Plotting of the number of runs
        ;Getting the width of the unrefreshed string
        widthtot=0.
5cb00808   Jean-Philippe Bernard   added some commen...
354
355
        ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
40597848   Ilyes Choubani   Plotting of numbe...
356
357
358
359
360
361
362
363
364
365
366
367
368
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        !dustemcgwin_ncmds.runs.txtwdth = thiswidth
        
        ;Getting the width of the refreshed string
        cgtext, xxpos, yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtot+= thiswidth;varying width        
        
        ;These two lines will also have to      be modified when plotting the refreshed values
        xxpos = 0.015 ;1.0 - widthtot - 0.03
        yypos = 0.015
        
        ;Displaying fixed part
5cb00808   Jean-Philippe Bernard   added some commen...
369
370
        ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
        cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
40597848   Ilyes Choubani   Plotting of numbe...
371
372
373
374
375
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
        ;saving the command id to replace it
        !dustemcgwin_ncmds.runs.pl = cmdind_m

5f04fa07   Ilyes Choubani   general update
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
        ;plotting of (mostly) fixed data for rchi2
        ;Since the format of the strings is specified, the length/width of the string in thex direction is fixed. 
        
        
        ;Getting the width of the unrefreshed string
        widthtot=0.
        cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        
        ;Getting the width of the refresh.ed string
        cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtot+= thiswidth;varying width        
        ;saving the command string width to replace it
        !dustemcgwin_ncmds.chi2.txtwdth = thiswidth
        
        
abebbdf3   Ilyes Choubani   General update: A...
393
        xxpos = 1.0 - widthtot - 0.03
5f04fa07   Ilyes Choubani   general update
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
        
        yypos = 0.97
        
        ;Displaying fixed part
        cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        
        cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
       
        ;saving the command id to replace it
        !dustemcgwin_ncmds.chi2.pl = cmdind_m
 
        
        
        ;plotting of (mostly) fixed data for rchi2
        
        ;Getting the width of the unrefreshed string
        widthtot=0.
        cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        ;!dustemcgwin_ncmds.rchi2.txtwdth1 = thiswidth
        ;Getting the width of the refreshed string
        cgtext, xxpos, yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtot+= thiswidth;varying width        
        !dustemcgwin_ncmds.rchi2.txtwdth = thiswidth
        ;These two lines will also have to      be modified when plotting the refreshed values
abebbdf3   Ilyes Choubani   General update: A...
421
        xxpos = 1.0 - widthtot - 0.03
5f04fa07   Ilyes Choubani   general update
422
423
424
425
426
427
428
429
430
431
        yypos = 0.95
        
        ;Displaying fixed part
        cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_m+=1
        ;saving the command id to replace it
        !dustemcgwin_ncmds.rchi2.pl = cmdind_m
        
        
5f04fa07   Ilyes Choubani   general update
432
433
        ;Plotting of the title of the dashboard (plot(s))
        
fdc0dcfe   Ilyes Choubani   adding forgotten ...
434
435
        
        ;NB issue here because the user can't modify the title after the dustem_mpfit_data call at the main procedure level (user proc)
5f04fa07   Ilyes Choubani   general update
436
        ;Getting the width of the title 
dfc68a85   Ilyes Choubani   Fixed some plotti...
437
438
439
440
        tit=string(_extra.title);
    
        cgtext, 0.3, 0.95,tit+' (RUNNING)',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1
        widthtot = thiswidth
5f04fa07   Ilyes Choubani   general update
441
442
        xxpos = (1 - thiswidth)/2
        yypos = 0.96
dfc68a85   Ilyes Choubani   Fixed some plotti...
443
444
445
446
        
        cgtext, 0.3, 0.95,tit,color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_m+=1 
        !dustemcgwin_ncmds.pltit.txtwdth = thiswidth*1.6 + (1 - widthtot)/2
         
5f04fa07   Ilyes Choubani   general update
447
        cgtext, xxpos, yypos,tit,color=0,/normal,charsize = 1.6,/addcmd & cmdind_m+=1
dfc68a85   Ilyes Choubani   Fixed some plotti...
448
449
        xxpos+=thiswidth*1.6
        cgtext, xxpos, yypos,' (RUNNING)',color=0,/normal,charsize = 1.6,/addcmd & cmdind_m+=1
5f04fa07   Ilyes Choubani   general update
450
451
452
        
        !dustemcgwin_ncmds.pltit.pl = cmdind_m
        
5cb00808   Jean-Philippe Bernard   added some commen...
453
    endif else begin     ;This is when the cgwindow exists already
2910e8ce   Ilyes Choubani   Draft version of ...
454
    
5f04fa07   Ilyes Choubani   general update
455
456
457
458
459
460
461
        
        winid_m = !dustemcgwin_id.sed
        cgcontrol, winid_m, execute=0
        cgset, winid_m ;apparently specifying the window index isn't enough. This might be because of the use of cgcontrol
        
        ;Refreshing chi2 data: 
        cmdin_m = !dustemcgwin_ncmds.chi2.pl
abebbdf3   Ilyes Choubani   General update: A...
462
        xxpos = 1 - !dustemcgwin_ncmds.chi2.txtwdth - 0.03  
5f04fa07   Ilyes Choubani   general update
463
464
465
466
467
468
469
        yypos = 0.97
        cgwindow,'cgtext', xxpos , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1
        
        
        
        ;Refreshing rchi2 data: 
        cmdin_m = !dustemcgwin_ncmds.rchi2.pl
abebbdf3   Ilyes Choubani   General update: A...
470
        xxpos = 1 - !dustemcgwin_ncmds.rchi2.txtwdth - 0.03  
5f04fa07   Ilyes Choubani   general update
471
472
        yypos = 0.95
        cgwindow,'cgtext', xxpos , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1
40597848   Ilyes Choubani   Plotting of numbe...
473
474
475
476
477
478
        
        
        ;Refreshing number of runs data: 
        cmdin_m = !dustemcgwin_ncmds.runs.pl
        xxpos = 0.03 + !dustemcgwin_ncmds.runs.txtwdth*1.35  ;(because of charsize)
        yypos = 0.015
afde94a3   Ilyes Choubani   general update
479
480
        if !dustem_iter.act eq 0 then txt = 'Fit failed. '  else txt = strtrim(!dustem_iter.act,2)
        cgwindow,'cgtext', xxpos , yypos,txt,color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1
40597848   Ilyes Choubani   Plotting of numbe...
481
        
dfc68a85   Ilyes Choubani   Fixed some plotti...
482
483
484
         
        ;update of the title here ?
        
bffa7018   Ilyes Choubani   update
485
        if !dustem_end EQ 1 then begin
dfc68a85   Ilyes Choubani   Fixed some plotti...
486
            ;replacing my count - 3
bffa7018   Ilyes Choubani   update
487
            tit=!dustem_plot_range.title_m
dfc68a85   Ilyes Choubani   Fixed some plotti...
488
489
490
491
492
493
494
495
496
            cmdin_m = !dustemcgwin_ncmds.pltit.pl
            
            xxpos = !dustemcgwin_ncmds.pltit.txtwdth
            yypos = 0.96
        
            cgwindow,'cgtext', xxpos , yypos,' (Final Run)',color=0,/normal,charsize = 1.6,/replacecmd,cmdindex=cmdin_m, winid=winid_m  
        
        endif
    
5f04fa07   Ilyes Choubani   general update
497
    endelse
2910e8ce   Ilyes Choubani   Draft version of ...
498
499
500
501
    
    ;cgWindow_GetDefs,xsize=xsize,ysize=ysize
    ;cgcontrol, resize=[xsize,ysize]
    if !run_pol then begin
c8368c6e   Ilyes Choubani   updating plotting...
502
        ;,wback='grey'
2910e8ce   Ilyes Choubani   Draft version of ...
503
504
        
        ;position arrays for plot and normalized graph
af5bca1f   Ilyes Choubani   general update
505
        
af5bca1f   Ilyes Choubani   general update
506
        ;THIS IS HARD-CODED IN A VERY SILLY WAY
2910e8ce   Ilyes Choubani   Draft version of ...
507
508
509
        
        p_sed = [0.05,0.67,0.475,0.90]
        p_psed = [0.525,0.67,0.95,0.90]
af5bca1f   Ilyes Choubani   general update
510
        p_spsed = [0.05,0.375,0.475,0.575]
18e4331f   Ilyes Choubani   general update (f...
511
        p_psised = [0.525,0.375,0.95,0.575]
5f04fa07   Ilyes Choubani   general update
512
        p_qsed = [0.05,0.12,0.475,0.35]  
18e4331f   Ilyes Choubani   general update (f...
513
514
        p_used = [0.525,0.12,0.95,0.35]
        
2910e8ce   Ilyes Choubani   Draft version of ...
515
        np_sed = [0.05,0.60,0.475,0.67]
18e4331f   Ilyes Choubani   general update (f...
516
517
518
        np_psed = [0.525,0.60,0.95,0.67]
        np_qsed = [0.05,0.05,0.475,0.12] 
        np_used = [0.525,0.05,0.95,0.12]
af5bca1f   Ilyes Choubani   general update
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
        
        p_sed[1]+= 0.0125 & p_sed[3]+= 0.0125 
        p_psed[1]+= 0.0125 & p_psed[3]+= 0.0125
        p_spsed[1]+= 0.0125 & p_spsed[3]+= 0.0125
        p_psised[1]+= 0.0125 & p_psised[3]+= 0.0125
        p_qsed[1]+= 0.0125 & p_qsed[3]+= 0.0125
        p_used[1]+= 0.0125 & p_used[3]+= 0.0125
        
        np_sed[1]+= 0.0125 & np_sed[3]+= 0.0125 
        np_psed[1]+= 0.0125 & np_psed[3]+= 0.0125
        np_qsed[1]+= 0.0125 & np_qsed[3]+= 0.0125
        np_used[1]+= 0.0125 & np_used[3]+= 0.0125
        
        
          
2910e8ce   Ilyes Choubani   Draft version of ...
534
535
536
    endif else begin
        p_sed  = [0.07,0.30,0.97,0.85]
        np_sed = [0.07,0.10,0.97,0.30]
c8368c6e   Ilyes Choubani   updating plotting...
537
    
2910e8ce   Ilyes Choubani   Draft version of ...
538
539
540
541
    endelse

    ;Plotting of sed data axes (whether or not data is present)
    plotsym,0,/fill ;you might need to execute this again. hmm...
5f04fa07   Ilyes Choubani   general update
542
543


bc224f3e   Ilyes Choubani   Update of plottin...
544
    ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
2910e8ce   Ilyes Choubani   Draft version of ...
545
546
    if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
        
bffa7018   Ilyes Choubani   update
547
548
        cgwindow,'dustem_plot_dataset', st, dataset='SED', /nodata, position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
        cgwindow,'dustem_plot_dataset', st, dataset='SED', /nodata, /norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
2910e8ce   Ilyes Choubani   Draft version of ...
549

2910e8ce   Ilyes Choubani   Draft version of ...
550
    endif else begin ;SED exists
18e4331f   Ilyes Choubani   general update (f...
551
552

       if  ~iswinsed then begin
5f04fa07   Ilyes Choubani   general update
553
       
96a72c8b   Ilyes Choubani   seperating xrange...
554
            cmdind_m = !dustemcgwin_ncmds.sed.pl
bffa7018   Ilyes Choubani   update
555
            cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec,dataset='SED', /refresh ,position=p_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra     
96a72c8b   Ilyes Choubani   seperating xrange...
556
557
            
            cmdind_m = !dustemcgwin_ncmds.sed.nrm
bffa7018   Ilyes Choubani   update
558
            cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec,dataset='SED', /norm, /refresh,position=np_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra
5f04fa07   Ilyes Choubani   general update
559
560
           
           
18e4331f   Ilyes Choubani   general update (f...
561
       endif else begin
5f04fa07   Ilyes Choubani   general update
562
      
bffa7018   Ilyes Choubani   update
563
           cgwindow,'dustem_plot_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 
96a72c8b   Ilyes Choubani   seperating xrange...
564
           
bffa7018   Ilyes Choubani   update
565
           cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
566
           !dustemcgwin_ncmds.sed.pl = cmdind_m
5f04fa07   Ilyes Choubani   general update
567
           
bffa7018   Ilyes Choubani   update
568
           cgwindow,'dustem_plot_dataset', st, dataset='SED',/norm, position=np_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be used too
5f04fa07   Ilyes Choubani   general update
569
           
bffa7018   Ilyes Choubani   update
570
           cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, /addcmd ,winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
571
           !dustemcgwin_ncmds.sed.nrm = cmdind_m
5f04fa07   Ilyes Choubani   general update
572
              
18e4331f   Ilyes Choubani   general update (f...
573
574
575
576
577
       endelse       
    endelse
    
    ;if ~!run_pol then begin;I don't think the order of the  ;goto, end_m
      if !run_pol then begin ;then goto, end_m
2910e8ce   Ilyes Choubani   Draft version of ...
578
        
18e4331f   Ilyes Choubani   general update (f...
579
580
        if ~test_qsed then begin ;Qsed is not present
            
bffa7018   Ilyes Choubani   update
581
582
            cgwindow,'dustem_plot_dataset', st, dataset='QSED', /nodata, position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
            cgwindow,'dustem_plot_dataset', st, dataset='QSED', /nodata, /norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
c8368c6e   Ilyes Choubani   updating plotting...
583
        
18e4331f   Ilyes Choubani   general update (f...
584
585
586
        endif else begin ;Qsed data is present
               
            if  ~iswinsed then begin
96a72c8b   Ilyes Choubani   seperating xrange...
587
            
18e4331f   Ilyes Choubani   general update (f...
588
589
                cmdind_m = !dustemcgwin_ncmds.qsed.pl
                ;refreshing the positive_only and negative_only plots if data is present in them
bffa7018   Ilyes Choubani   update
590
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/positive_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
5f04fa07   Ilyes Choubani   general update
591
                
bffa7018   Ilyes Choubani   update
592
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/negative_only, nodata=0, /refresh ,position=p_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
5f04fa07   Ilyes Choubani   general update
593
                
18e4331f   Ilyes Choubani   general update (f...
594
                cmdind_m = !dustemcgwin_ncmds.qsed.nrm
bffa7018   Ilyes Choubani   update
595
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED', /refresh, nodata=0, /norm,position=np_qsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
5f04fa07   Ilyes Choubani   general update
596
                
18e4331f   Ilyes Choubani   general update (f...
597
            endif else begin
5f04fa07   Ilyes Choubani   general update
598
                
dfc68a85   Ilyes Choubani   Fixed some plotti...
599
                ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
bffa7018   Ilyes Choubani   update
600
                cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
601
                ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
602
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
07372e26   Ilyes Choubani   Corrected huge pl...
603
604
                
                !dustemcgwin_ncmds.qsed.pl = cmdind_m
18e4331f   Ilyes Choubani   general update (f...
605
                
bffa7018   Ilyes Choubani   update
606
                cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
607
                ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
608
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
609
                
5f04fa07   Ilyes Choubani   general update
610
                
bffa7018   Ilyes Choubani   update
611
612
                cgwindow,'dustem_plot_dataset', st, dataset='QSED',/norm, position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be uqsed too
                cgwindow,'dustem_plot_dataset', st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
613
                !dustemcgwin_ncmds.qsed.nrm = cmdind_m
5f04fa07   Ilyes Choubani   general update
614
                
18e4331f   Ilyes Choubani   general update (f...
615
616
        endelse       
      endelse
5f04fa07   Ilyes Choubani   general update
617
         ;stop        
18e4331f   Ilyes Choubani   general update (f...
618
619
        if ~test_used then begin ;used is not present
            
bffa7018   Ilyes Choubani   update
620
621
            cgwindow,'dustem_plot_dataset', st, dataset='USED', /nodata, position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
            cgwindow,'dustem_plot_dataset', st, dataset='USED', /nodata, /norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
c8368c6e   Ilyes Choubani   updating plotting...
622
        
18e4331f   Ilyes Choubani   general update (f...
623
624
625
626
627
        endif else begin ;used data is present
               
            if  ~iswinsed then begin
                cmdind_m = !dustemcgwin_ncmds.used.pl
                ;refreshing the positive_only and negative_only plots if data is present in them
bffa7018   Ilyes Choubani   update
628
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
5f04fa07   Ilyes Choubani   general update
629
                
bffa7018   Ilyes Choubani   update
630
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh, nodata=0 ,position=p_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m+2, _extra=_extra
5f04fa07   Ilyes Choubani   general update
631
                
18e4331f   Ilyes Choubani   general update (f...
632
                cmdind_m = !dustemcgwin_ncmds.used.nrm
bffa7018   Ilyes Choubani   update
633
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED', /refresh, nodata=0, /norm,position=np_used, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
5f04fa07   Ilyes Choubani   general update
634
                
18e4331f   Ilyes Choubani   general update (f...
635
636
637
            endif else begin
            ;stop
                ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
bffa7018   Ilyes Choubani   update
638
                cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
639
                ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
640
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
07372e26   Ilyes Choubani   Corrected huge pl...
641
642
                
                !dustemcgwin_ncmds.used.pl = cmdind_m
18e4331f   Ilyes Choubani   general update (f...
643
                
bffa7018   Ilyes Choubani   update
644
                cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
645
                ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
646
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
07372e26   Ilyes Choubani   Corrected huge pl...
647
                
18e4331f   Ilyes Choubani   general update (f...
648
                
18e4331f   Ilyes Choubani   general update (f...
649
                
bffa7018   Ilyes Choubani   update
650
651
                cgwindow,'dustem_plot_dataset', st, dataset='USED',/norm, position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be uused too
                cgwindow,'dustem_plot_dataset', st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
652
                !dustemcgwin_ncmds.used.nrm = cmdind_m
5f04fa07   Ilyes Choubani   general update
653
                
18e4331f   Ilyes Choubani   general update (f...
654
655
656
657
658
        endelse       
      endelse
      
      if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
659
          cgwindow,'dustem_plot_dataset', st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra  & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
660
661

      endif else begin ;psi_em exists
5cb00808   Jean-Philippe Bernard   added some commen...
662
         ;stop
18e4331f   Ilyes Choubani   general update (f...
663
664
         if  ~iswinsed then begin
             cmdind_m = !dustemcgwin_ncmds.psi_em.pl
bffa7018   Ilyes Choubani   update
665
             cgwindow,'dustem_plot_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
af5bca1f   Ilyes Choubani   general update
666
             
18e4331f   Ilyes Choubani   general update (f...
667
668
         endif else begin
         ;stop
bffa7018   Ilyes Choubani   update
669
670
             cgwindow,'dustem_plot_dataset', st, dataset='psi_em', position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
             cgwindow,'dustem_plot_dataset', st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
671
             !dustemcgwin_ncmds.psi_em.pl = cmdind_m
af5bca1f   Ilyes Choubani   general update
672

18e4331f   Ilyes Choubani   general update (f...
673
674
         endelse       
      endelse
c8368c6e   Ilyes Choubani   updating plotting...
675
        
18e4331f   Ilyes Choubani   general update (f...
676
677
678
      
      if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
679
680
          cgwindow,'dustem_plot_dataset', st, dataset='polsed', /nodata, position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
          cgwindow,'dustem_plot_dataset', st, dataset='polsed', /nodata, /norm, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
681
682
683
684
685

      endif else begin ;polsed exists

         if  ~iswinsed then begin
             cmdind_m = !dustemcgwin_ncmds.polsed.pl
bffa7018   Ilyes Choubani   update
686
             cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
18e4331f   Ilyes Choubani   general update (f...
687
             cmdind_m = !dustemcgwin_ncmds.polsed.nrm
bffa7018   Ilyes Choubani   update
688
             cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
18e4331f   Ilyes Choubani   general update (f...
689
690
         endif else begin
         ;stop
bffa7018   Ilyes Choubani   update
691
692
             cgwindow,'dustem_plot_dataset', st, dataset='polsed', position=p_psed, /addcmd, winid=winid_m, _extra=_extra  & cmdind_m+=1  
             cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
693
             !dustemcgwin_ncmds.polsed.pl = cmdind_m
bffa7018   Ilyes Choubani   update
694
695
             cgwindow,'dustem_plot_dataset', st, dataset='polsed',/norm, position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 ;I think nodata can also be upolsed too
             cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
696
697
698
             !dustemcgwin_ncmds.polsed.nrm = cmdind_m
         endelse       
      endelse      
af5bca1f   Ilyes Choubani   general update
699
700
      
      
af5bca1f   Ilyes Choubani   general update
701
702
      if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
703
          cgwindow,'dustem_plot_dataset', st, dataset='polfrac', /nodata, position=p_spsed, /addcmd, winid=winid_m, _extra=_extra  & cmdind_m+=1
18e4331f   Ilyes Choubani   general update (f...
704

af5bca1f   Ilyes Choubani   general update
705
      endif else begin ;polfrac exists
18e4331f   Ilyes Choubani   general update (f...
706

af5bca1f   Ilyes Choubani   general update
707
708
         if  ~iswinsed then begin
             cmdind_m = !dustemcgwin_ncmds.polfrac.pl
bffa7018   Ilyes Choubani   update
709
             cgwindow,'dustem_plot_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra
af5bca1f   Ilyes Choubani   general update
710
711
712
             
         endif else begin
         ;stop
bffa7018   Ilyes Choubani   update
713
714
             cgwindow,'dustem_plot_dataset', st, dataset='polfrac', position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
             cgwindow,'dustem_plot_dataset', st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1
af5bca1f   Ilyes Choubani   general update
715
             !dustemcgwin_ncmds.polfrac.pl = cmdind_m
18e4331f   Ilyes Choubani   general update (f...
716

af5bca1f   Ilyes Choubani   general update
717
718
         endelse       
      endelse  
5f04fa07   Ilyes Choubani   general update
719
      
18e4331f   Ilyes Choubani   general update (f...
720

5f04fa07   Ilyes Choubani   general update
721
    ENDIF
d4f8829f   Ilyes Choubani   small cleaning
722
      
5f04fa07   Ilyes Choubani   general update
723
    cgcontrol, winid_m, execute=1
2910e8ce   Ilyes Choubani   Draft version of ...
724
         
5f04fa07   Ilyes Choubani   general update
725
726
727
ENDIF 


67bd858a   Ilyes Choubani   Replication of th...
728

afde94a3   Ilyes Choubani   general update
729
;stop
67bd858a   Ilyes Choubani   Replication of th...
730
731
732
733
734
if test_x then begin
    ;Generating extinction window and saving window ID
    
    if iswinext then begin
        
3b1e2e39   Jean-Philippe Bernard   replaced V2.0 by ...
735
        if !run_pol then cgwindow,wxsize=main_wxsize,wysize=main_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)' else cgwindow,wxsize=main_wxsize,wysize=main_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)';, wback='grey';,wobject=winobj_m
67bd858a   Ilyes Choubani   Replication of th...
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
        winid_x = cgquery(dimensions=dim_x,/current) ;this has to be changed because the dimensions of this array change with the data sets present (extinction/emission).
        !dustemcgwin_id.ext = winid_x
        
        cgcontrol, winid_x, execute=0
        ;cgset, winid_m
        ;Plotting model string (legend)
        xxpos = 0.015
        yypos = 0.97
        ;Plotting Hydrogen column density string (legend)
        cgtext, xxpos, yypos,'Model : '+!dustem_model,color=0,/normal,charsize = 1.2,/addcmd ;& cmdind_m+=1 This is the first command in the window
        yypos = 0.95
        cgtext, xxpos, yypos,textoidl('N_{H}')+textoidl(' (H/cm^2) : ')+strmid(string(*!dustem_HCD,format='(1E10.2)'),2),color=0,/normal,charsize = 1.2,/addcmd & cmdind_x+=1
        
        ;Plotting of the number of iterations completed by the fitter
        
        ;Plotting of the number of runs
        ;Getting the width of the unrefreshed string
        widthtot=0.
5cb00808   Jean-Philippe Bernard   added some commen...
754
755
        ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
756
757
758
759
760
761
762
763
764
765
766
767
768
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        !dustemcgwin_ncmds.runs.txtwdth = thiswidth
        
        ;Getting the width of the refreshed string
        cgtext, xxpos, yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtot+= thiswidth;varying width        
        
        ;These two lines will also have to      be modified when plotting the refreshed values
        xxpos = 0.015 ;1.0 - widthtot - 0.03
        yypos = 0.015
        
        ;Displaying fixed part
5cb00808   Jean-Philippe Bernard   added some commen...
769
770
        ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1
        cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
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
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        cgtext, xxpos + widthtext + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_x+=1
        ;saving the command id to replace it
        !dustemcgwin_ncmds.runs.pl = cmdind_x

        ;plotting of (mostly) fixed data for rchi2
        ;Since the format of the strings is specified, the length/width of the string in thex direction is fixed. 
        
        
        ;Getting the width of the unrefreshed string
        widthtot=0.
        cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        
        ;Getting the width of the refresh.ed string
        cgtext, xxpos, yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtot+= thiswidth;varying width        
        ;saving the command string width to replace it
        !dustemcgwin_ncmds.chi2.txtwdth = thiswidth
        
        
        xxpos = 1.0 - widthtot - 0.03
        
        yypos = 0.97
        
        ;Displaying fixed part
        cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0,/addcmd & cmdind_x+=1
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        
        cgtext, xxpos + widthtext , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_x+=1
        
        ;saving the command id to replace it
        !dustemcgwin_ncmds.chi2.pl = cmdind_x
  
        
        
        ;plotting of (mostly) fixed data for rchi2
        
        ;Getting the width of the unrefreshed string
        widthtot=0.
        cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtext = thiswidth
        widthtot+= thiswidth ;fixed width
        ;!dustemcgwin_ncmds.rchi2.txtwdth1 = thiswidth
        ;Getting the width of the refreshed string
        cgtext, xxpos, yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtot+= thiswidth;varying width        
        !dustemcgwin_ncmds.rchi2.txtwdth = thiswidth
        ;These two lines will also have to      be modified when plotting the refreshed values
        xxpos = 1.0 - widthtot - 0.03
        yypos = 0.95
        
        ;Displaying fixed part
        cgtext, xxpos, yypos,textoidl('r_{\chi^{2}} : '),color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1
        ;Displaying refreshed part (first run . This is the command that will be replaced)
        cgtext, xxpos + widthtext , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/addcmd & cmdind_x+=1
        ;saving the command id to replace it
        !dustemcgwin_ncmds.rchi2.pl = cmdind_x
        
        
        ;Plotting of the title of the dashboard (plot(s))
        
        ;NB: JP is right, the user should be able to set the entirety of the title.
        ;Make this block aware of the saving of the data  (from the fits table)
        
        
        ;Getting the width of the title 
        tit=string(_extra.title);
    
        cgtext, 0.3, 0.95,tit+' (RUNNING)',color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1
        widthtot = thiswidth
        xxpos = (1 - thiswidth)/2
        yypos = 0.96
        
        cgtext, 0.3, 0.95,tit,color=0,/normal,charsize=-1,width=thiswidth,/addcmd & cmdind_x+=1 
        !dustemcgwin_ncmds.pltit.txtwdth = thiswidth*1.6 + (1 - widthtot)/2
          
        cgtext, xxpos, yypos,tit,color=0,/normal,charsize = 1.6,/addcmd & cmdind_x+=1
        xxpos+=thiswidth*1.6
        cgtext, xxpos, yypos,' (RUNNING)',color=0,/normal,charsize = 1.6,/addcmd & cmdind_x+=1
        
        !dustemcgwin_ncmds.pltit.pl = cmdind_x
        
    endif else begin 
    
        
        winid_x = !dustemcgwin_id.ext
        cgcontrol, winid_x, execute=0
        cgset, winid_x ;apparently specifying the window index isn't enough. This might be because of the use of cgcontrol
        
        ;Refreshing chi2 data: 
afde94a3   Ilyes Choubani   general update
863
        cmdind_x = !dustemcgwin_ncmds.chi2.pl
67bd858a   Ilyes Choubani   Replication of th...
864
865
        xxpos = 1 - !dustemcgwin_ncmds.chi2.txtwdth - 0.03  
        yypos = 0.97
afde94a3   Ilyes Choubani   general update
866
        cgwindow,'cgtext', xxpos , yypos,strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
67bd858a   Ilyes Choubani   Replication of th...
867
868
869
870
        
        
        
        ;Refreshing rchi2 data: 
afde94a3   Ilyes Choubani   general update
871
        cmdind_x = !dustemcgwin_ncmds.rchi2.pl
67bd858a   Ilyes Choubani   Replication of th...
872
873
        xxpos = 1 - !dustemcgwin_ncmds.rchi2.txtwdth - 0.03  
        yypos = 0.95
afde94a3   Ilyes Choubani   general update
874
        cgwindow,'cgtext', xxpos , yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
67bd858a   Ilyes Choubani   Replication of th...
875
876
877
        
        
        ;Refreshing number of runs data: 
afde94a3   Ilyes Choubani   general update
878
        cmdind_x = !dustemcgwin_ncmds.runs.pl
67bd858a   Ilyes Choubani   Replication of th...
879
880
        xxpos = 0.03 + !dustemcgwin_ncmds.runs.txtwdth*1.35  ;(because of charsize)
        yypos = 0.015
afde94a3   Ilyes Choubani   general update
881
        cgwindow,'cgtext', xxpos , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1
67bd858a   Ilyes Choubani   Replication of th...
882
883
884
885
886
887
        
          
        ;update of the title here ?
        ;NB: JP is right, the user should be able to set the entirety of the title.
        ;Make this block aware of the saving of the data  (from the fits table)
        
bffa7018   Ilyes Choubani   update
888
        if !dustem_end EQ 1 then begin
67bd858a   Ilyes Choubani   Replication of th...
889
            ;replacing my count - 3
bffa7018   Ilyes Choubani   update
890
            tit=!dustem_plot_range.title_x
afde94a3   Ilyes Choubani   general update
891
            cmdind_x = !dustemcgwin_ncmds.pltit.pl
67bd858a   Ilyes Choubani   Replication of th...
892
893
894
895
            
            xxpos = !dustemcgwin_ncmds.pltit.txtwdth
            yypos = 0.96
        
afde94a3   Ilyes Choubani   general update
896
            cgwindow,'cgtext', xxpos , yypos,' (Final Run)',color=0,/normal,charsize = 1.6,/replacecmd,cmdindex=cmdind_x, winid=winid_x  
67bd858a   Ilyes Choubani   Replication of th...
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
        
        endif
    
    endelse
    
    ;cgWindow_GetDefs,xsize=xsize,ysize=ysize
    ;cgcontrol, resize=[xsize,ysize]
    if !run_pol then begin
        ;,wback='grey'
        
        ;position arrays for plot and normalized graph
        
        ;THIS IS HARD-CODED IN A VERY SILLY WAY
        
        p_ext = [0.05,0.67,0.475,0.90]
        p_pext = [0.525,0.67,0.95,0.90]
        p_spext = [0.05,0.375,0.475,0.575] ; Should we plot this? tau_polext/tau_ext_tot. YES FOR NOW...
        p_psiext = [0.525,0.375,0.95,0.575]
        p_qext = [0.05,0.12,0.475,0.35]  
        p_uext = [0.525,0.12,0.95,0.35]
        
        np_ext = [0.05,0.60,0.475,0.67]
        np_pext = [0.525,0.60,0.95,0.67]
        np_qext = [0.05,0.05,0.475,0.12] 
        np_uext = [0.525,0.05,0.95,0.12]
        
        p_ext[1]+= 0.0125 & p_ext[3]+= 0.0125 
        p_pext[1]+= 0.0125 & p_pext[3]+= 0.0125
        p_spext[1]+= 0.0125 & p_spext[3]+= 0.0125
        p_psiext[1]+= 0.0125 & p_psiext[3]+= 0.0125
        p_qext[1]+= 0.0125 & p_qext[3]+= 0.0125
        p_uext[1]+= 0.0125 & p_uext[3]+= 0.0125
        
        np_ext[1]+= 0.0125 & np_ext[3]+= 0.0125 
        np_pext[1]+= 0.0125 & np_pext[3]+= 0.0125
        np_qext[1]+= 0.0125 & np_qext[3]+= 0.0125
        np_uext[1]+= 0.0125 & np_uext[3]+= 0.0125
        
        
          
    endif else begin
        p_ext  = [0.07,0.30,0.97,0.85]
        np_ext = [0.07,0.10,0.97,0.30]
    
    endelse

    ;Plotting of sed data axes (whether or not data is present)
    plotsym,0,/fill ;you might need to execute this again. hmm...


    ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
    if ~test_ext then begin ; EXT data is not present (For completeness) # This is only valid when !run_pol=1
        
bffa7018   Ilyes Choubani   update
950
951
        cgwindow,'dustem_plot_dataset', st, dataset='EXT', /nodata, position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
        cgwindow,'dustem_plot_dataset', st, dataset='EXT', /nodata, /norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
952
953
954
955
956

    endif else begin ;EXT exists

        if  ~iswinext then begin
        
afde94a3   Ilyes Choubani   general update
957
            cmdind_x = !dustemcgwin_ncmds.ext.pl
bffa7018   Ilyes Choubani   update
958
            cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /refresh ,position=p_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra     
67bd858a   Ilyes Choubani   Replication of th...
959
            
afde94a3   Ilyes Choubani   general update
960
            cmdind_x = !dustemcgwin_ncmds.ext.nrm
bffa7018   Ilyes Choubani   update
961
            cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /norm, /refresh,position=np_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
962
963
964
965
            
            
        endif else begin
      
bffa7018   Ilyes Choubani   update
966
967
            cgwindow,'dustem_plot_dataset', st, dataset='EXT', position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 
            cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
968
969
            !dustemcgwin_ncmds.ext.pl = cmdind_x
            
bffa7018   Ilyes Choubani   update
970
            cgwindow,'dustem_plot_dataset', st, dataset='EXT',/norm, position=np_ext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be used too
67bd858a   Ilyes Choubani   Replication of th...
971
            
bffa7018   Ilyes Choubani   update
972
            cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, /addcmd ,winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
973
974
975
976
977
            !dustemcgwin_ncmds.ext.nrm = cmdind_x
              
        endelse       
    endelse
    
d4f8829f   Ilyes Choubani   small cleaning
978
979
    
      if !run_pol then begin 
67bd858a   Ilyes Choubani   Replication of th...
980
981
982
        
        if ~test_qext then begin ;Qext is not present
            
bffa7018   Ilyes Choubani   update
983
984
            cgwindow,'dustem_plot_dataset', st, dataset='QEXT', /nodata, position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
            cgwindow,'dustem_plot_dataset', st, dataset='QEXT', /nodata, /norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
985
986
987
988
989
990
        
        endif else begin ;Qext data is present
                
            if  ~iswinext then begin
                cmdind_x = !dustemcgwin_ncmds.qext.pl
                ;refreshing the positive_only and negative_only plots if data is present in them
bffa7018   Ilyes Choubani   update
991
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/positive_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
992
                
bffa7018   Ilyes Choubani   update
993
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/negative_only, nodata=0, /refresh ,position=p_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
994
995
                
                cmdind_x = !dustemcgwin_ncmds.qext.nrm
bffa7018   Ilyes Choubani   update
996
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT', /refresh, nodata=0, /norm,position=np_qext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
997
998
999
1000
                
            endif else begin
                
                ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendered)
bffa7018   Ilyes Choubani   update
1001
                cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1002
                ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
afde94a3   Ilyes Choubani   general update
1003
                
bffa7018   Ilyes Choubani   update
1004
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
07372e26   Ilyes Choubani   Corrected huge pl...
1005
1006
                
                !dustemcgwin_ncmds.qext.pl = cmdind_x
67bd858a   Ilyes Choubani   Replication of th...
1007
                
bffa7018   Ilyes Choubani   update
1008
                cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1009
                ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
1010
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1011
            
bffa7018   Ilyes Choubani   update
1012
1013
                cgwindow,'dustem_plot_dataset', st, dataset='QEXT',/norm, position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uqsed too
                cgwindow,'dustem_plot_dataset', st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1014
1015
1016
1017
1018
1019
1020
                !dustemcgwin_ncmds.qext.nrm = cmdind_x
                
        endelse       
      endelse
          ;stop        
        if ~test_uext then begin ;uext is not present
            
bffa7018   Ilyes Choubani   update
1021
1022
            cgwindow,'dustem_plot_dataset', st, dataset='UEXT', /nodata, position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
            cgwindow,'dustem_plot_dataset', st, dataset='UEXT', /nodata, /norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1023
1024
1025
1026
1027
1028
        
        endif else begin ;uext data is present
                
            if  ~iswinext then begin
                cmdind_x = !dustemcgwin_ncmds.uext.pl
                ;refreshing the positive_only and negative_only plots if data is present in them
bffa7018   Ilyes Choubani   update
1029
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1030
                
bffa7018   Ilyes Choubani   update
1031
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, nodata=0, /refresh ,position=p_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x+2, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1032
                
afde94a3   Ilyes Choubani   general update
1033
                cmdind_x = !dustemcgwin_ncmds.uext.nrm
bffa7018   Ilyes Choubani   update
1034
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /refresh, nodata=0, /norm,position=np_uext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1035
1036
1037
1038
                
            endif else begin
            ;stop
                ;Plotting of postive values if they exist (if hidden data is present it is plotted if not an empty plot is rendred)
bffa7018   Ilyes Choubani   update
1039
                cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1
53548c91   Ilyes Choubani   Display of frozen...
1040
                
67bd858a   Ilyes Choubani   Replication of th...
1041
                ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
1042
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
07372e26   Ilyes Choubani   Corrected huge pl...
1043
1044
                
                !dustemcgwin_ncmds.uext.pl = cmdind_x
67bd858a   Ilyes Choubani   Replication of th...
1045
                
bffa7018   Ilyes Choubani   update
1046
                cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1047
                ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
1048
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1049
                
67bd858a   Ilyes Choubani   Replication of th...
1050
                
bffa7018   Ilyes Choubani   update
1051
1052
                cgwindow,'dustem_plot_dataset', st, dataset='UEXT',/norm, position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be uused too
                cgwindow,'dustem_plot_dataset', st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1053
1054
1055
1056
1057
1058
1059
                !dustemcgwin_ncmds.uext.nrm = cmdind_x
                
        endelse       
      endelse
      
      if ~test_psi_ext then begin ; psi_ext data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
1060
          cgwindow,'dustem_plot_dataset', st, dataset='PSI_EXT', /nodata, position=p_psiext, /addcmd, winid=winid_x, _extra=_extra  & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1061
1062
1063
1064
1065

      endif else begin ;psi_ext exists

          if  ~iswinext then begin
              cmdind_x = !dustemcgwin_ncmds.psi_ext.pl
bffa7018   Ilyes Choubani   update
1066
              cgwindow,'dustem_plot_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='PSI_EXT', /refresh ,position=p_psiext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1067
1068
1069
              
          endif else begin
          ;stop
bffa7018   Ilyes Choubani   update
1070
1071
              cgwindow,'dustem_plot_dataset', st, dataset='psi_ext', position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
              cgwindow,'dustem_plot_dataset', st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1072
1073
1074
1075
1076
1077
1078
1079
              !dustemcgwin_ncmds.psi_ext.pl = cmdind_x

          endelse       
      endelse
        
      
      if ~test_polext then begin ; polext data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
1080
1081
          cgwindow,'dustem_plot_dataset', st, dataset='polext', /nodata, position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
          cgwindow,'dustem_plot_dataset', st, dataset='polext', /nodata, /norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1082
1083
1084
1085
1086

      endif else begin ;polext exists

          if  ~iswinext then begin
              cmdind_x = !dustemcgwin_ncmds.polext.pl
bffa7018   Ilyes Choubani   update
1087
              cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1088
              cmdind_x = !dustemcgwin_ncmds.polext.nrm
bffa7018   Ilyes Choubani   update
1089
              cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1090
1091
          endif else begin
          ;stop
bffa7018   Ilyes Choubani   update
1092
1093
              cgwindow,'dustem_plot_dataset', st, dataset='polext', position=p_pext, /addcmd, winid=winid_x, _extra=_extra  & cmdind_x+=1  
              cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1094
              !dustemcgwin_ncmds.polext.pl = cmdind_x
bffa7018   Ilyes Choubani   update
1095
1096
              cgwindow,'dustem_plot_dataset', st, dataset='polext',/norm, position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 ;I think nodata can also be upolsed too
              cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1097
1098
1099
1100
1101
1102
1103
              !dustemcgwin_ncmds.polext.nrm = cmdind_x
          endelse
      endelse      
      
      
      if ~test_fpolext then begin ; fpolext data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
1104
          cgwindow,'dustem_plot_dataset', st, dataset='fpolext', /nodata, position=p_spext, /addcmd, winid=winid_x, _extra=_extra  & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1105
1106
1107
1108
1109

      endif else begin ;fpolext exists

          if  ~iswinext then begin
              cmdind_x = !dustemcgwin_ncmds.fpolext.pl
bffa7018   Ilyes Choubani   update
1110
              cgwindow,'dustem_plot_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1111
1112
              
          endif else begin
07372e26   Ilyes Choubani   Corrected huge pl...
1113
          
bffa7018   Ilyes Choubani   update
1114
1115
              cgwindow,'dustem_plot_dataset', st, dataset='fpolext', position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
              cgwindow,'dustem_plot_dataset', st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1
67bd858a   Ilyes Choubani   Replication of th...
1116
1117
1118
1119
1120
1121
1122
1123
              !dustemcgwin_ncmds.fpolext.pl = cmdind_x

          endelse       
      endelse  
      

    ENDIF
        
67bd858a   Ilyes Choubani   Replication of th...
1124
    cgcontrol, winid_x, execute=1
d4f8829f   Ilyes Choubani   small cleaning
1125
     
67bd858a   Ilyes Choubani   Replication of th...
1126
1127
1128
1129
          
ENDIF 


5f04fa07   Ilyes Choubani   general update
1130
1131
1132
1133
1134
1135
IF ~iswinprms THEN BEGIN;(NEXT RUNS)
    
    winid_prms = !dustemcgwin_id.prms
    cgcontrol, winid_prms, execute=0
    cgset, winid_prms
    cmdind_prms = !dustemcgwin_ncmds.prms.pl
bffa7018   Ilyes Choubani   update
1136
    cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /refresh, winid=winid_prms,/replacecmd,cmdindex=cmdind_prms, _extra=_extra
5f04fa07   Ilyes Choubani   general update
1137
1138
    cgcontrol, winid_prms ,execute=1 
ENDIF ELSE BEGIN ;(FIRST RUN)
3b1e2e39   Jean-Philippe Bernard   replaced V2.0 by ...
1139
    cgwindow,wxpos=param_wxpos,wypos=param_wypos,wxsize=param_wxsize,wysize=param_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot? 
b6aa1f62   Jean-Philippe Bernard   moved PARAMETERS ...
1140
;    cgwindow,wxsize=350,wysize=200,wtitle='DUSTEMWRAP v2.0 (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot? 
5f04fa07   Ilyes Choubani   general update
1141
1142
1143
    winid_prms = cgquery(dimensions=dim_prms,/current) ;we don't need the dimension of the window so far/ I don't know why I needed it before
    cgcontrol, winid_prms, execute=0
    !dustemcgwin_id.prms = winid_prms
bffa7018   Ilyes Choubani   update
1144
1145
    cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd , winid=winid_prms,_extra=_extra ;& cmdind_prms+=1
    cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PARAMETERS', /addcmd, /refresh , winid=winid_prms, _extra=_extra & cmdind_prms+=1
5f04fa07   Ilyes Choubani   general update
1146
1147
1148
1149
    !dustemcgwin_ncmds.prms.pl = cmdind_prms
    cgcontrol, winid_prms ,execute=1        
ENDELSE 

2910e8ce   Ilyes Choubani   Draft version of ...
1150

67bd858a   Ilyes Choubani   Replication of th...
1151
;DISPLAY OF PLUGINS HAS A SMALL ISSUE
d4f8829f   Ilyes Choubani   small cleaning
1152
IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN  
67bd858a   Ilyes Choubani   Replication of th...
1153
1154
1155
1156
1157
1158
1159

    IF ~iswinplgns THEN BEGIN;(NEXT RUNS)
        
        winid_plgns = !dustemcgwin_id.plgns
        cgcontrol, winid_plgns, execute=0
        cgset, winid_plgns
        cmdind_plgns = !dustemcgwin_ncmds.plgns.pl
bffa7018   Ilyes Choubani   update
1160
        cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /refresh, winid=winid_plgns,/replacecmd,cmdindex=cmdind_plgns, _extra=_extra
67bd858a   Ilyes Choubani   Replication of th...
1161
1162
        cgcontrol, winid_plgns ,execute=1 
    ENDIF ELSE BEGIN ;(FIRST RUN)
3b1e2e39   Jean-Philippe Bernard   replaced V2.0 by ...
1163
        cgwindow,wxpos=plugin_wxpos,wypos=plugin_wypos,wxsize=plugin_wxsize,wysize=plugin_wysize,wtitle='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot? 
b6aa1f62   Jean-Philippe Bernard   moved PARAMETERS ...
1164
        ;cgwindow,wxsize=350,wysize=200,wtitle='DUSTEMWRAP v2.0 (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot? 
67bd858a   Ilyes Choubani   Replication of th...
1165
1166
1167
        winid_plgns = cgquery(dimensions=dim_plgns,/current) ;we don't need the dimension of the window so far/ I don't know why I needed it before
        cgcontrol, winid_plgns, execute=0
        !dustemcgwin_id.plgns = winid_plgns
bffa7018   Ilyes Choubani   update
1168
1169
        cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd , winid=winid_plgns,_extra=_extra ;& cmdind_prms+=1
        cgwindow,'dustem_plot_dataset', st, res, errors, p_dim,dataset='PLUGINS', /addcmd, /refresh , winid=winid_plgns, _extra=_extra & cmdind_plgns+=1
67bd858a   Ilyes Choubani   Replication of th...
1170
1171
1172
1173
1174
        !dustemcgwin_ncmds.plgns.pl = cmdind_plgns
        cgcontrol, winid_plgns ,execute=1        
    ENDELSE
     
ENDIF
2910e8ce   Ilyes Choubani   Draft version of ...
1175

392ede91   Jean-Philippe Bernard   included an help ...
1176
1177
the_end:

2910e8ce   Ilyes Choubani   Draft version of ...
1178
END