Blame view

src/idl/dustemwrap_plot_noobj.pro 35.1 KB
ed831104   Ilyes Choubani   no obj plotting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PRO dustemwrap_plot_noobj,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:
bffa7018   Ilyes Choubani   update
18
;    dustemwrap_plot_noobj
ed831104   Ilyes Choubani   no obj plotting
19
; PURPOSE:
bffa7018   Ilyes Choubani   update
20
;    plots dustemwrap observed sed, predicted sed, predicted spectra for total Intensity, polarization in emission and extinction without OOP routines
ed831104   Ilyes Choubani   no obj plotting
21
22
23
; CATEGORY:
;    DustEMWrap
; CALLING SEQUENCE:
bffa7018   Ilyes Choubani   update
24
;    dustemwrap_plot_noobj,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 
ed831104   Ilyes Choubani   no obj plotting
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
; 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:
;    

; 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

;This is also necessary for the plotting of the results of the fit (Last iteration) 
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. 
3466882c   Annie Hughes   removed help
95
  dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values),st=st  ; 0/0 division case?
ed831104   Ilyes Choubani   no obj plotting
96
97
98
99
100
  
  ;# Emission
  ;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
  if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin ;better test?
  
3466882c   Annie Hughes   removed help
101
      dustem_sed = dustem_compute_sed(p_dim,st=st,SED_spec=SED_spec)
ed831104   Ilyes Choubani   no obj plotting
102
103
      
      if !run_pol && !run_lin then begin
3466882c   Annie Hughes   removed help
104
105
106
         dustem_polsed = dustem_compute_polsed(p_dim,st=st,P_spec=P_spec,SP_spec=SP_spec,dustem_polfrac=dustem_polfrac)
; the following call need to change to include out instead of dustem_qsed/dustem_used?
         toto = dustem_compute_stokes(p_dim,st=st,dustem_qsed,dustem_used,Q_spec=Q_spec,U_spec=U_spec,PSI_spec=PSI_spec,dustem_psi_em=dustem_psi_em) 
ed831104   Ilyes Choubani   no obj plotting
107
        
ed831104   Ilyes Choubani   no obj plotting
108
109
110
111
112
113
      endif         
  endif
  
  ;# Extinction
;   if isa(!dustem_data.ext) then begin
  if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin
3466882c   Annie Hughes   removed help
114
      dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec)
ed831104   Ilyes Choubani   no obj plotting
115
116
117
      
      if !run_pol && !run_lin then begin
          
3466882c   Annie Hughes   removed help
118
119
120
121
; the following call need to change to include out instead of dustem_fpolext?
          dustem_polext = dustem_compute_polext(p_dim,st=st,polext_spec=POLEXT_spec,spext_spec=SPEXT_spec,dustem_fpolext)
; the following call need to change to include out instead of QEXT/UEXT-spec?
          toto = dustem_compute_stokext(p_dim,st=st,dustem_qext,dustem_uext,QEXT_spec=QEXT_spec,UEXT_spec=UEXT_spec,PSIEXT_spe=PSIEXT_spec,dustem_psi_ext=dustem_psi_ext) 
ed831104   Ilyes Choubani   no obj plotting
122
123
124
125
126
127
128
129
130
131
          
      endif
  endif
  
ENDIF ELSE BEGIN ;st is provided 
    ;stop

    ;# Emission
    ;if isa(!dustem_data.sed) then begin
    if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin
3466882c   Annie Hughes   removed help
132
        dustem_sed = dustem_compute_sed(p_dim,st=st,SED_spec=SED_spec)
ed831104   Ilyes Choubani   no obj plotting
133
134
135
        
        if !run_pol && !run_lin then begin
            
3466882c   Annie Hughes   removed help
136
137
138
            dustem_polsed = dustem_compute_polsed(p_dim,st=st,P_spec=P_spec,SP_spec=SP_spec,dustem_polfrac=dustem_polfrac)
; the following call need to change to include out instead of dustem_q/used?
            toto = dustem_compute_stokes(p_dim,st=st,dustem_qsed,dustem_used,Q_spec=Q_spec,U_spec=U_spec,PSI_spec=PSI_spec,dustem_psi_em=dustem_psi_em) 
