Commit 76e4d27f01ee0151454e57ee4406f65c354b6433
Exists in
master
Merge branch 'master' of https://gitlab.irap.omp.eu/OV-GSO-DC/dustem-wrapper_idl
Showing
7 changed files
with
967 additions
and
172 deletions
Show diff stats
... | ... | @@ -0,0 +1,32 @@ |
1 | +FUNCTION dstmwrp_exp, axis, index, number | |
2 | + | |
3 | +;IC: modified so that a '1' isn't displayed before the values | |
4 | + | |
5 | + ;A special case. | |
6 | + IF number EQ 0 THEN RETURN, '0' | |
7 | + | |
8 | + ; Assuming multiples of 10 with format. | |
9 | + ex = String(number, Format='(e8.0)') | |
10 | + pt = StrPos(ex, '.') | |
11 | + | |
12 | + first = StrMid(ex, 0, pt) | |
13 | + sign = StrMid(ex, pt+2, 1) | |
14 | + thisExponent = StrMid(ex, pt+3) | |
15 | + | |
16 | + ; Shave off leading zero in exponent | |
17 | + WHILE StrMid(thisExponent, 0, 1) EQ '0' DO thisExponent = StrMid(thisExponent, 1) | |
18 | + | |
19 | + ; Fix for sign and missing zero problem. | |
20 | + IF (Long(thisExponent) EQ 0) THEN BEGIN | |
21 | + sign = '' | |
22 | + thisExponent = '0' | |
23 | + ENDIF | |
24 | + | |
25 | + ; Make the exponent a superscript. | |
26 | + IF sign EQ '-' THEN BEGIN | |
27 | + IF first EQ 1 then RETURN, '10!U' + sign + thisExponent + '!N' ELSE RETURN, first + 'x10!U' + sign + thisExponent + '!N' | |
28 | + ENDIF ELSE BEGIN | |
29 | + IF first EQ 1 then RETURN, '10!U' + thisExponent + '!N' ELSE RETURN, first + 'x10!U' + thisExponent + '!N' | |
30 | + ENDELSE | |
31 | + | |
32 | +END | |
0 | 33 | \ No newline at end of file | ... | ... |
src/idl/dustem_compute_polsed.pro
... | ... | @@ -99,10 +99,10 @@ P=sqrt(Q_spec^2+U_spec^2) |
99 | 99 | |
100 | 100 | ENDIF |
101 | 101 | |
102 | -IF isa(!dustem_data.polsed) THEN dustem_polsed = (*!dustem_data.polsed).values * 0. ELSE dustem_polsed = (*!dustem_data.polfrac).values * 0. | |
103 | -;stop | |
104 | 102 | |
105 | -if not isarray(P) THEN stop | |
103 | +dustem_polsed = (*!dustem_data.qsed).values * 0. | |
104 | + | |
105 | +if not isarray(P) THEN stop ;I don't understand this test. The only thing it can indicate is a problem with the dust parameters or the fortran executable. But in my opinion these tests would be | |
106 | 106 | |
107 | 107 | |
108 | 108 | IF !dustem_do_cc NE 0 AND !dustem_never_do_cc EQ 0 THEN BEGIN |
... | ... | @@ -111,10 +111,10 @@ ENDIF ELSE BEGIN |
111 | 111 | message,'SKIPPING color correction calculations',/info |
112 | 112 | ENDELSE |
113 | 113 | |
114 | -IF isa(!dustem_data.polsed) THEN ind_polsed=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',count_polsed) ELSE ind_polsed=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',count_polsed) | |
114 | +ind_polsed=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM',count_polsed) | |
115 | 115 | |
116 | 116 | IF count_polsed NE 0 THEN BEGIN |
117 | - IF isa(!dustem_data.polsed) THEN filter_names=((*!dustem_data.polsed).filt_names)(ind_polsed) ELSE filter_names=((*!dustem_data.polfrac).filt_names)(ind_polsed) | |
117 | + filter_names=((*!dustem_data.qsed).filt_names)(ind_polsed) | |
118 | 118 | spolsed=dustem_cc(stp.polsed.wav,P,filter_names,cc=cc) |
119 | 119 | dustem_polsed[ind_polsed]=spolsed |
120 | 120 | ENDIF |
... | ... | @@ -126,10 +126,9 @@ ENDIF |
126 | 126 | ;Linear interpolation leads to wrong values, in particular where few |
127 | 127 | ;wavelengths points exist in the model (long wavelengths). |
128 | 128 | |
129 | -IF isa(!dustem_data.polsed) THEN ind_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',count_spec) ELSE ind_spec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',count_spec) | |
130 | -IF count_spec NE 0 THEN BEGIN | |
131 | - IF isa(!dustem_data.polsed) THEN dustem_polsed(ind_spec)=interpol(P,stp.polsed.wav,(((*!dustem_data.polsed).wav)(ind_spec))) ELSE dustem_polsed(ind_spec)=interpol(P,stp.polsed.wav,(((*!dustem_data.polfrac).wav)(ind_spec))) | |
132 | -ENDIF | |
129 | +ind_spec=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM',count_spec) | |
130 | +IF count_spec NE 0 THEN dustem_polsed(ind_spec)=interpol(P,stp.polsed.wav,(((*!dustem_data.qsed).wav)(ind_spec))) | |
131 | + | |
133 | 132 | out_st=stp |
134 | 133 | |
135 | 134 | ... | ... |
src/idl/dustem_fit_sed deleted
... | ... | @@ -1,150 +0,0 @@ |
1 | -PRO dustem_fit_sed&polsed&polext_NY | |
2 | - | |
3 | - | |
4 | -;Thanks for this! You're the first user that can give me actual feedback. | |
5 | -;I realized that there is plenty of work that still needs to be done. | |
6 | -;The wrapper is a war zone at the moment but we're getting there. | |
7 | - | |
8 | - | |
9 | -dustem_define_la_common ;Enables the wrapper to use a value called la_undef() | |
10 | -;which is how the wrapper recognizes undefined values. | |
11 | -;This value equals -32768 and should be present in your xcat files for all the values that you wish to omit from the fit. | |
12 | -;Setting unused/unwanted values/errors to zero is highly unrecommended (unless your case makes it reasonable to assume a null flux value. ie StokesQ = 0. for some band) | |
13 | -;I'm still working w/ JP on this so you shouldn't really worry about this. | |
14 | - | |
15 | - | |
16 | -;☆☆☆DUSTEM INITIALIZATION☆☆☆ | |
17 | -model='THEMIS' | |
18 | -dustem_init,mode=model,/pol | |
19 | - | |
20 | -!dustem_verbose=1 | |
21 | -!dustem_show_plot=1 | |
22 | - | |
23 | -;☆☆☆READING THE DATA☆☆☆ | |
24 | -dir_seds = '/Users/ilyeschoubani/Downloads/test_wrap_NY/' | |
25 | - | |
26 | -;###README### | |
27 | -;If the format of the SED is the new one (the current one), one just needs to read the xcat file. | |
28 | -;Otherwise, a procedure called dustem_old2new_sed_format.pro does the trick. That is what I used for your SED xcat file. | |
29 | -;This new format has been adjusted so that the data pertaining to the polarized emission is included in the SED (primary/main) structure. | |
30 | -;In other words, the polarization SED should also be there, which isn't our case since the polarization SED is in a seperate xcat file. | |
31 | -;Because of that, we will be reading the SED (which has the new format now) and fill the polarization-related tags (ie: P,p,their associated variances etc...) by reading their xcat files first (in our case we just have polsed). | |
32 | - | |
33 | -;☆☆☆Reading the SED xcat that has the new format☆☆☆ | |
34 | -str_sed = dir_seds+'SED_HD21.xcat' ;It has the same name because the old one has 'old' attached to its string now (after running the aforementioned procedure). | |
35 | -sed = read_xcat(str_sed,/silent) | |
36 | - | |
37 | -;☆☆☆Reading the POLSED xcat and including its data in the (primary/main) sed structure☆☆☆ | |
38 | - | |
39 | -;☆☆☆reading polsed xcat file☆☆☆ | |
40 | -str_polsed = dir_seds+'POLSED_HD21.xcat' | |
41 | -polsed = read_xcat(str_polsed,/silent) | |
42 | - | |
43 | -;☆☆☆now adding its content to the SED main structure☆☆☆ | |
44 | -match, sed.wave, polsed.wave, subsed, subpolsed | |
45 | -sed(subsed).LARGEP = polsed(subpolsed).spec | |
46 | -sed(subsed).sigma_LARGEP = polsed(subpolsed).error^2 ;The squared error value here is because the wrapper uses variances now. When preparing to fit,the wrapper computes the square root of this value so don't be alarmed as the error remains the same. | |
47 | - | |
48 | -;###README: | |
49 | -;The wrapper follows the same formalism when it comes to the handling of the extinction data. | |
50 | -;Meaning there is also a (primary/main) structure for extinction that also contains data pertaining to polarization (cross-section in the case of polext). | |
51 | -;Since we do not have extinction data (only Serkowski), we should read the Serkowski xcat file, and use its content to create a fake extinction (primary/main) procedure. | |
52 | -;The creation of this fake extinction procedure is necessary for dustem to be aware of the polext data. | |
53 | -;However I never implemented this before. By 'this' I mean the way the wrapper fits polext without the presence of ext. | |
54 | -;This means that your work has enabled us to think about a very important issue. | |
55 | - | |
56 | - | |
57 | -;☆☆☆The first thing we do is read the Serkowski xcat file that has the new format☆☆☆ | |
58 | -;###README: | |
59 | -;I used a procedure called dustem_old2new_sed_format.pro that does the job. | |
60 | -;This means that I have created the (primary/main) extinction structure with the Serkowski xcat file. | |
61 | -;The lines below are witness to the necessary changes that need to be made so that said structure includes the polext data. | |
62 | - | |
63 | -;☆☆☆Reading the POLEXT xcat file☆☆☆ | |
64 | -str_polext = dir_seds+'Serkowski_HD21.xcat' | |
65 | -ext = read_xcat(str_polext,/silent) | |
66 | - | |
67 | - | |
68 | -;☆☆☆Modifying the extinction structure and placing the polext data inside it☆☆☆ | |
69 | -ext.instru = 'EXTINCTION' | |
70 | -ext.EXT_P = ext.EXT_I | |
71 | -ext.SIGEXTP = ext.SIGEXTII | |
72 | -ext.EXT_I = la_undef(4) | |
73 | -ext.SIGEXTII = la_undef(4) | |
74 | - | |
75 | -;=== Set which parameters you want to fit | |
76 | -pd = [ $ | |
77 | - '(*!dustem_params).gas.G0', $ ;G0 | |
78 | - '(*!dustem_params).grains(0).mdust_o_mh', $ | |
79 | - '(*!dustem_params).grains(1).mdust_o_mh', $ | |
80 | - '(*!dustem_params).grains(2).mdust_o_mh' $ | |
81 | - ] | |
82 | - | |
83 | - | |
84 | -iv = [0.17E-02,0.63E-03,0.51E-02] | |
85 | - | |
86 | -Npar=n_elements(pd) | |
87 | - | |
88 | -ulimed=replicate(0,Npar) | |
89 | - | |
90 | -llimed=replicate(1,Npar) | |
91 | -llims=replicate(0,Npar) | |
92 | - | |
93 | -dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims | |
94 | - | |
95 | -dustem_init_plugins,pd | |
96 | - | |
97 | -st=dustem_set_data(sed=sed,ext=ext,rchi2_weight=rchi2_weight,f_HI=f_HI) | |
98 | - | |
99 | - | |
100 | -;=== RUN fit | |
101 | -tol=1.e-6 | |
102 | -xtol=1.e-6 | |
103 | -Nitermax=30; just an initialization | |
104 | - | |
105 | -xr=[1.,5e5] | |
106 | -yr=[1e-2,1.00e8] | |
107 | - | |
108 | -loadct,13 | |
109 | - | |
110 | -title=textoidl('TEST_SED') | |
111 | -ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') | |
112 | -t1=systime(0,/sec) | |
113 | -res=dustem_mpfit_data(tol=tol,xtol=xtol,Nitermax=Nitermax,xr=xr,/xstyle,yr=yr,/ysty,/ylog,/xlog,xtit=xtit,ytit=ytit,title=title) | |
114 | -t2=systime(0,/sec) | |
115 | - | |
116 | - | |
117 | -;=== SAVE FIT RESULTS | |
118 | -file_out='/tmp/DUSTEM_polsed_fit_example.sav' | |
119 | -dustem_save_system_variables,file_out | |
120 | -message,'Saved '+file_out,/continue | |
121 | - | |
122 | -;====================================== | |
123 | -;====You can exit IDL here and re-enter - THIS PART APPEARS TO BE FAULTY. NEEDS INVESTIGATION | |
124 | -;====================================== | |
125 | -file='/tmp/DUSTEM_polsed_fit_example.sav' | |
126 | -dustem_restore_system_variables,file | |
127 | - | |
128 | -;=== Plot best fit | |
129 | -win=1 | |
130 | -window,win & win=win+1 | |
131 | - | |
132 | -;=== recover best fit values | |
133 | -res=*(*!dustem_fit).current_param_values | |
134 | -chi2=(*!dustem_fit).chi2 | |
135 | -rchi2=(*!dustem_fit).rchi2 | |
136 | -;errors=*(*!dustem_fit).current_param_errors | |
137 | -;errors=(*(*!dustem_fit).current_param_errors)*(*(*!dustem_fit).param_init_values) | |
138 | - | |
139 | -;=== Plot best fit | |
140 | - | |
141 | -loadct,13 | |
142 | - | |
143 | -dustem_sed_plot,*(*!dustem_fit).current_param_values,ytit=ytit,xtit=xtit,title=title,yr=yr,xr=xr,/ysty,/xsty,res=res,chi2=chi2,rchi2=rchi2,/xlog,/ylog,/pol,ps=ps,png=png | |
144 | - | |
145 | -print,'dustem_mpfit_sed executed in ',t2-t1,' sec' | |
146 | - | |
147 | -the_end: | |
148 | - | |
149 | -END | |
150 | - |
src/idl/dustem_init.pro
... | ... | @@ -47,6 +47,14 @@ PRO dustem_init,dir=dir,wraptest=wraptest,plot_it=plot_it,model=model,help=help, |
47 | 47 | ; see evolution details on the dustem cvs maintained at CESR |
48 | 48 | ;- |
49 | 49 | |
50 | +;IC | |
51 | +;I think this procedure should be throughly revised. (and also the rest of the code corrected) | |
52 | +;Pointers are used when the need does not present itself. | |
53 | +;ie: defsysv, '!dustem_fit', ptr_new(dustem_fit_st), defsysv,'!dustem_inputs',ptr_new() or defsysv,'!dustem_params',ptr_new() which don't require initialization for instance | |
54 | + | |
55 | + | |
56 | + | |
57 | + | |
50 | 58 | IF keyword_set(help) THEN BEGIN |
51 | 59 | doc_library,'dustem_init' |
52 | 60 | goto,the_end |
... | ... | @@ -106,9 +114,9 @@ if keyword_set(pol) then begin |
106 | 114 | defsysv, '!dustem_data', { $ ;Data to fit |
107 | 115 | sed: ptr_new(), $ |
108 | 116 | ext: ptr_new(), $ |
109 | - polext: ptr_new(), $ | |
110 | - ;polsed: ptr_new(), $ ;newly deprecated | |
111 | - ;polfrac: ptr_new(), $ ;newly deprecated | |
117 | + polext: ptr_new(), $ ; | |
118 | + polsed: ptr_new(), $ ; changes in dustem_set_data/check_data to be made!!! | |
119 | + polfrac: ptr_new(), $ ; | |
112 | 120 | qsed: ptr_new(), $ |
113 | 121 | used: ptr_new(), $ |
114 | 122 | qext: ptr_new(), $ |
... | ... | @@ -116,7 +124,7 @@ if keyword_set(pol) then begin |
116 | 124 | } |
117 | 125 | |
118 | 126 | ;rchi2_weight = {sed: 0.,ext: 0.,polext: 0.,polsed: 0.,polfrac:0.,qsed:0.,used:0.,qext:0.,uext:0.} ;polsed and polfrac newly deprecated |
119 | - rchi2_weight = {sed: 0.,ext: 0.,polext: 0.,qsed:0.,used:0.,qext:0.,uext:0.} | |
127 | + rchi2_weight = {sed: 0.,ext: 0.,qsed:0.,used:0.,qext:0.,uext:0.} | |
120 | 128 | endif else begin |
121 | 129 | defsysv, '!dustem_data', { $ ;Data to fit |
122 | 130 | sed: ptr_new(), $ |
... | ... | @@ -149,9 +157,18 @@ defsysv,'!dustem_show', { $ ;Data to fit |
149 | 157 | uext: ptr_new() $ |
150 | 158 | } |
151 | 159 | |
152 | -;defsysv, '!dustem_psi',0. ;TO BE DEPRECTED... CHECK IF U STARTED IMPLEMENTING THIS ;0 is default. Meanin No PSI value(s) detected in the data xcat file. | |
153 | - | |
154 | 160 | |
161 | +defsysv, '!dustemcgwin_id', { $ ;IDs of windows to plot | |
162 | + sed: la_undef(), $ | |
163 | + ext: la_undef() $ | |
164 | + } | |
165 | + | |
166 | +defsysv, '!dustemcgwin_ncmds', { $ ;Keeping track of number of commands run. | |
167 | + sed: {ct_z1:0,ct_z2:0,ct_z3:0,ct_z4:0,ct_z5:0,ct_z6:0}, $ | |
168 | + ext: {ct_z1:0,ct_z2:0,ct_z3:0,ct_z4:0,ct_z5:0,ct_z6:0} $ | |
169 | + } | |
170 | + | |
171 | + | |
155 | 172 | ;IDL> help,*!dustem_data,/str |
156 | 173 | ;** Structure <2173b20>, 4 tags, length=448, data length=448, refs=1: |
157 | 174 | ; INSTRU_NAMES STRING Array[14] |
... | ... | @@ -186,7 +203,6 @@ defsysv, '!dustem_params', ptr_new() ;Contains the values of all Desert Model pa |
186 | 203 | ; 2:call to dustem_create_ionfrac with the SIZE_xxx.DAT files |
187 | 204 | ;ENDIF |
188 | 205 | |
189 | - | |
190 | 206 | defsysv,'!dustem_filters',ptr_new() ;filter information (filled by dustem_filter_init.pro) |
191 | 207 | ;; IDL> help,*!dustem_filters,/str |
192 | 208 | ;; ** Structure <1b95608>, 17 tags, length=8232, data length=8118, refs=1: |
... | ... | @@ -270,7 +286,7 @@ defsysv, '!dustem_model', model |
270 | 286 | (*!dustem_inputs).grain='GRAIN_NY_MODELA.DAT' |
271 | 287 | (*!dustem_inputs).align='ALIGN_G17_MODELA.DAT' |
272 | 288 | END |
273 | - ;This is a user-defined model | |
289 | + ;This is a user-defined model ;This will prolly have to get modified. | |
274 | 290 | 'USER_MODEL':BEGIN |
275 | 291 | (*!dustem_inputs).grain='GRAIN_USER.DAT' |
276 | 292 | END | ... | ... |
src/idl/dustem_mask_data.pro
1 | 1 | FUNCTION dustem_mask_data,data_struct,omit=omit,data_set=data_set,help=help |
2 | +;+ | |
3 | +; NAME: | |
4 | +; dustem_mask_data | |
5 | +; PURPOSE: | |
6 | +; Removing filters from a data structure. | |
7 | +; CATEGORY: | |
8 | +; DUSTEM Wrapper | |
9 | +; CALLING SEQUENCE: | |
10 | +; data_struct=dustem_mask_data(data_struct,omit=,data_set=) | |
11 | +; INPUTS: | |
12 | +; data_struct=read_xcat(file,/silent). Data structure formatted as outlined in the DustermWrap Users' Guide | |
13 | +; data_set : Array of character strings containing the different data sets to be filtered. | |
14 | +; ie: ['SED'],['QSED'],'USED'] or just ['QSED'] for example. The use of ['STOKESI','STOKESQ','STOKESU'] instead is equivalent. | |
15 | +; omit : Can be an array or list. In both cases it should contain the filter names as character strings. | |
16 | +; ie: omit=['SPIRE1','SPIRE2'] for an array or omit=list(['SPIRE2','SPIRE1','PACS2'],['HFI5','HFI4']) for a list. | |
17 | +; When using a list, its shape (dimension) should be the number of elements of the data_set array. | |
18 | +; ie: Each dimension is an array of filters to be removed from the corresponding data set in the data_set array. | |
19 | +; OPTIONAL INPUT PARAMETERS: | |
20 | +; None | |
21 | +; OUTPUTS: | |
22 | +; data_struct | |
23 | +; OPTIONAL OUTPUT PARAMETERS: | |
24 | +; None | |
25 | +; ACCEPTED KEY-WORDS: | |
26 | +; help = if set, prints this help | |
27 | +; COMMENTS | |
28 | +; Both list and array entries for omit and hide keywords are allowed. | |
29 | +; MODIFICATION HISTORY: | |
30 | +; Written by IC | |
31 | +;- | |
2 | 32 | |
3 | 33 | |
4 | 34 | IF keyword_set(help) THEN BEGIN |
... | ... | @@ -61,8 +91,8 @@ IF keyword_set(data_struct) and keyword_set(omit) THEN BEGIN |
61 | 91 | ind0[i] = arr_i ;Indices of the filters to be removed in the data structure |
62 | 92 | endfor |
63 | 93 | |
64 | - eq_tags = ['STOKESI','EXT_I','EXT_P','STOKESQ','STOKESU','EXT_Q','EXT_U'] | |
65 | - errvec = ['SIGMAII','SIGEXTI','SIGEXTP','SIGMAQQ','SIGMAUU','SIGEXTQ','SIGEXTU'] | |
94 | + eq_tags = ['STOKESI','EXT_I','EXT_P','','','','','STOKESQ','STOKESU','EXT_Q','EXT_U'] | |
95 | + errvec = ['SIGMAII','SIGEXTI','SIGEXTP','','','','','SIGMAQQ','SIGMAUU','SIGEXTQ','SIGEXTU'] | |
66 | 96 | |
67 | 97 | IF keyword_set(data_set) then begin |
68 | 98 | for i=0L,n_elements(data_set)-1 do begin | ... | ... |
src/idl/dustem_mpfit_run.pro
... | ... | @@ -131,11 +131,14 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN |
131 | 131 | ; Plot if needed |
132 | 132 | IF !dustem_show_plot NE 0 THEN BEGIN |
133 | 133 | |
134 | - window,win,title='DUSTEM WRAP (SED)' | |
134 | + ;window,win,title='DUSTEM WRAP (SED)' | |
135 | 135 | |
136 | 136 | ;cgwindow,WMULTI=[2,2,1],/CURRENT |
137 | - | |
138 | - dustem_plot_fit_sed,st,dustem_sed,_extra=_extra,res=p_min*(*(*!dustem_fit).param_init_values),chi2=(*!dustem_fit).chi2,rchi2=(*!dustem_fit).rchi2,fpol=fpol | |
137 | + | |
138 | + | |
139 | + dustemwrap_plot,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra | |
140 | + ;dustemwrap_plott,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra | |
141 | + ;dustem_plot_fit_sed,st,dustem_sed,_extra=_extra,res=p_min*(*(*!dustem_fit).param_init_values),chi2=(*!dustem_fit).chi2,rchi2=(*!dustem_fit).rchi2,fpol=fpol | |
139 | 142 | |
140 | 143 | ENDIF |
141 | 144 | ... | ... |
... | ... | @@ -0,0 +1,865 @@ |
1 | +PRO dustemwrap_plot,p_dim,st,dustem_sed,dustem_polsed,dustem_qsed,dustem_polfrac,_extra=_extra | |
2 | + | |
3 | +;NB/ the old POLFRAC treatment from mpfit_run will have to be copied over here when plotting the polarization fraction. | |
4 | + | |
5 | +;JP had this amazing idea about the plotting of the used parameters and plugins in (a) seperate window(s). | |
6 | +;I will definitely do it as soon as I am done with the main display. | |
7 | + | |
8 | +;When you replace a command in cgoplot you will need to replace the cgerrplot commands as well. | |
9 | +;THIS IS VERY IMPORTANT DO NOT FORGET THIS. | |
10 | +;YOU WILL NEEED A COUNTER FOR THE COMMAND INDICES.... You need to find a solution for this. | |
11 | +;or know which is the index of the command that is targeted. | |
12 | + | |
13 | +;The procedure takes the _extra keyword but the plotting inside does not take the full structure | |
14 | +;but rather the needed parts. | |
15 | +;when the "_extra_filtering" procedure is finished. The structure will be filtered and the routine will be more secure. | |
16 | + | |
17 | +;NB (VERY IMPORTANT): in order to refresh the cgoplots maybe I should use the replacecmd keyword. | |
18 | +;This line runs but does it do the job?: ,cmdindex=command_index,replacecmd=command_index you ne | |
19 | +;THAT LINE FOR ALL THE CGOPLOTS LINES | |
20 | + | |
21 | +;NB: maybe change the position arrays instead of creating two giant loops. | |
22 | +;THIS IS A REALLY INTERESTING IDEA | |
23 | + | |
24 | + | |
25 | +;It seems more adequate to execute dustem_compute_sed/polsed/stokes here instead of this block | |
26 | + | |
27 | +;especially that dustem_activate_plugins runs the executable already but does not output it. | |
28 | + | |
29 | +;NB: There is an implicit assumption that st and dustem_sed and others are set simultaneously. | |
30 | + | |
31 | +;As stated above I do not think that I need this block. This will need to be corrected. | |
32 | +IF not keyword_set(st) THEN BEGIN | |
33 | + ;Activation of the plugins is needed because of the plotting of the total emission model that includes them. | |
34 | + dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values) ; 0/0 division case? | |
35 | + st=dustem_run(p_dim) | |
36 | +ENDIF | |
37 | + | |
38 | +;If the interpolates arrays are not present (dustem_sed, etc...) run: | |
39 | +;dustem_compute_sed etc to generate them. | |
40 | + | |
41 | +;!const.c ;speed of light in vacuum. | |
42 | + | |
43 | +;Generating a first resizable window (for emission or extinction elements) | |
44 | + | |
45 | +;if ~windowavailable(cgquery()) then begin | |
46 | + | |
47 | +;LIST OF TESTS THAT NEED TO BE RAN SO THAT THE PLOTTING OF THE MODEL SPECTRA OCCURS | |
48 | + | |
49 | +test_sed = isa(!dustem_show.sed) | |
50 | +test_ext = isa(!dustem_show.ext) | |
51 | +test_polext = isa(!dustem_show.polext) | |
52 | +test_polsed = isa(!dustem_show.polsed) | |
53 | +test_polfrac = isa(!dustem_show.polfrac) | |
54 | +test_psi_em = isa(!dustem_show.psi_em) | |
55 | +test_psi_ext = isa(!dustem_show.psi_ext) | |
56 | +test_qsed = isa(!dustem_show.qsed) | |
57 | +test_used = isa(!dustem_show.used) | |
58 | +test_qext = isa(!dustem_show.qext) | |
59 | +test_uext = isa(!dustem_show.uext) | |
60 | + | |
61 | + | |
62 | +;testing on the fitting of emission vs extinction data | |
63 | +test_m = test_sed or test_polsed or test_polfrac or test_qsed or test_used or test_psi_em | |
64 | +test_x = test_ext or test_polext or test_qext or test_uext or test_psi_ext | |
65 | + | |
66 | +;there are three display layouts in one-window mode: emission, extinction and emission+extinction | |
67 | +fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 ; st.sed.wav and st.polsed.wav should remain the same | |
68 | +spec = st.sed.em_tot * fact | |
69 | +if !run_pol then specpol = st.polsed.em_tot * fact | |
70 | + | |
71 | +Ngrains=(*!dustem_params).Ngrains | |
72 | +use_cols=dustem_grains_colors(Ngrains,/cgplot) | |
73 | +use_cols[1]='Cornflower' | |
74 | + | |
75 | +;I have decided to keep track of the command index manually as I did not find any command online that does this. | |
76 | +cmdind_m = 0 ;for emission | |
77 | +cmdind_x = 0 ;for extinction | |
78 | + | |
79 | +;#YOU NEED TO REPLACE THE QSED AND USED SCOPES WITH A SINGLE POLSED ONE | |
80 | + | |
81 | +;ADDING PLUGIN(S) TO SPECTRUM---------------- | |
82 | +scopes=tag_names((*!dustem_scope)) | |
83 | +IF scopes[0] NE 'NONE' THEN BEGIN | |
84 | + | |
85 | + FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN | |
86 | + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0] | |
87 | + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2) | |
88 | + ENDFOR | |
89 | + FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN | |
90 | + if !run_pol then begin | |
91 | + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2) | |
92 | + endif | |
93 | + ENDFOR | |
94 | + | |
95 | + | |
96 | +ENDIF | |
97 | + | |
98 | +;these following indices will be used to change the keep the same information in the _extra structure | |
99 | +;this is an initial solution until I finish coding the _extra-filtering procedure. | |
100 | + | |
101 | +tgnms_extra = tag_names(_extra) | |
102 | +ind_xr = where(strmid(tgnms_extra,0,2) eq 'XR') | |
103 | +ind_yr = where(strmid(tgnms_extra,0,2) eq 'YR') | |
104 | +if ind_xr EQ -1 then xr=[1.00E+00,1.00E+05] else xr=(_extra.(ind_xr)) | |
105 | +if ind_yr EQ -1 then yr=[5.00E-03,1.00E+08] else yr=(_extra.(ind_yr)) | |
106 | + | |
107 | +iswinsed = !dustemcgwin_id.sed EQ la_undef() | |
108 | +iswinext = !dustemcgwin_id.ext EQ la_undef() | |
109 | + | |
110 | + | |
111 | +;if iswinsed then begin ;I believe the iswin test should be below the case condition because I am not copying all the first 'HUGE LOOP' but rather replacing the positional arrays. | |
112 | +if test_m then begin | |
113 | + ;do you need an if !run_pol condition here? | |
114 | + ;!run_pol=1 ;test. Needs to be commented asap. | |
115 | + ;Generating emission window and saving window ID | |
116 | + | |
117 | + if iswinsed then begin | |
118 | + cgwindow, wtitle='DUSTEMWRAP v2.0 (EMISSION)', wback='grey';,wobject=winobj_m | |
119 | + 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). | |
120 | + !dustemcgwin_id.sed = winid_m | |
121 | + | |
122 | + endif else winid_m = !dustemcgwin_id.sed | |
123 | + | |
124 | + | |
125 | + ;cgWindow_GetDefs,xsize=xsize,ysize=ysize | |
126 | + ;cgcontrol, resize=[xsize,ysize] | |
127 | + if !run_pol then begin | |
128 | + ;cgwindow,wxsize=1260,wysize=670,wtitle='DUSTEMWRAP v2.0 (EMISSION)',wback='grey' | |
129 | + | |
130 | + ;position arrays for plot and normalized graph | |
131 | + ;there might be some problems with the 'math' here | |
132 | + | |
133 | + p_sed = [0.05,0.67,0.475,0.90] | |
134 | + p_psed = [0.525,0.67,0.95,0.90] | |
135 | + ;p_spsed = [0.07,0.42,0.5,0.57] | |
136 | + ;p_psised = [,,,] | |
137 | + p_qsed = [0.07,0.19,0.5,0.39] | |
138 | + ;p_used = [,,,] | |
139 | + np_sed = [0.05,0.60,0.475,0.67] | |
140 | + ;np_psed = [0.525,0.60,0.95,0.67] | |
141 | + np_qsed = [0.07,0.09,0.5,0.19] | |
142 | + ;np_used = [,,,] | |
143 | + | |
144 | + posp_sed = [0.07,0.87] | |
145 | +; posp_psed = | |
146 | +; posp_spsed = | |
147 | +; posp_qsed = | |
148 | +; posp_used = | |
149 | + | |
150 | + posnp_sed = [0.07,0.65] | |
151 | +; posnp_psed = | |
152 | +; posnp_spsed = | |
153 | +; posnp_qsed = | |
154 | +; posnp_used = | |
155 | +; | |
156 | + | |
157 | + endif else begin | |
158 | + p_sed = [0.07,0.30,0.97,0.85] | |
159 | + np_sed = [0.07,0.10,0.97,0.30] | |
160 | + | |
161 | + posp_sed = [0.09,0.80] | |
162 | +; posp_psed = | |
163 | +; posp_spsed = | |
164 | +; posp_qsed = | |
165 | +; posp_used = | |
166 | + | |
167 | + posnp_sed = [0.09,0.25] | |
168 | +; posnp_psed = | |
169 | +; posnp_spsed = | |
170 | +; posnp_qsed = | |
171 | +; posnp_used = | |
172 | + endelse | |
173 | + | |
174 | + ;Plotting of sed data axes (whether or not data is present) | |
175 | + plotsym,0,/fill ;you might need to execute this again. hmm... | |
176 | + ;stop | |
177 | + | |
178 | + cgcontrol, execute=0 | |
179 | + | |
180 | + ;cgcontrol, update=0 | |
181 | + ;stop | |
182 | + ;cgcontrol, update=0 | |
183 | + if ~iswinsed then goto, zone1 | |
184 | + | |
185 | + if ~test_sed then begin ; SED data is not present (For completeness) # This is only valid when !run_pol=1 | |
186 | + | |
187 | + xvar=dustem_get_wavelengths() ;supposedly does not modify the x axis range | |
188 | + cgwindow,'cgplot',xvar,xvar,/nodata,/ylog,/xlog,/ys,xs=9,position=p_sed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 | |
189 | + cgwindow, 'cgaxis', xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10 & cmdind_m+=1 | |
190 | + | |
191 | + ;Plotting of the title of the SED plot | |
192 | + cgwindow,'xyouts',posp_sed[0],posp_sed[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
193 | + | |
194 | + ;Plotting of the normalized SED plot | |
195 | + cgwindow,'cgplot',xvar,xvar,/xlog,/ys,xs=1,position=np_sed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1 | |
196 | + | |
197 | + ;Plotting of the title of the normalized plot | |
198 | + cgwindow,'xyouts',posnp_sed[0],posnp_sed[1],textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
199 | + | |
200 | + ;FORGOT THE PLOTTING OF THE TITLES. THIS SHOULD PROBABLY BE PLACED OUT. | |
201 | + | |
202 | + endif else begin ;SED exists | |
203 | + | |
204 | + ;Locating filter and spectrum data points | |
205 | + idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt) | |
206 | + idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec) | |
207 | + | |
208 | + if ct_spec ne 0 then begin | |
209 | + | |
210 | + ;Plotting of spectrum data points (to be fitted) | |
211 | + cgwindow,'cgplot',((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec),/ylog,/xlog,/ys,xs=9,position=p_sed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8,ytickformat='dstmwrp_exp' | |
212 | + ;stop | |
213 | + | |
214 | + ;Plotting of the spectrum error points | |
215 | + rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2. | |
216 | + cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),((*!dustem_data.sed).values)(idx_spec)-rms,((*!dustem_data.sed).values)(idx_spec)+rms,/addcmd,color='Powder Blue' & cmdind_m+=1 | |
217 | + | |
218 | + endif | |
219 | + | |
220 | + if ct_filt ne 0 then begin | |
221 | + | |
222 | + if ct_spec ne 0 then txtcmd = 'cgoplot' else txtcmd = 'cgplot' & cmdind_m-=1 | |
223 | + ;Plotting of filter data points (to be fitted) ; | |
224 | + cgwindow,txtcmd,((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt),/addcmd,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,position=p_sed,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog & cmdind_m+=1;,xtick_get=hh | |
225 | + | |
226 | + ;Plotting of the filter error points | |
227 | + rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2.;/dustem_sed(idx_filt) | |
228 | + cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_filt),((*!dustem_data.sed).values)(idx_filt)-rms,((*!dustem_data.sed).values)(idx_filt)+rms,/addcmd,color='Dodger Blue' & cmdind_m+=1 | |
229 | + | |
230 | + endif | |
231 | + ;Plotting of frequency axis | |
232 | + cgwindow, 'cgaxis', xaxis=1,xlog=1 ,xs=1,xminor=10, xticklen=0.05 ,xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)') & cmdind_m+=1 | |
233 | + ;stop | |
234 | + ;Locating all the hidden data points (spectrum+filter) | |
235 | + match2,((*!dustem_data.sed).wav),((*!dustem_show.sed).wav),fit_sedpts,show_sedpts ;only show_sedpts is needed | |
236 | + idx_rmv_sed=where(show_sedpts eq -1, ct_hdnpts) ; indices of the points to hide | |
237 | + | |
238 | + if ct_hdnpts ne 0 then begin ;Hidden data points are present | |
239 | + | |
240 | + ;Locating the hidden spectrum and filter data points | |
241 | + idx_filt_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) NE 'SPECTRUM',ct_filt_hdn) | |
242 | + idx_spec_hdn = where(((*!dustem_show.sed).filt_names)(idx_rmv_sed) EQ 'SPECTRUM',ct_spec_hdn) | |
243 | + | |
244 | + ;Plotting of hidden spectrum data points | |
245 | + cgwindow,'cgoplot',((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_hdn),position=p_sed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1 | |
246 | + | |
247 | + ;Plotting of hidden spectrum error points | |
248 | + rms=3.*((*!dustem_show.sed).sigma)(idx_spec_hdn)/2. | |
249 | + cgwindow,'cgerrplot',((*!dustem_show.sed).wav)(idx_spec_hdn),((*!dustem_show.sed).values)(idx_spec_hdn)-rms,((*!dustem_show.sed).values)(idx_spec_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1 | |
250 | + | |
251 | + ;Plotting of hidden filter data points | |
252 | + cgwindow,'cgoplot',((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn),pos=p_sed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1 | |
253 | + | |
254 | + ;Plotting of hidden filter error point | |
255 | + rms=3.*((*!dustem_show.sed).sigma)(idx_filt_hdn)/2. | |
256 | + cgwindow,'cgerrplot',((*!dustem_show.sed).wav)(idx_filt_hdn),((*!dustem_show.sed).values)(idx_filt_hdn)-rms,((*!dustem_show.sed).values)(idx_filt_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1 | |
257 | + | |
258 | + endif | |
259 | + | |
260 | + ;Plotting of the title of the SED plot | |
261 | + cgwindow,'xyouts',posp_sed[0],posp_sed[1],textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
262 | + ;Plotting of the title of the normalized plot | |
263 | + cgwindow,'xyouts',posnp_sed[0],posnp_sed[1],textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1 | |
264 | + ;stop | |
265 | + | |
266 | + | |
267 | + ;create counter here!! | |
268 | + if iswinsed then !dustemcgwin_ncmds.sed.ct_z1 = cmdind_m | |
269 | + zone1: | |
270 | + if ~iswinsed then begin | |
271 | + cmdind_m = !dustemcgwin_ncmds.sed.ct_z1 | |
272 | + idx_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',ct_filt) | |
273 | + idx_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',ct_spec) | |
274 | + endif | |
275 | + ;Plotting of the spectra of the dust species | |
276 | + FOR i=0L,Ngrains-1 DO BEGIN | |
277 | + ;if i EQ 0 then txtcmd='cgplot' else txtcmd = 'cgoplot' | |
278 | + cmdind_m+=1 | |
279 | + if iswinsed then cgwindow,'cgoplot',st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],position=p_sed,/addcmd,noerase=1,winid=winid_m else $ | |
280 | + cgwindow,'cgoplot',st.sed.wav,st.sed.(i+1)*fact,color=use_cols[i],position=p_sed,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m | |
281 | + ENDFOR | |
282 | + | |
283 | + ;Plotting of the total dust emission spectrum | |
284 | + if iswinsed then begin | |
285 | + cgwindow,'cgoplot',st.sed.wav,spec,position=p_sed,/addcmd,noerase=1,winid=winid_m | |
286 | + cmdind_m+=1 | |
287 | + endif else begin | |
288 | + cmdind_m+=1 | |
289 | + cgwindow,'cgoplot',st.sed.wav,spec,position=p_sed,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m | |
290 | + endelse | |
291 | + | |
292 | + ;PLotting of the interpolates corresponding to spectrum and filter points | |
293 | + IF ct_filt NE 0 THEN BEGIN | |
294 | + ;plotsym,8 | |
295 | + xx=((*!dustem_data.sed).wav)[idx_filt] | |
296 | + yy=dustem_sed[idx_filt] | |
297 | + if iswinsed then begin | |
298 | + cgwindow,'cgoplot',xx,yy,color='red',psym=6,syms=2,noerase=1,/addcmd,winid=winid_m | |
299 | + cmdind_m+=1 | |
300 | + endif else begin | |
301 | + cmdind_m+=1 | |
302 | + cgwindow,'cgoplot',xx,yy,color='red',psym=6,syms=2,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m | |
303 | + endelse | |
304 | + ENDIF | |
305 | + ;stop | |
306 | + IF ct_spec NE 0 THEN BEGIN | |
307 | + ;plotsym,0 | |
308 | + xx=((*!dustem_data.sed).wav)[idx_spec] | |
309 | + yy=dustem_sed[idx_spec] | |
310 | + if iswinsed then begin | |
311 | + cgwindow,'cgoplot',xx,yy,color='red',psym=7,syms=2,noerase=1,/addcmd,winid=winid_m | |
312 | + cmdind_m+=1 | |
313 | + endif else begin | |
314 | + cmdind_m+=1 | |
315 | + cgwindow,'cgoplot',xx,yy,color='red',psym=7,syms=2,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m | |
316 | + endelse | |
317 | + ENDIF | |
318 | + ;stop | |
319 | + if iswinsed then begin | |
320 | + xvar=dustem_get_wavelengths() | |
321 | + ;plotsym,0,/fill | |
322 | + cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_sed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1 | |
323 | + endif else begin | |
324 | + cmdind_m += 1 | |
325 | + endelse | |
326 | + | |
327 | +; ;Plotting of the normalized SED plot | |
328 | +; xvar=dustem_get_wavelengths() | |
329 | +; ;plotsym,0,/fill | |
330 | +; cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_sed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1 | |
331 | +; ;stop | |
332 | + IF ct_filt NE 0 THEN BEGIN | |
333 | + xx=((*!dustem_data.sed).wav)[idx_filt] | |
334 | + yy=dustem_sed[idx_filt] | |
335 | + rms=3.*((*!dustem_data.sed).sigma)(idx_filt)/2. | |
336 | + if iswinsed then begin | |
337 | + cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,/addcmd,winid=winid_m,pos=np_sed & cmdind_m+=1 | |
338 | + cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_filt),(((*!dustem_data.sed).values)[idx_filt]-rms)/yy,(((*!dustem_data.sed).values)[idx_filt]+rms)/yy,/addcmd,color='Dodger Blue' & cmdind_m+=1 | |
339 | + endif else begin | |
340 | + cmdind_m+=1 & cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_filt]/yy,psym=16,color='Dodger Blue',syms=0.8,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m,pos=np_sed | |
341 | + cmdind_m+=1 & cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_filt),(((*!dustem_data.sed).values)[idx_filt]-rms)/yy,(((*!dustem_data.sed).values)[idx_filt]+rms)/yy,color='Dodger Blue',/replacecmd, cmdindex=cmdind_m | |
342 | + endelse | |
343 | + ENDIF | |
344 | + | |
345 | + IF ct_spec NE 0 THEN BEGIN | |
346 | + ;plotsym,0,/fill | |
347 | + xx=((*!dustem_data.sed).wav)[idx_spec] | |
348 | + yy=dustem_sed[idx_spec] | |
349 | + rms=3.*((*!dustem_data.sed).sigma)(idx_spec)/2. | |
350 | + if iswinsed then begin | |
351 | + cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Dodger Blue',psym=16,syms=0.8,noerase=1,/addcmd,winid=winid_m & cmdind_m+=1 | |
352 | + cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),(((*!dustem_data.sed).values)[idx_spec]-rms)/yy,(((*!dustem_data.sed).values)[idx_spec]+rms)/yy,/addcmd,color='Dodger Blue' & cmdind_m+=1 | |
353 | + endif else begin | |
354 | + cmdind_m+=1 & cgwindow,'cgoplot',xx,((*!dustem_data.sed).values)[idx_spec]/yy,color='Dodger Blue',psym=16,syms=0.8,noerase=1,winid=winid_m,/replacecmd,cmdindex=cmdind_m | |
355 | + cmdind_m+=1 & cgwindow,'cgerrplot',((*!dustem_data.sed).wav)(idx_spec),(((*!dustem_data.sed).values)[idx_spec]-rms)/yy,(((*!dustem_data.sed).values)[idx_spec]+rms)/yy,color='Dodger Blue',/replacecmd,cmdindex=cmdind_m | |
356 | + endelse | |
357 | + | |
358 | + ENDIF | |
359 | + | |
360 | + | |
361 | + ;cgwindow,'cgoplot',((*!dustem_show.sed).wav),((*!dustem_show.sed).values)/dustem_sed,/xlog,/ys,xs=1,position=np_sed,/addcmd,noerase=1,color='Dodger Blue',psym=8 | |
362 | + | |
363 | + | |
364 | + ;,winid=winid_m | |
365 | + | |
366 | + endelse | |
367 | + | |
368 | + if ~!run_pol then goto, end_m | |
369 | + | |
370 | + if ~test_qsed then begin ; QSED data is not present (For completeness) # This is only valid when !run_pol=1 | |
371 | + | |
372 | + xvar=dustem_get_wavelengths() ;supposedly does not modify the x axis range | |
373 | + cgwindow,'cgplot',xvar,xvar,/nodata,/ylog,/xlog,/ys,xs=9,position=p_qsed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1 | |
374 | + cgwindow, 'cgaxis', xaxis=1 ,xlog=1 ,xrange=((!const.c*1E6/xr)*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)'),xticklen=0.05,xminor=10 & cmdind_m+=1 | |
375 | + | |
376 | + ;Plotting of the title of the SED plot | |
377 | + cgwindow,'xyouts',0.07,0.87,textoidl('Q_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
378 | + | |
379 | + ;Plotting of the normalized SED plot | |
380 | + cgwindow,'cgplot',xvar,xvar,/xlog,/ys,xs=1,position=np_qsed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1 | |
381 | + | |
382 | + ;Plotting of the title of the normalized plot | |
383 | + cgwindow,'xyouts',0.07,0.65,textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
384 | + | |
385 | + ;FORGOT THE PLOTTING OF THE TITLES. THIS SHOULD PROBABLY BE PLACED OUT. | |
386 | + | |
387 | + endif else begin ;QSED exists | |
388 | + | |
389 | + ;Locating filter and spectrum data points | |
390 | + idx_filtq=where((*!dustem_data.qsed).filt_names NE 'SPECTRUM',ct_filtq) | |
391 | + idx_specq=where((*!dustem_data.qsed).filt_names EQ 'SPECTRUM',ct_specq) | |
392 | + | |
393 | + if ct_specq ne 0 then begin | |
394 | + | |
395 | + ;Plotting of spectrum data points (to be fitted) | |
396 | + cgwindow,'cgplot',((*!dustem_data.qsed).wav)(idx_specq),((*!dustem_data.qsed).values)(idx_specq),/ylog,/xlog,/ys,xs=9,position=p_qsed,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Powder Blue',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8,ytickformat='dstmwrp_exp' & cmdind_m+=1 | |
397 | + ;stop | |
398 | + | |
399 | + ;Plotting of the spectrum error points | |
400 | + rms=3.*((*!dustem_data.qsed).sigma)(idx_specq)/2. | |
401 | + cgwindow,'cgerrplot',((*!dustem_data.qsed).wav)(idx_specq),((*!dustem_data.qsed).values)(idx_specq)-rms,((*!dustem_data.qsed).values)(idx_specq)+rms,/addcmd,color='Powder Blue' & cmdind_m+=1 | |
402 | + | |
403 | + endif | |
404 | + | |
405 | + if ct_filtq ne 0 then begin | |
406 | + | |
407 | + if ct_specq ne 0 then txtcmd = 'cgoplot' else txtcmd = 'cgplot' | |
408 | + ;Plotting of filter data points (to be fitted) ; | |
409 | + cgwindow,txtcmd,((*!dustem_data.qsed).wav)(idx_filtq),((*!dustem_data.qsed).values)(idx_filtq),/addcmd,charsize=1.15,color='Dodger Blue',psym=8,syms=0.8,position=p_qsed,/ys,xs=9,noerase=1,xtickformat='(A1)',xr=xr,yr=yr,ytickformat='dstmwrp_exp',/ylog,/xlog & cmdind_m+=1 | |
410 | + | |
411 | + ;Plotting of the filter error points | |
412 | + rms=3.*((*!dustem_data.qsed).sigma)(idx_filtq)/2.;/dustem_sed(idx_filt) | |
413 | + cgwindow,'cgerrplot',((*!dustem_data.qsed).wav)(idx_filtq),((*!dustem_data.qsed).values)(idx_filtq)-rms,((*!dustem_data.qsed).values)(idx_filtq)+rms,/addcmd,color='Dodger Blue' & cmdind_m+=1 | |
414 | + | |
415 | + endif | |
416 | + ;Plotting of frequency axis | |
417 | + cgwindow, 'cgaxis', xaxis=1,xlog=1 ,xs=1,xminor=10, xticklen=0.05 ,xrange=((!const.c*1E6/(_extra.(ind_xr)))*1E-9),/addcmd,charsize=1.15,title=textoidl('\nu (GHz)') & cmdind_m+=1 | |
418 | + ;stop | |
419 | + | |
420 | + ;Locating all the hidden data points (spectrum+filter) | |
421 | + match2,((*!dustem_data.qsed).wav),((*!dustem_show.qsed).wav),fit_sedptsq,show_sedptsq ;only show_sedpts is needed | |
422 | + idx_rmv_sedq=where(show_sedptsq eq -1, ct_hdnptsq) ; indices of the points to hide | |
423 | + | |
424 | + if ct_hdnptsq ne 0 then begin ;Hidden data points are present | |
425 | + | |
426 | + ;Locating the hidden spectrum and filter data points | |
427 | + idx_filt_hdnq = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sedq) NE 'SPECTRUM',ct_filt_hdnq) | |
428 | + idx_spec_hdnq = where(((*!dustem_show.qsed).filt_names)(idx_rmv_sedq) EQ 'SPECTRUM',ct_spec_hdnq) | |
429 | + | |
430 | + ;Plotting of hidden spectrum data points | |
431 | + cgwindow,'cgoplot',((*!dustem_show.qsed).wav)(idx_spec_hdnq),((*!dustem_show.qsed).values)(idx_spec_hdnq),position=p_qsed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1 | |
432 | + | |
433 | + ;Plotting of hidden spectrum error points | |
434 | + rms=3.*((*!dustem_show.qsed).sigma)(idx_spec_hdnq)/2. | |
435 | + cgwindow,'cgerrplot',((*!dustem_show.qsed).wav)(idx_spec_hdnq),((*!dustem_show.qsed).values)(idx_spec_hdnq)-rms,((*!dustem_show.qsed).values)(idx_spec_hdnq)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1 | |
436 | + | |
437 | + ;Plotting of hidden filter data points | |
438 | + cgwindow,'cgoplot',((*!dustem_show.qsed).wav)(idx_filt_hdnq),((*!dustem_show.qsed).values)(idx_filt_hdnq),pos=p_qsed,/ylog,/xlog,/ys,xs=9,/addcmd,noerase=1,charsize=1.15,xtickformat='(A1)',color='Black',xr=xr,yr=yr,winid=winid_m,psym=8,syms=0.8 & cmdind_m+=1 | |
439 | + | |
440 | + ;Plotting of hidden filter error point | |
441 | + rms=3.*((*!dustem_show.qsed).sigma)(idx_filt_hdn)/2. | |
442 | + cgwindow,'cgerrplot',((*!dustem_show.qsed).wav)(idx_filt_hdn),((*!dustem_show.qsed).values)(idx_filt_hdn)-rms,((*!dustem_show.qsed).values)(idx_filt_hdn)+rms,/addcmd,winid=winid_m,color='Black' & cmdind_m+=1 | |
443 | + | |
444 | + endif | |
445 | + | |
446 | + ;Plotting of the title of the SED plot | |
447 | + cgwindow,'xyouts',0.07,0.87,textoidl('I_{\nu} (MJy/sr)'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
448 | + | |
449 | + ;Plotting of the normalized SED plot | |
450 | + xvar=dustem_get_wavelengths() | |
451 | + cgwindow,'cgplot',xvar,xvar/xvar,/xlog,/ys,xs=1,position=np_qsed,/addcmd,noerase=1,xtickformat='(A1)',color='Black',xr=xr,yr=[0.0,2.0],yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.0 & cmdind_m+=1 | |
452 | + | |
453 | + ;Plotting of the title of the normalized plot | |
454 | + cgwindow,'xyouts',0.07,0.65,textoidl('norm'),color=0,/normal,charsize=1.1,/addcmd & cmdind_m+=1;,winid=winid_m | |
455 | + | |
456 | + endelse | |
457 | + | |
458 | + | |
459 | + | |
460 | + end_m: | |
461 | + | |
462 | + ;cgset, winid_m | |
463 | + | |
464 | + ;cgcontrol, update=1 | |
465 | +; varrr=cgquery(dimensions=dim_m) ;be careful because the dim_m array can be multi-dimensional because of the presence of two windows. | |
466 | +; cgcontrol, update=1 | |
467 | +; cgcontrol, resize=[dim_m(0),dim_m(1)] | |
468 | +; | |
469 | + ;cgcontrol, resize=1 | |
470 | +; cgcontrol,update=1 | |
471 | +; cgcontrol,update=1 | |
472 | + | |
473 | +; cgcontrol, resize=[!D.X_SIZE,!D.Y_SIZE] | |
474 | + | |
475 | + cgcontrol, execute=1 | |
476 | + ;cgcontrol, update=0 | |
477 | + ;cgcontrol, update=1 | |
478 | + ;varr=cgquery(dimensions=dim_m,objectref=winobj_m) | |
479 | + | |
480 | + | |
481 | +endif | |
482 | +;endif | |
483 | + | |
484 | + | |
485 | +;stop | |
486 | + | |
487 | + | |
488 | + | |
489 | +; ;#COMMENTED BITS OF CODES | |
490 | +; | |
491 | +; IF keyword_set(help) THEN BEGIN | |
492 | +; doc_library,'dustem_plot_fit_sed' | |
493 | +; goto,the_end | |
494 | +; ENDIF | |
495 | +; | |
496 | +; IF keyword_set(ps) THEN BEGIN | |
497 | +; set_plot, 'PS' | |
498 | +; device, filename=ps, /color,set_character_size=[170,250], /encapsulated | |
499 | +; ENDIF ELSE BEGIN | |
500 | +; | |
501 | +; set_plot,'X' | |
502 | +; IF keyword_set(win) then window,win;,xsize=600,ysize=800 | |
503 | +; ENDELSE | |
504 | +; | |
505 | +; fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 | |
506 | +; ;use_col_data_filt=70 | |
507 | +; ;use_col_sed_spec=170 | |
508 | +; use_col_data_filt='blue' | |
509 | +; ;use_col_sed_spec='red' | |
510 | +; use_col_sed_spec='grey' | |
511 | +; IF not keyword_set(col_sed) THEN BEGIN | |
512 | +; ;use_col_sed_filt=250 ;red | |
513 | +; use_col_sed_filt='red' ;red | |
514 | +; ENDIF ELSE BEGIN | |
515 | +; use_col_sed_filt=col_sed | |
516 | +; ENDELSE | |
517 | +; IF not keyword_set(col_tot) THEN BEGIN | |
518 | +; ;use_col_tot=200 | |
519 | +; use_col_tot='black' | |
520 | +; ENDIF ELSE BEGIN | |
521 | +; use_col_tot=col_tot | |
522 | +; ENDELSE | |
523 | +; IF not keyword_set(line_tot) THEN BEGIN | |
524 | +; use_line_tot=0 | |
525 | +; ENDIF ELSE BEGIN | |
526 | +; use_line_tot=line_tot | |
527 | +; ENDELSE | |
528 | +; | |
529 | +; | |
530 | +; spec = st.sed.em_tot * fact | |
531 | +; if keyword_set(fpol) then specpol = st.polsed.em_tot * fact | |
532 | +; ;ADDING PLUGIN(S) TO SPECTRUM---------------- | |
533 | +; ;if n_tags(!dustem_data.sed) gt 1 then begin | |
534 | +; scopes=tag_names((*!dustem_scope)) | |
535 | +; IF scopes[0] NE 'NONE' THEN BEGIN | |
536 | +; ;IF ptr_valid(!dustem_plugin) THEN BEGIN | |
537 | +; FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN | |
538 | +; IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0] | |
539 | +; if keyword_set(fpol) then begin | |
540 | +; IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2) | |
541 | +; endif | |
542 | +; ENDFOR | |
543 | +; FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN | |
544 | +; if keyword_set(fpol) then begin | |
545 | +; IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2) | |
546 | +; endif | |
547 | +; ENDFOR | |
548 | +; ENDIF | |
549 | +; ;endif | |
550 | +; ;------------------------------------------ | |
551 | +; | |
552 | +; ;stop | |
553 | +; | |
554 | +; ;use_cols=[use_col_pah,use_col_vsg,use_col_bg,use_col_cont] | |
555 | +; ;use_lines=[use_line_pah,use_line_vsg,use_line_bg,use_line_cont] | |
556 | +; ;col_off=30 | |
557 | +; ;Ngrains=(*!dustem_params).grain.Ngrains | |
558 | +; Ngrains=(*!dustem_params).Ngrains | |
559 | +; ;use_cols=long(findgen(Ngrains)/(Ngrains-1)*(255-col_off)+col_off) | |
560 | +; use_cols=dustem_grains_colors(Ngrains,/cgplot) | |
561 | +; use_lines=replicate(0,Ngrains) | |
562 | +; | |
563 | +; norm = dustem_sed * 0. + 1 | |
564 | +; | |
565 | +; ;====== PLOT THE SED | |
566 | +; | |
567 | +; IF keyword_set(title) THEN title = title ELSE title = 'Spectral Energy Distribution (Running)' | |
568 | +; | |
569 | +; IF keyword_set(xr) THEN xr = xr ELSE xr = [1.00E+00,6.00E+04] | |
570 | +; | |
571 | +; IF keyword_set(yr) THEN yr = yr ELSE yr = [1.00E-7,5.00E03] | |
572 | +; | |
573 | +; IF keyword_set(xtit) THEN xtit = xtit ELSE xtit = textoidl('\lambda (\mum)') | |
574 | +; | |
575 | +; IF keyword_set(ytit) THEN ytit = ytit ELSE ytit = textoidl('Brightness/N_H (MJy/sr/H)') | |
576 | +; | |
577 | +; | |
578 | +; ;deffo define a title variable here. The procedures are not communicating with each other. | |
579 | +; ;pos=cgLayout() | |
580 | +; ;############################### | |
581 | +; if keyword_set(fpol) then begin | |
582 | +; if !run_lin then begin | |
583 | +; cgDisplay, 600, 500 | |
584 | +; cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,xtit='',ytit=ytit,tit='',/ylog,/xlog,/ys,/xs,position=[0.12,0.25,0.96,0.76],xtickformat='(A1)',_extra=_extra,charsize=1.3,/noerase | |
585 | +; endif | |
586 | +; endif ELSE cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,xtit='',ytit=ytit,tit=title,/ylog,/xlog,/ys,/xs,position=[0.12,0.35,0.96,0.90],xtickformat='(A1)',_extra=_extra,charsize=1.3 | |
587 | +; ;############################### | |
588 | +; | |
589 | +; | |
590 | +; ;cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/norm,/nodata,xtit='',ytit=textoidl('Brightness/N_H (MJy/sr/H)'),tit=title,ylog=1,/xlog,xr=xr,yr=yr,/ys,/xs,position=[0.12,0.35,0.96,0.90],xtickformat='(A1)' | |
591 | +; | |
592 | +; | |
593 | +; ;stop | |
594 | +; ;cgplot,st.polsed.wav,Q_sed*fact,xtit='',ytit=ytitstq,tit=titstq,ylog=ylog,/xlog,xr=xr,yr=yr,/ys,/xs,position=[0.17,0.35,0.95,0.95],xtickformat='(A1)' | |
595 | +; | |
596 | +; ;this is where you will add the normalized sed | |
597 | +; | |
598 | +; | |
599 | +; ind_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',count_filt) | |
600 | +; ind_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',count_spec) | |
601 | +; ;=== Plot the data | |
602 | +; ; following lines for fawlty compatibility | |
603 | +; defsysv,'!psym',exists=pexist | |
604 | +; if pexist eq 0 then defsysv,'!psym',0 | |
605 | +; IF count_spec NE 0 THEN BEGIN | |
606 | +; ;x& | |
607 | +; xx=((*!dustem_data.sed).wav)[ind_spec] | |
608 | +; yy=((*!dustem_data.sed).values)[ind_spec]/norm[ind_spec] | |
609 | +; rms=3.*((*!dustem_data.sed).sigma)[ind_spec]/2./norm[ind_spec] | |
610 | +; cgoplot,xx,yy,psym ,syms=0.5,color=use_col_sed_spec | |
611 | +; IF not keyword_set(no_spec_error) THEN BEGIN | |
612 | +; cgerrplot,xx,yy-rms,yy+rms,color=use_col_sed_spec | |
613 | +; ;err_bar,((*!dustem_data.sed).wav)(ind_spec),((*!dustem_data.sed).values)(ind_spec)/norm(ind_spec),yrms=3.*((*!dustem_data.sed).sigma)(ind_spec)/2./norm(ind_spec) | |
614 | +; ENDIF | |
615 | +; ENDIF | |
616 | +; IF count_filt NE 0 THEN BEGIN | |
617 | +; ;stop | |
618 | +; xx=((*!dustem_data.sed).wav)[ind_filt] | |
619 | +; yy=((*!dustem_data.sed).values)[ind_filt]/norm[ind_filt] | |
620 | +; rms=3.*((*!dustem_data.sed).sigma)[ind_filt]/2./norm[ind_filt] | |
621 | +; plotsym,0,/fill | |
622 | +; cgoplot,xx,yy,psym=8,color='Dodger Blue';use_col_data_filt | |
623 | +; ;err_bar,((*!dustem_data.sed).wav)(ind_filt),((*!dustem_data.sed).values)(ind_filt)/norm(ind_filt),yrms=3.*((*!dustem_data.sed).sigma)(ind_filt)/2./norm(ind_filt),color=use_col_data_filt | |
624 | +; cgerrplot,xx,yy-rms,yy+rms,color='Dodger Blue';use_col_data_filt | |
625 | +; ENDIF | |
626 | +; ;=== Plot the computed SED | |
627 | +; IF count_filt NE 0 THEN BEGIN | |
628 | +; plotsym,8 | |
629 | +; xx=((*!dustem_data.sed).wav)[ind_filt] | |
630 | +; yy=sed[ind_filt]/norm[ind_filt] | |
631 | +; cgoplot,xx,yy,color=use_col_sed_filt,psym=6,syms=2 | |
632 | +; ENDIF | |
633 | +; IF count_spec NE 0 THEN BEGIN | |
634 | +; plotsym,0 | |
635 | +; xx=((*!dustem_data.sed).wav)[ind_spec] | |
636 | +; yy=sed[ind_spec]/norm[ind_spec] | |
637 | +; cgoplot,xx,yy,color=use_col_sed_filt,psym=6,syms=2 | |
638 | +; ENDIF | |
639 | +; | |
640 | +; | |
641 | +; IF !dustem_show_plot EQ 2 THEN BEGIN | |
642 | +; norm = spec | |
643 | +; ENDIF ELSE BEGIN | |
644 | +; norm = spec * 0. + 1 | |
645 | +; ENDELSE | |
646 | +; use_cols[1]='Cornflower' | |
647 | +; FOR i=0L,Ngrains-1 DO BEGIN | |
648 | +; cgoplot,st.sed.wav,st.sed.(i+1)*fact/norm,color=use_cols[i],linestyle=use_lines[i] | |
649 | +; ENDFOR | |
650 | +; | |
651 | +; ;stop | |
652 | +; | |
653 | +; ;PLOTTING OF THE PLUGIN(S)--------------- AUTOMATE THIS. QUITE FEASIBLE | |
654 | +; IF tag_exist(*!dustem_scope,'CONTINUUM') THEN BEGIN | |
655 | +; cgoplot,st.sed.wav,(*(*!dustem_plugin).continuum)[*,0],color='Teal',linestyle=3 | |
656 | +; ENDIF | |
657 | +; IF tag_exist(*!dustem_scope,'FREEFREE') THEN BEGIN | |
658 | +; cgoplot,st.sed.wav,(*(*!dustem_plugin).freefree)[*,0],color='Dark Red',linestyle=3 | |
659 | +; ENDIF | |
660 | +; IF tag_exist(*!dustem_scope,'SYNCHROTRON') THEN BEGIN | |
661 | +; cgoplot,st.sed.wav,(*(*!dustem_plugin).synchrotron)[*,0],color='Crimson',linestyle=3 | |
662 | +; ENDIF | |
663 | +; | |
664 | +; IF tag_exist(*!dustem_scope,'MBBDY_ISRF') THEN BEGIN | |
665 | +; cgoplot,st.sed.wav,(*(*!dustem_plugin).mbbdy_isrf)[*,0],color='Gold',linestyle=3 | |
666 | +; ENDIF | |
667 | +; | |
668 | +; IF tag_exist(*!dustem_scope,'MBBDY') THEN BEGIN | |
669 | +; cgoplot,st.sed.wav,(*(*!dustem_plugin).mbbdy)[*,0],color='Cornflower',linestyle=3 | |
670 | +; ENDIF | |
671 | +; | |
672 | +; | |
673 | +; cgoplot,st.sed.wav,spec/norm,color=use_col_tot,linestyle=use_line_tot | |
674 | +; if keyword_set(fpol) then cgoplot,st.polsed.wav,specpol,color='Teal',linestyle=4 | |
675 | +; ;plot the normalized data as well. | |
676 | +; ;---------------------------------------- | |
677 | +; | |
678 | +; ;==== print the legend | |
679 | +; frmt0='(A36)' | |
680 | +; frmt1='(1E10.2)' | |
681 | +; frmt2='(F7.2)' | |
682 | +; use_legend_xpos=0.50 | |
683 | +; if keyword_set(fpol) then use_legend_ypos=0.70 ELSE use_legend_ypos=0.84 | |
684 | +; use_legend_offset=0.03 ;This is the offset between lines of the legend in normalized units | |
685 | +; legend_charsize=0.86 | |
686 | +; | |
687 | +; k=0. | |
688 | +; iscond=0 | |
689 | +; n_plgns = n_tags(*!dustem_scope) | |
690 | +; inn=n_plgns/2+1 | |
691 | +; IF n_plgns mod 2 ne 0 THEN inn=n_plgns/2+2 | |
692 | +; | |
693 | +; IF keyword_set(legend_xpos) THEN use_legend_xpos=legend_xpos | |
694 | +; IF keyword_set(legend_ypos) THEN use_legend_ypos=legend_ypos | |
695 | +; IF keyword_set(legend_offset) THEN use_legend_offset=legend_offset | |
696 | +; | |
697 | +; IF !d.name NE 'PS' THEN cleanplot | |
698 | +; | |
699 | +; tg=0 | |
700 | +; prv_str='' | |
701 | +; IF keyword_set(res) THEN BEGIN | |
702 | +; Npar=n_elements(res) | |
703 | +; ;print,'==============' | |
704 | +; | |
705 | +; FOR i=0L,Npar-1 DO BEGIN | |
706 | +; parameter_description=(*(*!dustem_fit).param_descs)[i] | |
707 | +; parameter_type=dustem_parameter_description2type(parameter_description,string_name=string_name) | |
708 | +; str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1) | |
709 | +; IF keyword_set(errors) THEN BEGIN | |
710 | +; str=str+textoidl(' \pm ')+string(errors(i),format=frmt1) | |
711 | +; ENDIF | |
712 | +; | |
713 | +; xxpos=use_legend_xpos*0.07 | |
714 | +; yypos=use_legend_ypos*0.03 | |
715 | +; xyouts,xxpos,yypos,'Model: '+!dustem_model,color=0,/normal,charsize=legend_charsize | |
716 | +; | |
717 | +; IF STRUPCASE(strmid(strtrim(parameter_description,2),0,6)) eq 'DUSTEM' THEN BEGIN | |
718 | +; | |
719 | +; ; xxpos=use_legend_xpos*0.07 | |
720 | +; ; yypos=use_legend_ypos*0.03 | |
721 | +; ; xyouts,xxpos,yypos,'Model: '+!dustem_model,color=0,/normal,charsize=legend_charsize | |
722 | +; | |
723 | +; xxpos=use_legend_xpos*0.75 | |
724 | +; yypos=use_legend_ypos*1.03 | |
725 | +; xyouts,xxpos,yypos,'--Plugins--',color=0,/normal,charsize=legend_charsize | |
726 | +; | |
727 | +; ii = strsplit(string_name,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword | |
728 | +; | |
729 | +; mm=where(tag_names(*!dustem_scope) eq strupcase(strmid(string_name,7,ii-7)),coun) ; Selecting a plugin through matching the string name of the plugin form the scope system variable with the one read from the parameter description vector | |
730 | +; | |
731 | +; ;tg+=1 | |
732 | +; ;if strmid(string_name,7,ii-7) eq prv_str then tg-=1 | |
733 | +; prmtg=(*(*!dustem_paramtag).(mm)) | |
734 | +; indtg=(strmid(string_name,ii+1)) & indtg=strmid(indtg,0,/reverse_offset) | |
735 | +; ;stop | |
736 | +; indtg=fix(indtg) | |
737 | +; prmtg=prmtg[indtg-1] | |
738 | +; | |
739 | +; str=string(strmid(string_name,7,ii-7)+' ['+strmid(string_name,ii+1)+']: '+prmtg+' = ',format=frmt0)+string(res[i],format=frmt1) | |
740 | +; | |
741 | +; prv_str=strmid(string_name,7,ii-7) | |
742 | +; | |
743 | +; | |
744 | +; | |
745 | +; IF keyword_set(errors) THEN BEGIN | |
746 | +; str=str+textoidl(' \pm ')+string(errors(i),format=frmt1) | |
747 | +; ENDIF | |
748 | +; | |
749 | +; xxpos=use_legend_xpos*0.46 | |
750 | +; | |
751 | +; IF n_plgns gt 3 THEN BEGIN ;adapt the display of the plugins if there are more than three (display two columns) | |
752 | +; IF i eq inn+k THEN BEGIN | |
753 | +; k+=inn | |
754 | +; ;iscond=1 | |
755 | +; inn+=1 | |
756 | +; xxpos=use_legend_xpos*0.06 | |
757 | +; ENDIF | |
758 | +; ENDIF | |
759 | +; | |
760 | +; ; IF iscond THEN BEGIN | |
761 | +; ; inn+=1 | |
762 | +; ; xxpos=use_legend_xpos*0.06 | |
763 | +; ; ENDIF | |
764 | +; | |
765 | +; yypos=use_legend_ypos-(i-k)*use_legend_offset | |
766 | +; xyouts,xxpos,yypos,str,color=0,/normal,charsize=legend_charsize | |
767 | +; endif else begin | |
768 | +; IF STRUPCASE(strmid(strtrim(parameter_description,2),0,24)) eq '(*!DUSTEM_PARAMS).GRAINS' and STRUPCASE(strmid(strtrim(parameter_description,2),3,1,/reverse_offset)) EQ 'O' then begin | |
769 | +; indpop=fix(STRUPCASE(strmid(strtrim(parameter_description,2),12,1,/reverse_offset))) | |
770 | +; ;oo+=1 | |
771 | +; ;string_name=(((*!dustem_params).GRAINS).grain_type)[oo-1] | |
772 | +; string_name=(((*!dustem_params).GRAINS).grain_type)[indpop] | |
773 | +; ;stop | |
774 | +; endif | |
775 | +; k+=1 | |
776 | +; xxpos=use_legend_xpos*1.5 | |
777 | +; yypos=use_legend_ypos*1.03 | |
778 | +; xyouts,xxpos,yypos,'--Parameters--',color=0,/normal,charsize=legend_charsize | |
779 | +; yypos=use_legend_ypos-(i)*use_legend_offset | |
780 | +; xxpos=use_legend_xpos*1.14 | |
781 | +; str=string(string_name+' = ',format=frmt0)+string(res[i],format=frmt1) | |
782 | +; xyouts,xxpos,yypos,str,color=0,/normal,charsize=legend_charsize | |
783 | +; endelse | |
784 | +; ENDFOR | |
785 | +; ;stop | |
786 | +; ENDIF | |
787 | +; IF keyword_set(chi2) THEN BEGIN | |
788 | +; xxpos=1.29*use_legend_xpos | |
789 | +; yypos=1.13*0.84;use_legend_ypos | |
790 | +; xyouts,xxpos,yypos,string('chi2=',format=frmt0)+string(chi2,format=frmt2),color=0,/normal,charsize=legend_charsize | |
791 | +; ENDIF | |
792 | +; IF keyword_set(rchi2) THEN BEGIN | |
793 | +; xxpos=1.29*use_legend_xpos | |
794 | +; yypos=1.13*0.84-use_legend_offset;use_legend_ypos-use_legend_offset | |
795 | +; xyouts,xxpos,yypos,string('red. chi2=',format=frmt0)+string(rchi2,format=frmt2),color=0,/normal,charsize=legend_charsize | |
796 | +; ENDIF | |
797 | +; | |
798 | +; xtit=textoidl('\lambda (\mum)') | |
799 | +; ;cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,/nodata,xtit=xtit,ytit='Normalized',tit='',/xlog,xr=xr,/ys,/xs,yr=[0,2],ylog=0,position=[0.12,0.14,0.96,0.35],/noerase,yticks=2,ymino=2,xticklen=0.1 | |
800 | +; ;stop | |
801 | +; | |
802 | +; IF keyword_set(_extra) THEN BEGIN | |
803 | +; extra_kept={XR:[0.,0.]} | |
804 | +; extra_tags=tag_names(_extra) | |
805 | +; ind=where(extra_tags EQ 'XR',count) | |
806 | +; IF count NE 0 THEN extra_kept.XR=_extra.(ind[0]) ;ELSE extra_kept=0 | |
807 | +; ENDIF | |
808 | +; | |
809 | +; ;stop | |
810 | +; ;,position=[0.12,0.14,0.96,0.35] old position before your polfrac display modification | |
811 | +; if keyword_set(fpol) then begin | |
812 | +; cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,_extra=extra_kept,/nodata,xtit=xtit,ytit='Normalized',tit='',/xlog,/ys,/xs,yr=[0,2],ylog=0,position=[0.12,0.1,0.96,0.25],/noerase,yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.3 | |
813 | +; endif else cgplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,_extra=extra_kept,/nodata,xtit=xtit,ytit='Normalized',tit='',/xlog,/ys,/xs,yr=[0,2],ylog=0,position=[0.12,0.14,0.96,0.35],/noerase,yticks=2,ymino=2,xticklen=0.1,ytickformat='(F6.2)',charsize=1.3 | |
814 | +; ;plot the normalized data as well. | |
815 | +; IF count_spec NE 0 THEN BEGIN | |
816 | +; xx=((*!dustem_data.sed).wav)[ind_spec] | |
817 | +; yy=((*!dustem_data.sed).values/sed)[ind_spec] | |
818 | +; cgoplot,xx,yy,psym=16,symsize=1,thick=2,color=use_col_sed_spec | |
819 | +; trois_sigma=(3.*((*!dustem_data.sed).sigma)/2./sed)[ind_spec] | |
820 | +; cgerrplot,xx,yy-trois_sigma,yy+trois_sigma,color=use_col_sed_spec | |
821 | +; ENDIF | |
822 | +; IF count_filt NE 0 THEN BEGIN | |
823 | +; xx=((*!dustem_data.sed).wav)[ind_filt] | |
824 | +; yy=((*!dustem_data.sed).values/sed)[ind_filt] | |
825 | +; cgoplot,xx,yy,psym=16,symsize=1,thick=2,color='Dodger Blue' | |
826 | +; trois_sigma=(3.*((*!dustem_data.sed).sigma)/2./sed)[ind_filt] | |
827 | +; cgerrplot,xx,yy-trois_sigma,yy+trois_sigma,color='Dodger Blue' | |
828 | +; ENDIF | |
829 | +; | |
830 | +; ;stop | |
831 | +; ;cgoplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,psym=16,symsize=1,thick=2,color='Dodger Blue' | |
832 | +; cgoplot,10^!x.crange,replicate(1.,2),color='black',linestyle=0 | |
833 | +; ;cgoplot,st.sed.wav,spec/spec,color='black' | |
834 | +; ;cgerrplot,((*!dustem_data.sed).wav),((*!dustem_data.sed).values)/sed-3.*((*!dustem_data.sed).sigma)/2./sed,((*!dustem_data.sed).values)/sed+3.*((*!dustem_data.sed).sigma)/2./sed,color='Dodger Blue' | |
835 | +; | |
836 | +; | |
837 | +; if keyword_set(fpol) then begin | |
838 | +; plotsym,0,/fill | |
839 | +; cgplot, (*!dustem_data.polfrac).wav,(*!dustem_data.polfrac).values*100,/nodata,xtit='',tit=title,ytit='',/xlog,/ylog,/ys,/xs,position=[0.12,0.76,0.96,0.91],charsize=1.3,yr=[1.0E-1,30.0],/noerase,xticklen=0.1,xtickformat='(A1)',_extra=extra_kept;,xr=_extra.xr | |
840 | +; xxpos=use_legend_xpos*0.35 | |
841 | +; yypos=use_legend_ypos*1.25 | |
842 | +; xyouts,xxpos,yypos,'Polarization fraction (%)',color=cgcolor('purple'),charsize=legend_charsize,/normal | |
843 | +; yypos=use_legend_ypos*1.20 | |
844 | +; stringg='Polarization SED '+'('+textoidl('P_{\nu}')+')' | |
845 | +; xyouts,xxpos,yypos,stringg,color=cgcolor('teal'),charsize=legend_charsize,/normal | |
846 | +; pilotfx=fpol(0);((*!dustem_data.polfrac).values)(0);fpol(0); | |
847 | +; cgoplot, (*!dustem_data.polfrac).wav,(*!dustem_data.polfrac).values*100,charsize=1.3,psym=8,syms=1,thick=2,color='Dodger Blue' | |
848 | +; cgoplot, st.polsed.wav,(specpol/spec)*100/pilotfx*((*!dustem_data.polfrac).values)(0),color='purple' | |
849 | +; cgoplot, (*!dustem_data.polfrac).wav,fpol*100/pilotfx*((*!dustem_data.polfrac).values)(0),color='Red',psym=6,syms=1 | |
850 | +; ;fpol=abs(fpol) | |
851 | +; ;delp=(*!dustem_data.polfrac).values*100-fpol*100/pilotfx*((*!dustem_data.polfrac).values)(0) | |
852 | +; ;cgoplot, ((*!dustem_data.polfrac).wav),((*!dustem_data.polfrac).values*100+delp),charsize=1.3,color='black',linestyle=2 | |
853 | +; ;stop | |
854 | +; endif | |
855 | +; | |
856 | +; IF keyword_set(ps) THEN BEGIN | |
857 | +; device,/close | |
858 | +; set_plot,'X' | |
859 | +; ENDIF | |
860 | +; | |
861 | +; ;stop | |
862 | +; | |
863 | +; the_end: | |
864 | + | |
865 | +END | ... | ... |