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, Distributed, Plotting, Mid-Level ; ; 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: ; ; ACCEPTED KEY-WORDS: ; help ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; Generates plots! ; ; 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 2022 ; Evolution details on the DustEMWrap gitlab. ; See http://dustemwrap.irap.omp.eu/ for FAQ and help. ;- 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. dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values),st=st ; 0/0 division case? ENDIF ;# Emission if not keyword_set(dustem_sed) and isa((*!dustem_data).sed) then begin ;better test? dustem_sed = dustem_compute_sed(p_dim,st=st,SED_spec=SED_spec) if !run_pol and tag_exist(*!dustem_show,'qsed') && !run_lin then begin dustem_polsed = dustem_compute_polsed(p_dim,st=st,P_spec=P_spec,SP_spec=SP_spec,dustem_polfrac=dustem_polfrac) toto = dustem_compute_stokes(p_dim,st=st,Q_spec=Q_spec,U_spec=U_spec,PSI_spec=PSI_spec,dustem_psi_em=dustem_psi_em) dustem_qsed = toto[0] dustem_used = toto[1] endif endif ;# Extinction if not keyword_set(dustem_ext) and isa((*!dustem_data).ext) then begin dustem_ext = dustem_compute_ext(p_dim,st=st,EXT_spec=EXT_spec) if !run_pol and tag_exist(*!dustem_show,'qext') && !run_lin then begin ;any polarization tag (qsed,used,qext,usext,polfrac) can be used for this test ;stop dustem_polext = dustem_compute_polext(p_dim,st=st,POLEXT_spec=POLEXT_spec,SPEXT_spec=SPEXT_spec,dustem_fpolext=dustem_fpolext) toto = dustem_compute_stokext(p_dim,st=st,QEXT_spec=QEXT_spec,UEXT_spec=UEXT_spec,PSIEXT_spec=PSIEXT_spec,dustem_psi_ext=dustem_psi_ext) dustem_qext = toto[0] dustem_uext = toto[1] endif endif 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 new_mouchard.qchi2=(*!dustem_fit).qchi2 new_mouchard.qrchi2=(*!dustem_fit).qrchi2 new_mouchard.uchi2=(*!dustem_fit).uchi2 new_mouchard.urchi2=(*!dustem_fit).urchi2 mouchard=[mouchard,new_mouchard] !iteration_mouchard=ptr_new(mouchard) ;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) ;All these tests exist so that the plotting of each data_set can be handled ;this is important for future releases. if !run_pol then begin if tag_exist(*!dustem_show,'qsed') then begin ;testing to account for the fact that the user can activate the !run_pol keyword without knowing ;ie: using a dust model with polarization test_polsed = isa((*!dustem_show).polsed) test_polfrac = isa((*!dustem_show).polfrac) test_qsed = isa((*!dustem_show).qsed) test_used = isa((*!dustem_show).used) test_psi_em = isa((*!dustem_show).psi_em) endif if tag_exist(*!dustem_show,'qext') then begin test_polext = isa((*!dustem_show).polext) test_psi_ext = isa((*!dustem_show).psi_ext) test_fpolext = isa((*!dustem_show).fpolext) test_qext = isa((*!dustem_show).qext) test_uext = isa((*!dustem_show).uext) endif if tag_exist(*!dustem_show,'qsed') then test_m = test_sed or test_polsed $ or test_polfrac or test_qsed $ or test_used or test_psi_em if tag_exist(*!dustem_show,'qext') then test_x = test_ext or test_polext $ or test_fpolext or test_qext $ or test_uext or test_psi_ext if ~tag_exist(*!dustem_show,'qsed') then test_m = test_sed if ~tag_exist(*!dustem_show,'qext') then test_x = test_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)' ;LOOPS OVER THE _EXTRA STRUCTURE AND RETRIEVES ;THE KEYWORDS PERTAINING TO EACH DATA SET. ;IT PLACES THEM IN A SYSTEM VARIABLE THAT IS ;ALWAYS REFRESHED (AFTER THIS CALL). dustem_set_plot_range,test_sed, test_ext,_extra= _extra ;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 ;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) * (*(*!dustem_fit).param_init_values) endif else begin errors = (*(*!dustem_fit).param_init_values)*0.;+la_undef();Initialized to 0 instead of la_undef() 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 ;==== These are arameters for window positioning if !run_pol and tag_exist(*!dustem_show,'qsed') then BEGIN ;qsed tag is sufficient for the test 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 if !run_pol and tag_exist(*!dustem_show,'qsed') 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 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 cgcontrol, winid_m, execute=0 ;cgset, winid_m ;#Displaying model string xxpos = 0.015 yypos = 0.97 ;#Displaying Hydrogen column density string 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 ;#Displaying of the number of iterations completed by the fitter xxpos = 0.015 yypos = 0.015 ;#Displaying frozen part of the string of number of iterations cgtext, xxpos, yypos,'Iteration : ',color=0,/normal,charsize = 1.35,/addcmd & cmdind_m+=1 ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen('Iteration : '))) ;#Displaying refreshed part of the string of number of iterations cgtext, xxpos, yypos,esc_txt+strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.25,/addcmd & cmdind_m+=1 ;#saving the command id to replace the refreshed command !dustemcgwin_ncmds.runs.pl = cmdind_m ;#plotting of (mostly) fixed data for rchi2 yypos = 0.97 ;#Displaying fixed part ;replacing the chi2 value (refreshed part of the string) by spaces esc_txt = strjoin(replicate(' ', strlen(strtrim(string(chi2,format=frmt2),2)))) cgtext, 0.985, yypos,textoidl('\chi^{2} : ')+esc_txt,color=0,/normal,charsize = 1.0,alignment=1.0,/addcmd & cmdind_m+=1 ;#Displaying refreshed part (first run . This is the command that will be replaced) ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen(textoidl('\chi^{2} : ')))) cgtext, 0.985, yypos,esc_txt+strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=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 yypos = 0.95 ;#Displaying fixed part ;replacing the rchi2 value (refreshed part of the string) by spaces esc_txt = strjoin(replicate(' ', strlen(strtrim(string(rchi2,format=frmt2),2)))) cgtext, 0.985, yypos,textoidl('r_{\chi^{2}} : ')+esc_txt,color=0,/normal,charsize = 1.35,alignment=1.0,/addcmd & cmdind_m+=1 ;#Displaying refreshed part (first run . This is the command that will be replaced) ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen(textoidl('r_{\chi^{2}} : ')))) cgtext, 0.985, yypos,esc_txt+strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=1.0,/addcmd & cmdind_m+=1 ;saving the command id to replace it !dustemcgwin_ncmds.rchi2.pl = cmdind_m ;Saving the title for the emission plot tit=!dustem_plot_range.title_m ;See if Annie and JP don't like plotting this on the bottom of the window cgtext, 0.5, 0.96,tit,color=0,/normal,charsize = 1.6,alignment=0.5,/addcmd & cmdind_m+=1 cgtext, 0.5, 0.015,'(RUNNING)',color=0,/normal,charsize = 1.6,/addcmd,alignment=0.5 & cmdind_m+=1 !dustemcgwin_ncmds.pltit.pl = cmdind_m endif else begin ;This is when the cgwindow exists already 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 xxpos = 0.985;1 - !dustemcgwin_ncmds.chi2.txtwdth - 0.03 yypos = 0.97 esc_txt = strjoin(replicate(' ', strlen(textoidl('\chi^{2} : ')))) cgwindow,'cgtext', xxpos , yypos,esc_txt+strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=1.0,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1 ;Refreshing rchi2 data: cmdin_m = !dustemcgwin_ncmds.rchi2.pl xxpos = 0.985;1 - !dustemcgwin_ncmds.rchi2.txtwdth - 0.03 yypos = 0.95 esc_txt = strjoin(replicate(' ', strlen(textoidl('r_{\chi^{2}} : ')))) cgwindow,'cgtext', xxpos , yypos,esc_txt+strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=1.0,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1 ;Refreshing number of runs data: cmdin_m = !dustemcgwin_ncmds.runs.pl xxpos = 0.015;0.03 + !dustemcgwin_ncmds.runs.txtwdth*1.35 ;(because of charsize) yypos = 0.015 esc_txt = strjoin(replicate(' ', strlen('Iteration : '))) if !dustem_iter.act eq 0 then txt = esc_txt+'Fit failed. ' else txt = esc_txt+strtrim(!dustem_iter.act,2) cgwindow,'cgtext', xxpos , yypos,txt,color=0,/normal,charsize = 1.25,/replacecmd,cmdindex=cmdin_m, winid=winid_m ;& cmdind_m+=1 ;update of the title here ? if !dustem_end EQ 1 then begin ;IF & ONLY IF we're at the last iteration (refreshing title) ;tit=!dustem_plot_range.title_m cmdin_m = !dustemcgwin_ncmds.pltit.pl xxpos = 0.5;!dustemcgwin_ncmds.pltit.txtwdth_m yypos = 0.015 cgwindow,'cgtext', xxpos , yypos,'(Final Run)',alignment=0.5,color=0,/normal,charsize = 1.6,/replacecmd,cmdindex=cmdin_m, winid=winid_m endif if !dustem_end EQ -1 then begin ;Adjusting title for subsequent displays to the end of the fit tit=!dustem_plot_range.title_m cmdind_m = !dustemcgwin_ncmds.pltit.pl xxpos = 0.5 yypos =0.96 cgwindow,'cgtext', xxpos , yypos,tit,color=0,/normal,charsize = 1.6,/replacecmd,alignment=0.5,cmdindex=cmdind_m-1, winid=winid_m ;this following/below call is needed so that the string disappears (string is '(FINAL RUN)' or '(RUNNING)') ;just to be safe yypos = 0.015 cgwindow,'cgtext', xxpos, yypos,'',color=0,/normal,charsize = 1.6,/replacecmd,alignment=0.5,cmdindex=cmdind_m, winid=winid_m ENDIF endelse if !run_pol and tag_exist(*!dustem_show,'qsed') 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.88] np_sed = [0.07,0.12,0.97,0.30] endelse plotsym,0,/fill if ~test_sed then begin ; SED data is not present (For completeness) 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 endif else begin ;SED exists if ~iswinsed then begin ;PLOTTING OF REFRESHED DATA ;REFRESHING DATA IN THE MAIN PLOT cmdind_m = !dustemcgwin_ncmds.sed.pl cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec,dataset='SED', /refresh ,position=p_sed, winid=winid_m,cmdindex=cmdind_m,/replacecmd,_extra=_extra ;REFRESHING DATA IN THE NORMALIZED PLOT cmdind_m = !dustemcgwin_ncmds.sed.nrm 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 endif else begin ; PLOTTING OF DATA THAT IS UNCHAED cgwindow,'dustem_plot_dataset', st, dataset='SED', position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 cgwindow,'dustem_plot_dataset', st, dustem_sed,SED_spec, dataset='SED', /refresh ,position=p_sed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 !dustemcgwin_ncmds.sed.pl = cmdind_m 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 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 !dustemcgwin_ncmds.sed.nrm = cmdind_m endelse endelse if !run_pol and tag_exist(*!dustem_show,'qsed') then begin if ~test_qsed then begin ;Qsed is not present 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 endif else begin ;Qsed data is present if ~iswinsed then begin cmdind_m = !dustemcgwin_ncmds.qsed.pl ;refreshing the positive_only and negative_only plots if data is present in them 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 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 cmdind_m = !dustemcgwin_ncmds.qsed.nrm 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 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) cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing 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 !dustemcgwin_ncmds.qsed.pl = cmdind_m cgwindow,'dustem_plot_dataset', st, dataset='QSED', position=p_qsed, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing 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 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 !dustemcgwin_ncmds.qsed.nrm = cmdind_m endelse endelse ;stop if ~test_used then begin ;used is not present 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 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 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 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 cmdind_m = !dustemcgwin_ncmds.used.nrm 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 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) cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/positive_only, _extra=_extra & cmdind_m+=1 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing 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 !dustemcgwin_ncmds.used.pl = cmdind_m cgwindow,'dustem_plot_dataset', st, dataset='USED', position=p_used, /addcmd, winid=winid_m,/negative_only, _extra=_extra & cmdind_m+=1 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing 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 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 !dustemcgwin_ncmds.used.nrm = cmdind_m endelse endelse if ~test_psi_em then begin ; psi_em data is not present (For completeness) # This is only valid when !run_pol=1 cgwindow,'dustem_plot_dataset', st, dataset='psi_em', /nodata, position=p_psised, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 endif else begin ;psi_em exists ;stop if ~iswinsed then begin cmdind_m = !dustemcgwin_ncmds.psi_em.pl 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 endif else begin ;stop 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 !dustemcgwin_ncmds.psi_em.pl = cmdind_m endelse endelse if ~test_polsed then begin ; polsed data is not present (For completeness) # This is only valid when !run_pol=1 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 endif else begin ;polsed exists if ~iswinsed then begin cmdind_m = !dustemcgwin_ncmds.polsed.pl cgwindow,'dustem_plot_dataset', st, dustem_polsed,P_spec, dataset='polsed', /refresh ,position=p_psed, winid=winid_m,/replacecmd,cmdindex=cmdind_m, _extra=_extra cmdind_m = !dustemcgwin_ncmds.polsed.nrm 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 endif else begin ;stop 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 !dustemcgwin_ncmds.polsed.pl = cmdind_m 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 !dustemcgwin_ncmds.polsed.nrm = cmdind_m endelse endelse if ~test_polfrac then begin ; polfrac data is not present (For completeness) # This is only valid when !run_pol=1 cgwindow,'dustem_plot_dataset', st, dataset='polfrac', /nodata, position=p_spsed, /addcmd, winid=winid_m, _extra=_extra & cmdind_m+=1 endif else begin ;polfrac exists if ~iswinsed then begin cmdind_m = !dustemcgwin_ncmds.polfrac.pl 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 endif else begin ;stop 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 !dustemcgwin_ncmds.polfrac.pl = cmdind_m endelse endelse ENDIF cgcontrol, winid_m, execute=1 ENDIF ;stop if test_x then begin ;Generating extinction window and saving window ID if iswinext then begin ; fixed data if !run_pol and tag_exist(*!dustem_show,'qext') 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 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 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,/addcmd & cmdind_x+=1 ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen('Iteration : '))) ;Displaying refreshed part (first run . This is the command that will be replaced) cgtext, xxpos, yypos,esc_txt+strtrim(!dustem_iter.act,2),color=0,/normal,charsize = 1.25,/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. yypos = 0.97 ;Displaying fixed part ;replacing the chi2 value (refreshed part of the string) by spaces esc_txt = strjoin(replicate(' ', strlen(strtrim(string(chi2,format=frmt2),2)))) cgtext, 0.985, yypos,textoidl('\chi^{2} : ')+esc_txt,color=0,/normal,charsize = 1.0,alignment=1.0,/addcmd & cmdind_x+=1 ;Displaying refreshed part (first run . This is the command that will be replaced) ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen(textoidl('\chi^{2} : ')))) cgtext, 0.985, yypos,esc_txt+strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=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 yypos = 0.95 ;Displaying fixed part ;relpacing the rchi2 value (refreshed part of the string) by spaces esc_txt = strjoin(replicate(' ', strlen(strtrim(string(rchi2,format=frmt2),2)))) cgtext, 0.985, yypos,textoidl('r_{\chi^{2}} : ')+esc_txt,color=0,/normal,charsize = 1.35,alignment=1.0,/addcmd & cmdind_x+=1 ;Displaying refreshed part (first run . This is the command that will be replaced) ;generating the equivalent escape string for the frozen part of the string esc_txt = strjoin(replicate(' ', strlen(textoidl('r_{\chi^{2}} : ')))) cgtext, 0.985, yypos,strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=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)) ;Saving the title for the extinction plot tit=!dustem_plot_range.title_x; cgtext, 0.5, 0.96,tit,color=0,/normal,charsize = 1.6,alignment=0.5,/addcmd & cmdind_x+=1 ;plotting the status on the bottom of the display window cgtext, 0.5, 0.015,'(RUNNING)',color=0,/normal,charsize = 1.6,alignment=0.5,/addcmd & cmdind_x+=1 !dustemcgwin_ncmds.pltit.pl = cmdind_x endif else begin ; refreshed runs 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: cmdind_x = !dustemcgwin_ncmds.chi2.pl xxpos = 0.985;1 - !dustemcgwin_ncmds.chi2.txtwdth - 0.03 yypos = 0.97 esc_txt = strjoin(replicate(' ', strlen(textoidl('\chi^{2} : ')))) cgwindow,'cgtext', xxpos , yypos,esc_txt+strtrim(string(chi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1 ;Refreshing rchi2 data: cmdind_x = !dustemcgwin_ncmds.rchi2.pl xxpos = 0.985;1 - !dustemcgwin_ncmds.rchi2.txtwdth - 0.03 yypos = 0.95 esc_txt = strjoin(replicate(' ', strlen(textoidl('r_{\chi^{2}} : ')))) cgwindow,'cgtext', xxpos , yypos,esc_txt+strtrim(string(rchi2,format=frmt2),2),color=0,/normal,charsize = 1.0,alignment=1.0,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1 ;Refreshing number of runs data: cmdind_x = !dustemcgwin_ncmds.runs.pl xxpos = 0.015; 0.03 + !dustemcgwin_ncmds.runs.txtwdth*1.35 ;(because of charsize) yypos = 0.015 esc_txt = strjoin(replicate(' ', strlen('Iteration : '))) if !dustem_iter.act eq 0 then txt = esc_txt+'Fit failed. ' else txt = esc_txt+strtrim(!dustem_iter.act,2) cgwindow,'cgtext', xxpos , yypos,txt,color=0,/normal,charsize = 1.25,/replacecmd,cmdindex=cmdind_x, winid=winid_x ;& cmdind_m+=1 ;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) if !dustem_end EQ 1 then begin ;IF & ONLY IF we're at the last iteration ;tit=!dustem_plot_range.title_x cmdind_x = !dustemcgwin_ncmds.pltit.pl xxpos = 0.5;!dustemcgwin_ncmds.pltit.txtwdth_x yypos = 0.015 cgwindow,'cgtext', xxpos , yypos,' (Final Run)',alignment=0.5,color=0,/normal,charsize = 1.6,/replacecmd,cmdindex=cmdind_x, winid=winid_x endif if !dustem_end EQ -1 then begin ; tit=!dustem_plot_range.title_x cmdind_x = !dustemcgwin_ncmds.pltit.pl xxpos = 0.5 yypos =0.96 cgwindow,'cgtext', xxpos , yypos,tit,color=0,/normal,charsize = 1.6,/replacecmd,alignment=0.5,cmdindex=cmdind_x-1, winid=winid_x cgwindow,'cgtext', xxpos, 0.015,'',color=0,/normal,charsize = 1.6,/replacecmd,alignment=0.5,cmdindex=cmdind_x, winid=winid_x ENDIF endelse ;cgWindow_GetDefs,xsize=xsize,ysize=ysize ;cgcontrol, resize=[xsize,ysize] if !run_pol and tag_exist(*!dustem_show,'qext') 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 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 endif else begin ;EXT exists if ~iswinext then begin ; refreshed runs cmdind_x = !dustemcgwin_ncmds.ext.pl cgwindow,'dustem_plot_dataset', st, dustem_ext,EXT_spec,dataset='EXT', /refresh ,position=p_ext, winid=winid_x,cmdindex=cmdind_x,/replacecmd,_extra=_extra cmdind_x = !dustemcgwin_ncmds.ext.nrm 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 endif else begin ;fixed runs 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 !dustemcgwin_ncmds.ext.pl = cmdind_x 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 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 !dustemcgwin_ncmds.ext.nrm = cmdind_x endelse endelse if !run_pol and tag_exist(*!dustem_show,'qext') then begin if ~test_qext then begin ;Qext is not present 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 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 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 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 cmdind_x = !dustemcgwin_ncmds.qext.nrm 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 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) cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing 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 !dustemcgwin_ncmds.qext.pl = cmdind_x cgwindow,'dustem_plot_dataset', st, dataset='QEXT', position=p_qext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing 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 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 !dustemcgwin_ncmds.qext.nrm = cmdind_x endelse endelse ;stop if ~test_uext then begin ;uext is not present 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 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 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 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 cmdind_x = !dustemcgwin_ncmds.uext.nrm 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 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) cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/positive_only, _extra=_extra & cmdind_x+=1 ;Refreshing the positive_only plot ONLY if there is data. If not do nothing 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 !dustemcgwin_ncmds.uext.pl = cmdind_x cgwindow,'dustem_plot_dataset', st, dataset='UEXT', position=p_uext, /addcmd, winid=winid_x,/negative_only, _extra=_extra & cmdind_x+=1 ;Refreshing the negative_only plot ONLY if there is data. If not do nothing 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 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 !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 cgwindow,'dustem_plot_dataset', st, dataset='PSI_EXT', /nodata, position=p_psiext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 endif else begin ;psi_ext exists if ~iswinext then begin cmdind_x = !dustemcgwin_ncmds.psi_ext.pl 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 endif else begin ;stop 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 !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 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 endif else begin ;polext exists if ~iswinext then begin cmdind_x = !dustemcgwin_ncmds.polext.pl cgwindow,'dustem_plot_dataset', st, dustem_polext,POLEXT_spec, dataset='polext', /refresh ,position=p_pext, winid=winid_x,/replacecmd,cmdindex=cmdind_x, _extra=_extra cmdind_x = !dustemcgwin_ncmds.polext.nrm 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 endif else begin ;stop 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 !dustemcgwin_ncmds.polext.pl = cmdind_x 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 !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 cgwindow,'dustem_plot_dataset', st, dataset='fpolext', /nodata, position=p_spext, /addcmd, winid=winid_x, _extra=_extra & cmdind_x+=1 endif else begin ;fpolext exists if ~iswinext then begin cmdind_x = !dustemcgwin_ncmds.fpolext.pl 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 endif else begin 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 !dustemcgwin_ncmds.fpolext.pl = cmdind_x endelse endelse ENDIF cgcontrol, winid_x, execute=1 ENDIF if !dustem_end then !dustem_end = -1 ;so that the last iteration is only plotted once. 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 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PARAMETERS', /refresh, winid=winid_prms,/replacecmd,cmdindex=cmdind_prms, _extra=_extra cgcontrol, winid_prms ,execute=1 ENDIF ELSE BEGIN ;(FIRST RUN) 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? ; cgwindow,wxsize=350,wysize=200,wtitle='DUSTEMWRAP v2.0 (PARAMETERS)' ; keeping the same y dimension of the emission/extinction plot? 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 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PARAMETERS', /addcmd , winid=winid_prms,_extra=_extra ;& cmdind_prms+=1 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PARAMETERS', /addcmd, /refresh , winid=winid_prms, _extra=_extra & cmdind_prms+=1 !dustemcgwin_ncmds.prms.pl = cmdind_prms cgcontrol, winid_prms ,execute=1 ENDELSE IF (tag_names(*!dustem_plugin))(0) NE 'NONE' THEN BEGIN 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 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PLUGINS', /refresh, winid=winid_plgns,/replacecmd,cmdindex=cmdind_plgns, _extra=_extra cgcontrol, winid_plgns ,execute=1 ENDIF ELSE BEGIN ;(FIRST RUN) 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? ;cgwindow,wxsize=350,wysize=200,wtitle='DUSTEMWRAP v2.0 (PLUGINS)' ; keeping the same y dimension of the emission/extinction plot? 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 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PLUGINS', /addcmd , winid=winid_plgns,_extra=_extra ;& cmdind_prms+=1 cgwindow,'dustem_plot_dataset', st, p_dim, errors,dataset='PLUGINS', /addcmd, /refresh , winid=winid_plgns, _extra=_extra & cmdind_plgns+=1 !dustemcgwin_ncmds.plgns.pl = cmdind_plgns cgcontrol, winid_plgns ,execute=1 ENDELSE ENDIF the_end: END