ed831104   Ilyes Choubani   no obj plotting
139
140
141
142
143
144
145
146
147
            ;stop    
        endif
    endif
    
    ;# Extinction
    ;if isa(!dustem_data.ext) then begin
    
    if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin
    
3466882c   Annie Hughes   removed help
148
        dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec)
ed831104   Ilyes Choubani   no obj plotting
149
150
151
        
        if !run_pol && !run_lin then begin
            
3466882c   Annie Hughes   removed help
152
153
            dustem_polext = dustem_compute_polext(p_dim,st=st,POLEXT_spec=POLEXT_spec,SPEXT_spec=SPEXT_spec,dustem_fpolext)
            toto = dustem_compute_stokext(p_dim,st=st,dustem_qext,dustem_uext,QEXT_spec=QEXT_spec,UEXT_spec=UEXT_spec,PSIEXT_spec=PSIEXT_spec,dustem_psi_ext=dustem_psi_ext) 
ed831104   Ilyes Choubani   no obj plotting
154
155
156
157
158
159
            
        endif
    endif
    
ENDELSE 

bffa7018   Ilyes Choubani   update
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
;IC: Will come back for this to include all datasets and their associated data.
;ADDING THIS BLOCK FOR COMPLETENESS
dd=(*(*!dustem_data).sed).values
ss=(*(*!dustem_data).sed).sigma
recomputed_chi2_sed   = total((dd-dustem_sed)^2/ss^2)
dof= n_elements((*(*!dustem_data).sed).values) - n_elements(*(*!dustem_fit).PARAM_DESCS)
recomputed_rchi2_sed  = recomputed_chi2_sed / dof

;print,'recomputed chi^2:',!dustem_iter.act,recomputed_rchi2_sed,recomputed_chi2_sed
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


bffa7018   Ilyes Choubani   update
176
177
178
179
180
;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.

;JPB: need here to store values of current parameter values (including plugins) into !iteration_mouchard
3466882c   Annie Hughes   removed help
181
;help,(*!dustem_fit).CURRENT_PARAM_VALUES   ;This is not currently filled up ...
bffa7018   Ilyes Choubani   update
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

;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:
 
mouchard=[mouchard,new_mouchard]
!iteration_mouchard=ptr_new(mouchard)
ed831104   Ilyes Choubani   no obj plotting
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

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

test_sed = isa((*!dustem_show).sed)
test_ext = isa((*!dustem_show).ext)
if !run_pol then begin
    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)
    test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em
    test_x = test_ext or test_polext or test_fpolext or test_qext or test_uext or test_psi_ext
endif else begin
    test_m = test_sed 
    test_x = test_ext 
endelse

;testing on the fitting of emission vs extinction data

n_plgns = n_tags(*!dustem_plugin)

frmt0='(A36)'
frmt1='(1E10.2)'
frmt2='(10F10.2)'

;Instead of setting the extra tags for plotting in dustemcgwin, we'll place them in this (parent) procedure. 
tgnms_extra = tag_names(_extra)

ed831104   Ilyes Choubani   no obj plotting
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


;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
;trying to do the same thing for parameters and plugins
cmdind_prms = 0 ;for parameters
cmdind_plgns = 0 ;for plugins

;ADDING PLUGIN(S) TO SPECTRUM----------------

;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. 

iswinsed = !dustemcgwin_id.sed EQ la_undef()
iswinext = !dustemcgwin_id.ext EQ la_undef()

;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()


;plotstrct = !p
ed831104   Ilyes Choubani   no obj plotting
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281

;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
    errors = (*(*!dustem_fit).current_param_errors)
endif else begin
    errors = (*(*!dustem_fit).param_init_values)*0. 
ENDELSE 

if isa((*!dustem_fit).chi2) then begin
    chi2 = (*!dustem_fit).chi2    
endif else begin
    chi2 = la_undef()
endelse 

if isa((*!dustem_fit).rchi2) then begin
    rchi2 = (*!dustem_fit).rchi2    
endif else begin
    rchi2 = la_undef()
endelse 


ed831104   Ilyes Choubani   no obj plotting
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
;==== These are arameters for window positioning
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

if test_m then begin
    ;Generating emission window and saving window ID
    
    ;if iswinsed then begin    ;This is when the cgwindow does not exist already
        
    TVLCT, 255, 255, 255, 254 ; White color
    !P.Color = 253
    !P.Background = 254
    
    if !run_pol then window,0, xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)',xpos=0,ypos=0 else window, 0,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EMISSION)',xpos=0, ypos=0;, wback='grey';,wobject=winobj_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_m+=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.
    ;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 
    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 
    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
    ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1
    cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35 
    ;Displaying refreshed part (first run . This is the command that will be replaced)
7d129a82   Ilyes Choubani   updating minor di...
355
    cgtext, xxpos + widthtext*1.35 + 0.015 , yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.0 
ed831104   Ilyes Choubani   no obj plotting
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
    
    ;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 
    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 
    widthtot+= thiswidth;varying width        
    ;saving the command string width to replace it
    
    xxpos = 1.0 - widthtot - 0.03
    
    yypos = 0.97
    
    ;Displaying fixed part
    cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0 
    ;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 
   
    
    ;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 
    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 
    widthtot+= thiswidth;varying width        
    
    
    ;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 
    ;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 
    ;saving the command id to replace it 
    
    ;Plotting of the title of the dashboard (plot(s))
    
    
    ;NB issue here because the user can't modify the title after the dustem_mpfit_data call at the main procedure level (user proc)
    ;Getting the width of the title 
b8019d76   Ilyes Choubani   replacing _extra....
411
    tit=!dustem_plot_range.title_m;
ed831104   Ilyes Choubani   no obj plotting
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

    cgtext, 0.3, 0.95,tit+' (RUNNING)',color=0,/normal,charsize=-1,width=thiswidth 
    widthtot = thiswidth
    xxpos = (1 - thiswidth)/2
    yypos = 0.96
    
    cgtext, 0.3, 0.95,tit,color=0,/normal,charsize=-1,width=thiswidth 
     
    cgtext, xxpos, yypos,tit,color=0,/normal,charsize = 1.6 & cmdind_m+=1
    xxpos+=thiswidth*1.6
    cgtext, xxpos, yypos,' (RUNNING)',color=0,/normal,charsize = 1.6 
    
   if !run_pol then begin
        ;,wback='grey'
        
        ;position arrays for plot and normalized graph
        
        ;THIS IS HARD-CODED IN A VERY SILLY WAY
        
        p_sed = [0.05,0.67,0.475,0.90]
        p_psed = [0.525,0.67,0.95,0.90]
        p_spsed = [0.05,0.375,0.475,0.575]
        p_psised = [0.525,0.375,0.95,0.575]
        p_qsed = [0.05,0.12,0.475,0.35]  
        p_used = [0.525,0.12,0.95,0.35]
        
        np_sed = [0.05,0.60,0.475,0.67]
        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]
        
        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
        
        
          
    endif else begin
        p_sed  = [0.07,0.30,0.97,0.85]
        np_sed = [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...
8a2cb251   Jean-Philippe Bernard   modifcations to c...
465
;stop
ed831104   Ilyes Choubani   no obj plotting
466
467
468
469

    ;This is not the right test the user might want to show the prediction for sed and fit the stokes parameters
    if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1
        
bffa7018   Ilyes Choubani   update
470
471
        dustem_plot_dataset, st, dataset='SED', /nodata, position=p_sed, _extra=_extra 
        dustem_plot_dataset, st, dataset='SED', /nodata, /norm, position=np_sed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
472
473

    endif else begin ;SED exists
8a2cb251   Jean-Philippe Bernard   modifcations to c...
474
           ;this plots the observed SED
bffa7018   Ilyes Choubani   update
475
           dustem_plot_dataset, st, dataset='SED', position=p_sed, _extra=_extra
8a2cb251   Jean-Philippe Bernard   modifcations to c...
476
           ;this plots the predicted spectrum and predicted SED
bffa7018   Ilyes Choubani   update
477
           dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, _extra=_extra 
8a2cb251   Jean-Philippe Bernard   modifcations to c...
478
           ;This plots an empty normalized plot
bffa7018   Ilyes Choubani   update
479
           dustem_plot_dataset, st, dataset='SED',/norm, position=np_sed, _extra=_extra ;I think nodata can also be used too
8a2cb251   Jean-Philippe Bernard   modifcations to c...
480
           ;This plots the normalized observed SED - best fit
bffa7018   Ilyes Choubani   update
481
           dustem_plot_dataset, st, dustem_sed,SED_spec, dataset='SED', /norm, /refresh,position=np_sed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
482
483
484
485
486
487
488
    endelse
    

      if !run_pol then begin ;then goto, end_m
        
        if ~test_qsed then begin ;Qsed is not present
            
bffa7018   Ilyes Choubani   update
489
490
            dustem_plot_dataset, st, dataset='QSED', /nodata, position=p_qsed, _extra=_extra 
            dustem_plot_dataset, st, dataset='QSED', /nodata, /norm, position=np_qsed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
491
492
493
494
        
        endif else begin ;Qsed data is present
                
            ;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
495
            dustem_plot_dataset, st, dataset='QSED', position=p_qsed,/positive_only, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
496
            ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
497
            dustem_plot_dataset, st, dustem_qsed,Q_spec, dataset='QSED',/positive_only, /refresh ,position=p_qsed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
498
499
            
             
bffa7018   Ilyes Choubani   update
500
            dustem_plot_dataset, st, dataset='QSED', position=p_qsed, /addcmd,/negative_only, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
501
            ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
502
            dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED',/negative_only, /refresh ,position=p_qsed, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
503
504
            
            
bffa7018   Ilyes Choubani   update
505
506
            dustem_plot_dataset, st, dataset='QSED',/norm, position=np_qsed, _extra=_extra  ;I think nodata can also be uqsed too
            dustem_plot_dataset, st, dustem_qsed,Q_spec,dataset='QSED', /norm, /refresh,position=np_qsed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
507
508
509
510
511
512
513
               
      endelse
      
         
              
        if ~test_used then begin ;used is not present
            
bffa7018   Ilyes Choubani   update
514
515
            dustem_plot_dataset, st, dataset='USED', /nodata, position=p_used, _extra=_extra 
            dustem_plot_dataset, st, dataset='USED', /nodata, /norm, position=np_used, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
516
517
518
519
            
        endif else begin ;used data is present
                       
            ;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
520
            dustem_plot_dataset, st, dataset='USED', position=p_used,/positive_only, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
521
            ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
522
            dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/positive_only, /refresh ,position=p_used, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
523
            
bffa7018   Ilyes Choubani   update
524
            dustem_plot_dataset, st, dataset='USED', position=p_used, winid=winid_m,/negative_only, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
525
            ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
526
            dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED',/negative_only, /refresh ,position=p_used, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
527
            
bffa7018   Ilyes Choubani   update
528
529
            dustem_plot_dataset, st, dataset='USED',/norm, position=np_used, _extra=_extra ;I think nodata can also be uused too
            dustem_plot_dataset, st, dustem_used,U_spec, dataset='USED', /norm, /refresh,position=np_used, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
530
531
532
533
534
              
      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
535
          dustem_plot_dataset, st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
536
537
538

      endif else begin ;psi_em exists
         
bffa7018   Ilyes Choubani   update
539
540
        dustem_plot_dataset, st, dataset='psi_em', position=p_psised, _extra=_extra 
        dustem_plot_dataset, st, dustem_psi_em,PSI_spec, dataset='psi_em', /refresh ,position=p_psised, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
541
542
543
544
545
546
                   
      endelse
        
      
      if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
547
548
          dustem_plot_dataset, st, dataset='polsed', /nodata, position=p_psed, _extra=_extra 
          dustem_plot_dataset, st, dataset='polsed', /nodata, /norm, position=np_psed, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
549
550
551

      endif else begin 
      
bffa7018   Ilyes Choubani   update
552
553
        dustem_plot_dataset, st, dataset='polsed', position=p_psed, _extra=_extra
        dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
554
      
bffa7018   Ilyes Choubani   update
555
556
        dustem_plot_dataset, st, dataset='polsed',/norm, position=np_psed, _extra=_extra ;I think nodata can also be upolsed too
        dustem_plot_dataset, st, dustem_polsed,P_spec, dataset='polsed', /norm, /refresh,position=np_psed, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
557
558
559
560
561
562
            
      endelse      
      
      
      if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1
          
bffa7018   Ilyes Choubani   update
563
          dustem_plot_dataset, st, dataset='polfrac', /nodata, position=p_spsed, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
564
565
566
567

      endif else begin ;polfrac exists


bffa7018   Ilyes Choubani   update
568
569
         dustem_plot_dataset, st, dataset='polfrac', position=p_spsed, _extra=_extra 
         dustem_plot_dataset, st, dustem_polfrac,SP_spec,SED_spec, dataset='polfrac', /refresh ,position=p_spsed, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
570
571
572
573
574

      endelse  
      

    ENDIF
55275be6   Ilyes Choubani   allowing no_obj p...
575
    
ed831104   Ilyes Choubani   no obj plotting
576
577
578
579
580
         
ENDIF 



ee57e2f7   Jean-Philippe Bernard   removed stops
581
;stop
ed831104   Ilyes Choubani   no obj plotting
582
583
if test_x then begin
    ;Generating extinction window and saving window ID
55275be6   Ilyes Choubani   allowing no_obj p...
584
    if !run_pol then window,1,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)' else window,1,xsize=main_wxsize,ysize=main_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (EXTINCTION)';, wback='grey';,wobject=winobj_m
ed831104   Ilyes Choubani   no obj plotting
585
    
ed831104   Ilyes Choubani   no obj plotting
586
    
55275be6   Ilyes Choubani   allowing no_obj p...
587
588
589
590
591
592
593
    ;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
ed831104   Ilyes Choubani   no obj plotting
594
    
55275be6   Ilyes Choubani   allowing no_obj p...
595
    ;Plotting of the number of iterations completed by the fitter
ed831104   Ilyes Choubani   no obj plotting
596
    
55275be6   Ilyes Choubani   allowing no_obj p...
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
    ;Plotting of the number of runs
    ;Getting the width of the unrefreshed string
    widthtot=0.
    ;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
    widthtext = thiswidth
    widthtot+= thiswidth ;fixed width
    
    ;Getting the width of the refreshed string
    cgtext, xxpos, yypos,strtrim(!dustem_iter.act,2),color=0,/normal,charsize=-1,width=thiswidth
    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
    ;cgtext, xxpos, yypos,'Runs : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_x+=1
    cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35
    ;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
    ;saving the command id to replace it
    
    
    ;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
    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
    widthtot+= thiswidth;varying width        
    ;saving the command string width to replace it
    
    
    xxpos = 1.0 - widthtot - 0.03
    
    yypos = 0.97
    
    ;Displaying fixed part
    cgtext, xxpos, yypos,textoidl('\chi^{2} : '),color=0,/normal,charsize = 1.0
    ;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
    
    ;saving the command id to replace it
      
    
    
    ;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
    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
    widthtot+= thiswidth;varying width        
    
    ;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
    ;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
    ;saving the command id to replace it
    
    
    ;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 
b8019d76   Ilyes Choubani   replacing _extra....
681
    tit=!dustem_plot_range.title_x;
55275be6   Ilyes Choubani   allowing no_obj p...
682
683
684
685
686
687
688
689
690
691
692
693
    
    cgtext, 0.3, 0.95,tit+' (RUNNING)',color=0,/normal,charsize=-1,width=thiswidth
    widthtot = thiswidth
    xxpos = (1 - thiswidth)/2
    yypos = 0.96
    
    cgtext, 0.3, 0.95,tit,color=0,/normal,charsize=-1,width=thiswidth
      
    cgtext, xxpos, yypos,tit,color=0,/normal,charsize = 1.6
    xxpos+=thiswidth*1.6
    cgtext, xxpos, yypos,' (RUNNING)',color=0,/normal,charsize = 1.6
    
bffa7018   Ilyes Choubani   update
694
   
ed831104   Ilyes Choubani   no obj plotting
695
    if !run_pol then begin
bffa7018   Ilyes Choubani   update
696
       
ed831104   Ilyes Choubani   no obj plotting
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
        ;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
740
741
        dustem_plot_dataset, st, dataset='EXT', /nodata, position=p_ext, _extra=_extra 
        dustem_plot_dataset, st, dataset='EXT', /nodata, /norm, position=np_ext, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
742
743

    endif else begin ;EXT exists
ed831104   Ilyes Choubani   no obj plotting
744
      
bffa7018   Ilyes Choubani   update
745
746
        dustem_plot_dataset, st, dataset='EXT', position=p_ext, _extra=_extra
        dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /refresh ,position=p_ext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
747
        
bffa7018   Ilyes Choubani   update
748
        dustem_plot_dataset, st, dataset='EXT',/norm, position=np_ext, _extra=_extra ;I think nodata can also be used too
55275be6   Ilyes Choubani   allowing no_obj p...
749
        
bffa7018   Ilyes Choubani   update
750
        dustem_plot_dataset, st, dustem_ext,EXT_spec, dataset='EXT', /norm, /refresh,position=np_ext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
751
               
ed831104   Ilyes Choubani   no obj plotting
752
753
754
755
756
757
758
    endelse
    
    
      if !run_pol then begin 
        
        if ~test_qext then begin ;Qext is not present
            
bffa7018   Ilyes Choubani   update
759
760
            dustem_plot_dataset, st, dataset='QEXT', /nodata, position=p_qext, _extra=_extra 
            dustem_plot_dataset, st, dataset='QEXT', /nodata, /norm, position=np_qext, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
761
762
        
        endif else begin ;Qext data is present
55275be6   Ilyes Choubani   allowing no_obj p...
763
764
                    
            ;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
765
            dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/positive_only, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
766
            ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
ed831104   Ilyes Choubani   no obj plotting
767
            
bffa7018   Ilyes Choubani   update
768
            dustem_plot_dataset, st, dustem_qext,QEXT_spec, dataset='QEXT',/positive_only, /refresh ,position=p_qext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
769
            
bffa7018   Ilyes Choubani   update
770
            dustem_plot_dataset, st, dataset='QEXT', position=p_qext,/negative_only, _extra=_extra
55275be6   Ilyes Choubani   allowing no_obj p...
771
            ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
772
            dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT',/negative_only, /refresh ,position=p_qext, _extra=_extra
55275be6   Ilyes Choubani   allowing no_obj p...
773
        
bffa7018   Ilyes Choubani   update
774
775
            dustem_plot_dataset, st, dataset='QEXT',/norm, position=np_qext, _extra=_extra ;I think nodata can also be uqsed too
            dustem_plot_dataset, st, dustem_qext,QEXT_spec,dataset='QEXT', /norm, /refresh,position=np_qext, _extra=_extra
55275be6   Ilyes Choubani   allowing no_obj p...
776

ed831104   Ilyes Choubani   no obj plotting
777
778
779
780
      endelse
          ;stop        
        if ~test_uext then begin ;uext is not present
            
bffa7018   Ilyes Choubani   update
781
782
            dustem_plot_dataset, st, dataset='UEXT', /nodata, position=p_uext, _extra=_extra
            dustem_plot_dataset, st, dataset='UEXT', /nodata, /norm, position=np_uext, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
783
784
        
        endif else begin ;uext data is present
55275be6   Ilyes Choubani   allowing no_obj p...
785
            
ed831104   Ilyes Choubani   no obj plotting
786
787
            ;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
788
                dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/positive_only, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
789
790
                
                ;Refreshing the positive_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
791
                dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/positive_only, /refresh ,position=p_uext, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
792
                
55275be6   Ilyes Choubani   allowing no_obj p...
793
              
bffa7018   Ilyes Choubani   update
794
                dustem_plot_dataset, st, dataset='UEXT', position=p_uext,/negative_only, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
795
                ;Refreshing the negative_only plot ONLY if there is data. If not do nothing
bffa7018   Ilyes Choubani   update
796
                dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT',/negative_only, /refresh ,position=p_uext, _extra=_extra
ed831104   Ilyes Choubani   no obj plotting
797
                
ed831104   Ilyes Choubani   no obj plotting
798
                
bffa7018   Ilyes Choubani   update
799
800
                dustem_plot_dataset, st, dataset='UEXT',/norm, position=np_uext, _extra=_extra ;I think nodata can also be uused too
                dustem_plot_dataset, st, dustem_uext,UEXT_spec, dataset='UEXT', /norm, /refresh,position=np_uext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
801
802
            
                      
ed831104   Ilyes Choubani   no obj plotting
803
804
805
806
      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
807
          dustem_plot_dataset, st, dataset='PSI_EXT', /nodata, position=p_psiext, _extra=_extra  
ed831104   Ilyes Choubani   no obj plotting
808
809
810

      endif else begin ;psi_ext exists

bffa7018   Ilyes Choubani   update
811
812
              dustem_plot_dataset, st, dataset='psi_ext', position=p_psiext, _extra=_extra 
              dustem_plot_dataset, st, dustem_psi_ext,PSIEXT_spec, dataset='psi_ext', /refresh ,position=p_psiext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
813
              
ed831104   Ilyes Choubani   no obj plotting
814
              
ed831104   Ilyes Choubani   no obj plotting
815
816
817
818
819
      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
820
821
          dustem_plot_dataset, st, dataset='polext', /nodata, position=p_pext, _extra=_extra 
          dustem_plot_dataset, st, dataset='polext', /nodata, /norm, position=np_pext, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
822
823
824

      endif else begin ;polext exists

bffa7018   Ilyes Choubani   update
825
826
        dustem_plot_dataset, st, dataset='polext', position=p_pext, _extra=_extra 
        dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
827
         
bffa7018   Ilyes Choubani   update
828
829
        dustem_plot_dataset, st, dataset='polext',/norm, position=np_pext, _extra=_extra  ;I think nodata can also be upolsed too
        dustem_plot_dataset, st, dustem_polext,POLEXT_spec, dataset='polext', /norm, /refresh,position=np_pext, _extra=_extra 
55275be6   Ilyes Choubani   allowing no_obj p...
830
        
ed831104   Ilyes Choubani   no obj plotting
831
832
833
834
835
      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
836
          dustem_plot_dataset, st, dataset='fpolext', /nodata, position=p_spext, _extra=_extra  
55275be6   Ilyes Choubani   allowing no_obj p...
837
          
ed831104   Ilyes Choubani   no obj plotting
838
839
840

      endif else begin ;fpolext exists

55275be6   Ilyes Choubani   allowing no_obj p...
841
        
bffa7018   Ilyes Choubani   update
842
843
        dustem_plot_dataset, st, dataset='fpolext', position=p_spext, _extra=_extra 
        dustem_plot_dataset, st, dustem_fpolext,SPEXT_spec,EXT_spec, dataset='fpolext', /refresh ,position=p_spext, _extra=_extra
55275be6   Ilyes Choubani   allowing no_obj p...
844

ed831104   Ilyes Choubani   no obj plotting
845

ed831104   Ilyes Choubani   no obj plotting
846
847
848
849
850
      endelse  
      

    ENDIF
        
ed831104   Ilyes Choubani   no obj plotting
851
852
853
854
855
     
          
ENDIF 


55275be6   Ilyes Choubani   allowing no_obj p...
856
857
;PLOTTING OF THE PARAMETERS
window,2,xpos=param_wxpos,ypos=param_wypos,xsize=param_wxsize,ysize=param_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot? 
f9089dc2   Ilyes Choubani   implementing the ...
858
859
dustem_plot_dataset, st, p_dim, errors,dataset='PARAMETERS',_extra=_extra ;& cmdind_prms+=1
dustem_plot_dataset, st,  p_dim,errors,dataset='PARAMETERS',/refresh, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
860

55275be6   Ilyes Choubani   allowing no_obj p...
861
;PLOTTING OF THE PLUGINS
ed831104   Ilyes Choubani   no obj plotting
862
IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN  
55275be6   Ilyes Choubani   allowing no_obj p...
863
864
    
    window,3,xpos=plugin_wxpos,ypos=plugin_wypos,xsize=plugin_wxsize,ysize=plugin_wysize,title='DUSTEMWRAP '+!dustem_version.version+' (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot? 
f9089dc2   Ilyes Choubani   implementing the ...
865
866
    dustem_plot_dataset, st, p_dim, errors,dataset='PLUGINS',_extra=_extra ;& cmdind_prms+=1
    dustem_plot_dataset, st, p_dim, errors,dataset='PLUGINS', /refresh , winid=winid_plgns, _extra=_extra 
ed831104   Ilyes Choubani   no obj plotting
867
868
869
870
871
872
     
ENDIF

the_end:

END