Commit 21d1a616d4739eb3dd0e13f9889246bdc0edc851

Authored by Jean-Philippe Bernard
2 parents bec7b3e8 92e2e66f
Exists in master

Merge branch 'master' of https://gitlab.irap.omp.eu/OV-GSO-DC/dustem-wrapper_idl

src/idl/dustem_check_data.pro
1 -FUNCTION dustem_check_data, sed=sed,ext=ext,ist=ist,pst=pst,qst=qst,ust=ust,exst=exst,pexst=pexst,qexst=qexst,uexst=uexst 1 +FUNCTION dustem_check_data, sed=sed,ext=ext,fpol=fpol,ist=ist,pst=pst,fpst=fpst,qst=qst,ust=ust,exst=exst,pexst=pexst,qexst=qexst,uexst=uexst
2 2
3 3
4 ;THIS PROCEDURE CHECKS THE DATA PROVIDED BY THE USER AND RETURNS DIFFERENT STRUCTURES TO DEFINE (SET) THE COMPOSITE DATA FITTING STRUCTURE (!dustem_data) 4 ;THIS PROCEDURE CHECKS THE DATA PROVIDED BY THE USER AND RETURNS DIFFERENT STRUCTURES TO DEFINE (SET) THE COMPOSITE DATA FITTING STRUCTURE (!dustem_data)
@@ -23,6 +23,7 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -23,6 +23,7 @@ IF KEYWORD_SET(sed) THEN BEGIN
23 ;INITIALIZING OUTPUT STRUCTURES 23 ;INITIALIZING OUTPUT STRUCTURES
24 ist = obs_st 24 ist = obs_st
25 pst = ist 25 pst = ist
  26 + fpst = ist
26 qst = ist 27 qst = ist
27 ust = ist 28 ust = ist
28 ;This allows the user to fit polsed, qsed and used individually. 29 ;This allows the user to fit polsed, qsed and used individually.
@@ -39,8 +40,7 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -39,8 +40,7 @@ IF KEYWORD_SET(sed) THEN BEGIN
39 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 40 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
40 IF strupcase(ans) EQ 'N' THEN BEGIN 41 IF strupcase(ans) EQ 'N' THEN BEGIN
41 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 42 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
42 - message, 'Aborting ...',/continue  
43 - stop 43 + message, 'Aborting ...'
44 ENDIF 44 ENDIF
45 ENDIF 45 ENDIF
46 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 46 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -59,11 +59,11 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -59,11 +59,11 @@ IF KEYWORD_SET(sed) THEN BEGIN
59 ans='' 59 ans=''
60 pst.values=sed.largeP 60 pst.values=sed.largeP
61 pst.sigma=sqrt(abs(sed.sigma_largeP)) 61 pst.sigma=sqrt(abs(sed.sigma_largeP))
62 - ;Testig if there is LargeP data. If not move to qsed data 62 + ;Testig if there is LargeP data. If not move to polfrac data (fpol)
63 ind = where(sed.largeP NE la_undef() and finite(sed.largeP) EQ 1 and sed.sigma_largeP NE la_undef() and finite(sed.sigma_largeP) EQ 1,NP) ;Testing on the nan values is needed to move to testing the other data fields (because if the dataset is full of Nans but not la_undef(), the code will think it's valid dta) 63 ind = where(sed.largeP NE la_undef() and finite(sed.largeP) EQ 1 and sed.sigma_largeP NE la_undef() and finite(sed.sigma_largeP) EQ 1,NP) ;Testing on the nan values is needed to move to testing the other data fields (because if the dataset is full of Nans but not la_undef(), the code will think it's valid dta)
64 IF NP EQ 0 THEN BEGIN 64 IF NP EQ 0 THEN BEGIN
65 pst = ptr_new() 65 pst = ptr_new()
66 - goto, qzone 66 + goto, fpzone
67 ENDIF ELSE BEGIN 67 ENDIF ELSE BEGIN
68 ind = where(finite(sed.largeP) EQ 0 or finite(sed.sigma_largeP) EQ 0, countnokp) ;Format is not okay if there are nan values but the wrapper recognizes the la_undef() value 68 ind = where(finite(sed.largeP) EQ 0 or finite(sed.sigma_largeP) EQ 0, countnokp) ;Format is not okay if there are nan values but the wrapper recognizes the la_undef() value
69 IF countnokp NE 0 THEN BEGIN 69 IF countnokp NE 0 THEN BEGIN
@@ -72,8 +72,7 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -72,8 +72,7 @@ IF KEYWORD_SET(sed) THEN BEGIN
72 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 72 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
73 IF strupcase(ans) EQ 'N' THEN BEGIN 73 IF strupcase(ans) EQ 'N' THEN BEGIN
74 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 74 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
75 - message, 'Aborting ...',/continue  
76 - stop 75 + message, 'Aborting ...'
77 ENDIF 76 ENDIF
78 ENDIF 77 ENDIF
79 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 78 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -86,8 +85,41 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -86,8 +85,41 @@ IF KEYWORD_SET(sed) THEN BEGIN
86 values = pst.values(testp) 85 values = pst.values(testp)
87 sigma = pst.sigma(testp) 86 sigma = pst.sigma(testp)
88 pst={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma} 87 pst={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma}
89 - ENDIF  
90 - ENDELSE 88 + ENDIF
  89 + ENDELSE
  90 + fpzone:
  91 + ans=''
  92 + fpst.values=sed.smallp
  93 + fpst.sigma=sqrt(abs(sed.sigma_smallp))
  94 + ;Testig if there is smallp data. If not move to qsed data
  95 + ind = where(sed.smallP NE la_undef() and finite(sed.smallP) EQ 1 and sed.sigma_smallP NE la_undef() and finite(sed.sigma_smallP) EQ 1,NSP) ;Testing on the nan values is needed to move to testing the other data fields (because if the dataset is full of Nans but not la_undef(), the code will think it's valid dta)
  96 + IF NSP EQ 0 THEN BEGIN
  97 + fpst = ptr_new()
  98 + ;goto, qzone
  99 + goto, qzone
  100 + ENDIF ELSE BEGIN
  101 + ind = where(finite(sed.smallP) EQ 0 or finite(sed.sigma_smallP) EQ 0, countnoksp) ;Format is not okay if there are nan values but the wrapper recognizes the la_undef() value
  102 + IF countnoksp NE 0 THEN BEGIN
  103 + message, "SED format isn't met. NaN value(s) detected in SmallP data.",/continue
  104 + message, 'Without automatic format fitering you cannot proceed.',/continue
  105 + read, ans, prompt='Would you like automatic format filtering? (Y/N):'
  106 + IF strupcase(ans) EQ 'N' THEN BEGIN
  107 + message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
  108 + message, 'Aborting ...'
  109 + ENDIF
  110 + ENDIF
  111 + IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
  112 + ELSE message, 'Data format is met. Removal of undefined data points...',/continue
  113 + testsp=where(sed.sigma_smallP NE 0. and finite(sed.sigma_smallP) EQ 1 and sed.sigma_smallP NE la_undef() and sed.smallP NE la_undef() and finite(sed.smallP) EQ 1,ctestsp)
  114 + IF ctestsp NE 0 THEN BEGIN
  115 + instru_names = fpst.instru_names(testsp)
  116 + filt_names = fpst.filt_names(testsp)
  117 + wav = fpst.wav(testsp)
  118 + values = fpst.values(testsp)
  119 + sigma = fpst.sigma(testsp)
  120 + fpst={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma}
  121 + ENDIF
  122 + ENDELSE
91 qzone: 123 qzone:
92 ans='' 124 ans=''
93 qst.values=sed.StokesQ 125 qst.values=sed.StokesQ
@@ -105,8 +137,7 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -105,8 +137,7 @@ IF KEYWORD_SET(sed) THEN BEGIN
105 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 137 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
106 IF strupcase(ans) EQ 'N' THEN BEGIN 138 IF strupcase(ans) EQ 'N' THEN BEGIN
107 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 139 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
108 - message, 'Aborting ...',/continue  
109 - stop 140 + message, 'Aborting ...'
110 ENDIF 141 ENDIF
111 ENDIF 142 ENDIF
112 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 143 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -138,8 +169,7 @@ IF KEYWORD_SET(sed) THEN BEGIN @@ -138,8 +169,7 @@ IF KEYWORD_SET(sed) THEN BEGIN
138 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 169 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
139 IF strupcase(ans) EQ 'N' THEN BEGIN 170 IF strupcase(ans) EQ 'N' THEN BEGIN
140 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 171 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
141 - message, 'Aborting ...',/continue  
142 - stop 172 + message, 'Aborting ...'
143 ENDIF 173 ENDIF
144 ENDIF 174 ENDIF
145 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 175 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -191,8 +221,7 @@ IF KEYWORD_SET(ext) THEN begin @@ -191,8 +221,7 @@ IF KEYWORD_SET(ext) THEN begin
191 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 221 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
192 IF strupcase(ans) EQ 'N' THEN BEGIN 222 IF strupcase(ans) EQ 'N' THEN BEGIN
193 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 223 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
194 - message, 'Aborting ...',/continue  
195 - stop 224 + message, 'Aborting ...'
196 ENDIF 225 ENDIF
197 ENDIF 226 ENDIF
198 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 227 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -225,8 +254,7 @@ IF KEYWORD_SET(ext) THEN begin @@ -225,8 +254,7 @@ IF KEYWORD_SET(ext) THEN begin
225 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 254 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
226 IF strupcase(ans) EQ 'N' THEN BEGIN 255 IF strupcase(ans) EQ 'N' THEN BEGIN
227 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 256 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
228 - message, 'Aborting ...',/continue  
229 - stop 257 + message, 'Aborting ...'
230 ENDIF 258 ENDIF
231 ENDIF 259 ENDIF
232 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 260 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -260,8 +288,7 @@ IF KEYWORD_SET(ext) THEN begin @@ -260,8 +288,7 @@ IF KEYWORD_SET(ext) THEN begin
260 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 288 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
261 IF strupcase(ans) EQ 'N' THEN BEGIN 289 IF strupcase(ans) EQ 'N' THEN BEGIN
262 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 290 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
263 - message, 'Aborting ...',/continue  
264 - stop 291 + message, 'Aborting ...'
265 ENDIF 292 ENDIF
266 ENDIF 293 ENDIF
267 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 294 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
@@ -294,8 +321,7 @@ IF KEYWORD_SET(ext) THEN begin @@ -294,8 +321,7 @@ IF KEYWORD_SET(ext) THEN begin
294 read, ans, prompt='Would you like automatic format filtering? (Y/N):' 321 read, ans, prompt='Would you like automatic format filtering? (Y/N):'
295 IF strupcase(ans) EQ 'N' THEN BEGIN 322 IF strupcase(ans) EQ 'N' THEN BEGIN
296 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue 323 message,'You have chosen not to use automatic filtering. Please adjust the SED format.',/continue
297 - message, 'Aborting ...',/continue  
298 - stop 324 + message, 'Aborting ...'
299 ENDIF 325 ENDIF
300 ENDIF 326 ENDIF
301 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $ 327 IF strupcase(ans) EQ 'Y' THEN message, 'You have chosen automatic format filtering. Removal of undefined data points...',/continue $
src/idl/dustem_compute_polsed.pro
@@ -48,14 +48,14 @@ IF not keyword_set(stp) THEN BEGIN @@ -48,14 +48,14 @@ IF not keyword_set(stp) THEN BEGIN
48 ENDIF 48 ENDIF
49 49
50 If keyword_set(result) THEN result=stp 50 If keyword_set(result) THEN result=stp
51 -fact = 1.e4*1.E20/(4.*!pi)/(3.e8/1.e-6/(stp.polsed).wav)*1.e20/1.e7 51 +fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/(stp.polsed).wav)*1.e20/1.e7
52 52
53 P = stp.polsed.em_tot*fact;1.00e17/(4.*!pi) ;This is Polarized intensity P 53 P = stp.polsed.em_tot*fact;1.00e17/(4.*!pi) ;This is Polarized intensity P
54 -I = stp.sed.em_tot*fact;1.00e17/(4.*!pi) ;This is Total intensity I 54 +stI = stp.sed.em_tot*fact;1.00e17/(4.*!pi) ;This is Total intensity I
55 out=0. 55 out=0.
56 Nwaves=(size(P))[1] 56 Nwaves=(size(P))[1]
57 57
58 -frac=P/I 58 +frac=P/stI
59 tes=where(finite(frac) eq 0) 59 tes=where(finite(frac) eq 0)
60 frac(tes)=0. 60 frac(tes)=0.
61 61
@@ -77,7 +77,7 @@ FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN @@ -77,7 +77,7 @@ FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
77 ENDFOR 77 ENDFOR
78 78
79 79
80 -IF ~isa(Q_spec) && ~isa(U_spec) THEN polar_ippsi2iqu,I,Q_spec,U_spec,frac,replicate(0.,Nwaves) 80 +IF ~isa(Q_spec) && ~isa(U_spec) THEN polar_ippsi2iqu,stI,Q_spec,U_spec,frac,replicate(0.,Nwaves)
81 81
82 82
83 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN 83 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
@@ -92,13 +92,12 @@ FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN @@ -92,13 +92,12 @@ FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
92 92
93 ENDFOR 93 ENDFOR
94 94
95 -  
96 P=sqrt(Q_spec^2+U_spec^2) 95 P=sqrt(Q_spec^2+U_spec^2)
97 96
98 ENDIF 97 ENDIF
99 98
100 -dustem_polsed = (*!dustem_data.polsed).values * 0.  
101 - 99 +IF isa(!dustem_data.polsed) THEN dustem_polsed = (*!dustem_data.polsed).values * 0. ELSE dustem_polsed = (*!dustem_data.polfrac).values * 0.
  100 +;stop
102 101
103 if not isarray(P) THEN stop 102 if not isarray(P) THEN stop
104 103
@@ -109,22 +108,25 @@ ENDIF ELSE BEGIN @@ -109,22 +108,25 @@ ENDIF ELSE BEGIN
109 message,'SKIPPING color correction calculations',/info 108 message,'SKIPPING color correction calculations',/info
110 ENDELSE 109 ENDELSE
111 110
112 -ind_polsed=where((*!dustem_data.polsed).filt_names NE 'SPECTRUM',count_polsed)  
113 -  
114 -IF count_polsed NE 0 THEN BEGIN  
115 - filter_names=((*!dustem_data.polsed).filt_names)(ind_polsed) 111 +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)
116 112
  113 +IF count_polsed NE 0 THEN BEGIN
  114 + 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 spolsed=dustem_cc(stp.polsed.wav,P,filter_names,cc=cc) 115 spolsed=dustem_cc(stp.polsed.wav,P,filter_names,cc=cc)
118 dustem_polsed[ind_polsed]=spolsed 116 dustem_polsed[ind_polsed]=spolsed
119 -  
120 ENDIF 117 ENDIF
121 118
122 -;For spectrum data points, interpolate in log-log 119 +
  120 +;stop
  121 +
  122 +
  123 +;For spectrum data points, interpolate in log-log.
123 ;Linear interpolation leads to wrong values, in particular where few 124 ;Linear interpolation leads to wrong values, in particular where few
124 ;wavelengths points exist in the model (long wavelengths). 125 ;wavelengths points exist in the model (long wavelengths).
125 -ind_spec=where((*!dustem_data.polsed).filt_names EQ 'SPECTRUM',count_spec) 126 +
  127 +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)
126 IF count_spec NE 0 THEN BEGIN 128 IF count_spec NE 0 THEN BEGIN
127 - dustem_polsed(ind_spec)=interpol(P,stp.polsed.wav,(((*!dustem_data.polsed).wav)(ind_spec))) 129 + 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)))
128 ENDIF 130 ENDIF
129 out_st=stp 131 out_st=stp
130 132
src/idl/dustem_init.pro
@@ -200,7 +200,11 @@ defsysv,'!dustem_show_plot',1 ;0=show no plot @@ -200,7 +200,11 @@ defsysv,'!dustem_show_plot',1 ;0=show no plot
200 ;== This is for the default mode 200 ;== This is for the default mode
201 dustem_inputs={GRAIN:'GRAIN.DAT',ISRF:'ISRF.DAT',ALIGN:'ALIGN.DAT'} 201 dustem_inputs={GRAIN:'GRAIN.DAT',ISRF:'ISRF.DAT',ALIGN:'ALIGN.DAT'}
202 !dustem_inputs=ptr_new(dustem_inputs) 202 !dustem_inputs=ptr_new(dustem_inputs)
  203 +
  204 +
203 defsysv, '!dustem_HCD', ptr_new(1.00E20) ;This is a dumb thing I added but will shortly remove it 205 defsysv, '!dustem_HCD', ptr_new(1.00E20) ;This is a dumb thing I added but will shortly remove it
  206 +
  207 +
204 ;===This is the Desert option 208 ;===This is the Desert option
205 209
206 IF keyword_set(model) THEN BEGIN 210 IF keyword_set(model) THEN BEGIN
@@ -247,7 +251,11 @@ defsysv, '!dustem_model', model @@ -247,7 +251,11 @@ defsysv, '!dustem_model', model
247 'NY_MODELA':BEGIN 251 'NY_MODELA':BEGIN
248 (*!dustem_inputs).grain='GRAIN_NY_MODELA.DAT' 252 (*!dustem_inputs).grain='GRAIN_NY_MODELA.DAT'
249 (*!dustem_inputs).align='ALIGN_G17_MODELA.DAT' 253 (*!dustem_inputs).align='ALIGN_G17_MODELA.DAT'
250 - END 254 + END
  255 + ;This is a user-defined model
  256 + 'USER_MODEL':BEGIN
  257 + (*!dustem_inputs).grain='GRAIN_USER.DAT'
  258 + END
251 ELSE:BEGIN 259 ELSE:BEGIN
252 message,'model '+model+' unknown',/continue 260 message,'model '+model+' unknown',/continue
253 message,'Known models are COMPIEGNE_ETAL2010,DBP90,DL01,DL07,AJ13,G17_MODELA,G17_MODELB,G17_MODELC,G17_MODELD,THEMIS',/continue 261 message,'Known models are COMPIEGNE_ETAL2010,DBP90,DL01,DL07,AJ13,G17_MODELA,G17_MODELB,G17_MODELC,G17_MODELD,THEMIS',/continue
src/idl/dustem_init_parinfo.pro
@@ -10,7 +10,7 @@ PRO dustem_init_parinfo,pd,iv, $ @@ -10,7 +10,7 @@ PRO dustem_init_parinfo,pd,iv, $
10 dustem_set_func_ind,pd,iv 10 dustem_set_func_ind,pd,iv
11 11
12 12
13 -one_parinfo={value:0.D0, fixed:0, limited:[0,0], limits:[0.D0,0], parname:'', relstep:0., step:0.5, mpside:0, tied:''} 13 +one_parinfo={value:0.D0, fixed:0, limited:[0,0], limits:[0.D0,0], parname:'', relstep:0.5, step:0.0, mpside:0, tied:''}
14 Npar=n_elements(pd) 14 Npar=n_elements(pd)
15 dustem_parinfo=replicate(one_parinfo,Npar) 15 dustem_parinfo=replicate(one_parinfo,Npar)
16 FOR i=0L,Npar-1 DO BEGIN 16 FOR i=0L,Npar-1 DO BEGIN
@@ -60,5 +60,5 @@ ENDIF @@ -60,5 +60,5 @@ ENDIF
60 suite2: 60 suite2:
61 61
62 defsysv,'!dustem_parinfo',ptr_new(dustem_parinfo) 62 defsysv,'!dustem_parinfo',ptr_new(dustem_parinfo)
63 - 63 +;stop
64 END 64 END
src/idl/dustem_mpfit_run.pro
1 -FUNCTION dustem_mpfit_run,x,p_min,_EXTRA=extra 1 +FUNCTION dustem_mpfit_run,x,p_min,_EXTRA=_extra
2 2
3 ;+ 3 ;+
4 ; NAME: 4 ; NAME:
@@ -55,12 +55,6 @@ dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values) @@ -55,12 +55,6 @@ dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values)
55 st = dustem_run(p_dim) 55 st = dustem_run(p_dim)
56 st_model=dustem_read_all(!dustem_soft_dir) 56 st_model=dustem_read_all(!dustem_soft_dir)
57 57
58 -  
59 -  
60 -;problem that needs fixing - case of the composite ISRF  
61 -; st=st if you want to make the isrf thingy work. This is because dustem_activate_plugins requires the st structure but in the case of the composite ISRF the problem is that the wrapper's first read isrf is a MATHIS one so the first abundances the wrapper gets from dustem are the product of dust heated by the MATHIS ISRF  
62 -  
63 -  
64 chi2_sed = 0 58 chi2_sed = 0
65 chi2_ext = 0 59 chi2_ext = 0
66 chi2_polext = 0 60 chi2_polext = 0
@@ -105,7 +99,7 @@ dustem_out = [0] @@ -105,7 +99,7 @@ dustem_out = [0]
105 ind_data_tag=dustem_data_tag(count=count_data_tag) 99 ind_data_tag=dustem_data_tag(count=count_data_tag)
106 100
107 ;if exist('./noplot') then !dustem_show_plot = 0 else if !dustem_show_plot eq 0 then !dustem_show_plot = 1 101 ;if exist('./noplot') then !dustem_show_plot = 0 else if !dustem_show_plot eq 0 then !dustem_show_plot = 1
108 - 102 +;stop
109 FOR i_tag=0,count_data_tag-1 DO BEGIN 103 FOR i_tag=0,count_data_tag-1 DO BEGIN
110 104
111 ;stop 105 ;stop
@@ -113,11 +107,9 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN @@ -113,11 +107,9 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
113 ;print,i_tag,ind_data_tag(i_tag) 107 ;print,i_tag,ind_data_tag(i_tag)
114 ;print,tagnames(ind_data_tag(i_tag)) 108 ;print,tagnames(ind_data_tag(i_tag))
115 109
116 -  
117 CASE tagnames(ind_data_tag(i_tag)) OF 110 CASE tagnames(ind_data_tag(i_tag)) OF
118 - 111 +
119 'SED' : BEGIN 112 'SED' : BEGIN
120 -  
121 dustem_sed = dustem_compute_sed(p_dim,st);dustem_compute_sed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron) 113 dustem_sed = dustem_compute_sed(p_dim,st);dustem_compute_sed(p_dim,st,cont=cont,freefree=freefree,synchrotron=synchrotron)
122 chi2_sed = total(((*!dustem_data.sed).values-dustem_sed)^2/(*!dustem_data.sed).sigma^2) 114 chi2_sed = total(((*!dustem_data.sed).values-dustem_sed)^2/(*!dustem_data.sed).sigma^2)
123 n_sed = n_elements((*!dustem_data.sed).values) 115 n_sed = n_elements((*!dustem_data.sed).values)
@@ -136,22 +128,96 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN @@ -136,22 +128,96 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
136 print,"Best SED chi2 obtained if f_HI = ",alpha, " or if we multiply model by ",beta 128 print,"Best SED chi2 obtained if f_HI = ",alpha, " or if we multiply model by ",beta
137 (*!dustem_fit).chi2=chi2_sed 129 (*!dustem_fit).chi2=chi2_sed
138 (*!dustem_fit).rchi2=rchi2_sed 130 (*!dustem_fit).rchi2=rchi2_sed
139 -  
140 ; Plot if needed 131 ; Plot if needed
141 IF !dustem_show_plot NE 0 THEN BEGIN 132 IF !dustem_show_plot NE 0 THEN BEGIN
  133 +
142 ;title='DUSTEM WRAP('+strtrim(string(win),2)+')' 134 ;title='DUSTEM WRAP('+strtrim(string(win),2)+')'
143 window,win,title='DUSTEM WRAP (SED)' 135 window,win,title='DUSTEM WRAP (SED)'
144 136
145 ;cgwindow,WMULTI=[2,2,1],/CURRENT 137 ;cgwindow,WMULTI=[2,2,1],/CURRENT
146 -  
147 - 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  
148 -  
149 - 138 + ;I.C
  139 + ;undeprecated the use of polfrac here
  140 + ;**********
  141 + ;I added this block so I can plot polfrac inside the sed window
  142 + ;I will probably remove it
  143 + ;**********
  144 + ;test if polfrac is in tagnames:
  145 + ;another problem is that sed and pol data don't have the same filters.
  146 + varvar=where(tagnames eq 'POLFRAC', testfpol)
  147 + if testfpol ne 0 then begin
  148 + if !run_lin then begin
  149 + dustem_polsed = dustem_compute_polsed(p_dim,st) ; this quantity hasn't been computed yet that is why this line is present here.
  150 + ind_filt=where((*!dustem_data.polfrac).filt_names NE 'SPECTRUM',count_filt) ;locating the filters of polfrac=smallp in SED xcat
  151 + ind_fspec=where((*!dustem_data.polfrac).filt_names EQ 'SPECTRUM',count_fspec) ;locating the spectrum points in polfrac data. Later testing will have to be on the wavelengths
  152 +
  153 + ;dustem_sed and dustem_polsed might not have the same length thus this block.
  154 + ;I'm not so sure about this...
  155 +
  156 + If n_elements(dustem_sed) ne n_elements(dustem_polsed) then begin
  157 + if n_elements(dustem_sed) gt n_elements(dustem_polsed) then begin
  158 + dustem_polsed_x = dustem_polsed
  159 + dustem_sed_x = dustem_polsed ;meaning dustem_sed needs to be modified
  160 + ;matching the filter data points
  161 + IF count_filt ne 0 then begin
  162 + for i=0L,count_filt-1 do begin
  163 + j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt)
  164 + if testfilt ne 0 then dustem_sed_x(ind_filt(i)) = dustem_sed(j(0))
  165 + endfor
  166 + endif
  167 + ;matching the spectrum data points
  168 + IF count_fspec ne 0 then begin
  169 + for i=0L,count_fspec-1 do begin
  170 + j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec)
  171 + if testspec ne 0 then dustem_sed_x((ind_fspec(i))) = dustem_sed(j(0))
  172 + endfor
  173 + endif
  174 + endif ELSE begin
  175 +
  176 + ;I think I will have errors here!! The thing is I'm trying to make this work without (*!dustem_data.polsed) which is hard.
  177 +
  178 + dustem_polsed_x = dustem_sed
  179 + dustem_sed_x = dustem_sed ;meaning dustem_polsed needs to be modified
  180 + ;matching the filter data points
  181 + IF count_filt ne 0 then begin
  182 + for i=0L,count_filt-1 do begin
  183 + j=where((*!dustem_data.sed).filt_names EQ (*!dustem_data.polfrac).filt_names(ind_filt(i)),testfilt)
  184 + if testfilt ne 0 then dustem_polsed_x(ind_filt(i)) = dustem_polsed(j(0))
  185 + endfor
  186 + endif
  187 + ;matching the spectrum data points
  188 + IF count_fspec ne 0 then begin
  189 + for i=0L,count_fspec-1 do begin
  190 + j=where((*!dustem_data.sed).wav EQ (*!dustem_data.polfrac).wav(ind_fspec(i)),testspec)
  191 + if testspec ne 0 then dustem_polsed_x((ind_fspec(i))) = dustem_polsed(j(0))
  192 + endfor
  193 + endif
  194 +
  195 + ENDELSE
  196 + endif ELSE BEGIN
  197 + dustem_polsed_x = dustem_polsed
  198 + dustem_sed_x = dustem_sed
  199 + ENDELSE
  200 +
  201 + dustem_polfrac = dustem_polsed_x/dustem_sed_x
  202 + ;stop
  203 + ;stop
  204 + chi2_polfrac = total(((*!dustem_data.polfrac).values-dustem_polfrac)^2/(*!dustem_data.polfrac).sigma^2)
  205 + n_polfrac = n_elements((*!dustem_data.polfrac).values)
  206 + rchi2_polfrac = chi2_polfrac / n_polfrac
  207 + wrchi2_polfrac = rchi2_polfrac * !fit_rchi2_weight.polfrac
  208 + message,"chi2 POLFRAC = "+strtrim(chi2_polfrac,2)+" rchi2 POLFRAC = "+strtrim(rchi2_polfrac,2),/continue ;," weighted rchi2 POLFRAC=",wrchi2_polfrac
  209 + dustem_out = [ dustem_out, dustem_polfrac ]
  210 + fpol=dustem_polfrac ; problem because extra structure does not get updated so you actually need the 'extra' procedure you haven't finihed coding.
  211 + endif
  212 + endif
  213 + ;stop
  214 + 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
  215 +
150 ;stop 216 ;stop
151 ENDIF 217 ENDIF
152 218
153 dustem_out = [ dustem_out, dustem_sed ] 219 dustem_out = [ dustem_out, dustem_sed ]
154 - 220 +
155 END 221 END
156 222
157 'EXT' : BEGIN 223 'EXT' : BEGIN
@@ -394,7 +460,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN @@ -394,7 +460,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
394 win+=1 460 win+=1
395 window ,win ,title='DUSTEM WRAP (QSED)' 461 window ,win ,title='DUSTEM WRAP (QSED)'
396 titstq='Stokes Q Polarization Intensity' 462 titstq='Stokes Q Polarization Intensity'
397 - ytitstq=textoidl('Q_\nu (W/m^2/HZ/sr) for N_H=10^{20} H/cm^2') 463 + ytitstq=textoidl('Q_\nu (W/m^2/Hz/sr) for N_H=10^{20} H/cm^2')
398 xtit=textoidl('\lambda (\mum)') 464 xtit=textoidl('\lambda (\mum)')
399 xr=[10,2e4] 465 xr=[10,2e4]
400 normpol=Q_spec*fact 466 normpol=Q_spec*fact
@@ -579,9 +645,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN @@ -579,9 +645,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
579 645
580 END 646 END
581 647
582 -  
583 - ELSE : stop  
584 - 648 + ELSE : IF tagnames(ind_data_tag(i_tag)) NE 'POLFRAC' THEN stop
585 ENDCASE 649 ENDCASE
586 650
587 ENDFOR 651 ENDFOR
src/idl/dustem_plot_fit_sed.pro
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 res=res,errors=errors,chi2=chi2,rchi2=rchi2, $ 2 res=res,errors=errors,chi2=chi2,rchi2=rchi2, $
3 no_spec_error=no_spec_error,title=title,$;xtit=xtit,ytit=ytit,xr=xr,yr=yr $ 3 no_spec_error=no_spec_error,title=title,$;xtit=xtit,ytit=ytit,xr=xr,yr=yr $
4 help=help,win=win,ps=ps, $ 4 help=help,win=win,ps=ps, $
5 - legend_xpos=legend_xpos,legend_ypos=legend_ypos,legend_offset=legend_offset, $ 5 + legend_xpos=legend_xpos,legend_ypos=legend_ypos,legend_offset=legend_offset,fpol=fpol, $
6 _extra=_extra 6 _extra=_extra
7 7
8 ; NAME: 8 ; NAME:
@@ -59,11 +59,10 @@ IF keyword_set(ps) THEN BEGIN @@ -59,11 +59,10 @@ IF keyword_set(ps) THEN BEGIN
59 ENDIF ELSE BEGIN 59 ENDIF ELSE BEGIN
60 60
61 set_plot,'X' 61 set_plot,'X'
62 - IF keyword_set(win) then window,win 62 + IF keyword_set(win) then window,win;,xsize=600,ysize=800
63 ENDELSE 63 ENDELSE
64 64
65 fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 65 fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7
66 -  
67 ;use_col_data_filt=70 66 ;use_col_data_filt=70
68 ;use_col_sed_spec=170 67 ;use_col_sed_spec=170
69 use_col_data_filt='blue' 68 use_col_data_filt='blue'
@@ -89,7 +88,7 @@ ENDELSE @@ -89,7 +88,7 @@ ENDELSE
89 88
90 89
91 spec = st.sed.em_tot * fact 90 spec = st.sed.em_tot * fact
92 - 91 +if keyword_set(fpol) then specpol = st.polsed.em_tot * fact
93 ;ADDING PLUGIN(S) TO SPECTRUM---------------- 92 ;ADDING PLUGIN(S) TO SPECTRUM----------------
94 ;if n_tags(!dustem_data.sed) gt 1 then begin 93 ;if n_tags(!dustem_data.sed) gt 1 then begin
95 scopes=tag_names((*!dustem_scope)) 94 scopes=tag_names((*!dustem_scope))
@@ -97,6 +96,14 @@ IF scopes[0] NE 'NONE' THEN BEGIN @@ -97,6 +96,14 @@ IF scopes[0] NE 'NONE' THEN BEGIN
97 ;IF ptr_valid(!dustem_plugin) THEN BEGIN 96 ;IF ptr_valid(!dustem_plugin) THEN BEGIN
98 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN 97 FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
99 IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0] 98 IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_SED') THEN spec+=(*(*!dustem_plugin).(i))[*,0]
  99 + if keyword_set(fpol) then begin
  100 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'REPLACE_QSED') THEN specpol=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
  101 + endif
  102 + ENDFOR
  103 + FOR i=0L,n_tags(*!dustem_scope)-1 DO BEGIN
  104 + if keyword_set(fpol) then begin
  105 + IF total(strsplit((*(*!dustem_scope).(i)),'+',/extract) EQ 'ADD_QSED') THEN specpol+=sqrt(((*(*!dustem_plugin).(i))[*,1])^2+((*(*!dustem_plugin).(i))[*,2])^2)
  106 + endif
100 ENDFOR 107 ENDFOR
101 ENDIF 108 ENDIF
102 ;endif 109 ;endif
@@ -127,12 +134,23 @@ IF keyword_set(xtit) THEN xtit = xtit ELSE xtit = textoidl('\lambda (\mum)') @@ -127,12 +134,23 @@ IF keyword_set(xtit) THEN xtit = xtit ELSE xtit = textoidl('\lambda (\mum)')
127 134
128 IF keyword_set(ytit) THEN ytit = ytit ELSE ytit = textoidl('Brightness/N_H (MJy/sr/H)') 135 IF keyword_set(ytit) THEN ytit = ytit ELSE ytit = textoidl('Brightness/N_H (MJy/sr/H)')
129 136
  137 +
130 ;deffo define a title variable here. The procedures are not communicating with each other. 138 ;deffo define a title variable here. The procedures are not communicating with each other.
131 139
  140 +;###############################
  141 +if keyword_set(fpol) then begin
  142 + if !run_lin then begin
  143 + cgDisplay, 600, 500
  144 + 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
  145 + endif
  146 +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
  147 +;###############################
  148 +
  149 +
132 ;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)' 150 ;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)'
133 -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  
134 151
135 152
  153 +;stop
136 ;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)' 154 ;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)'
137 155
138 ;this is where you will add the normalized sed 156 ;this is where you will add the normalized sed
@@ -185,8 +203,8 @@ IF !dustem_show_plot EQ 2 THEN BEGIN @@ -185,8 +203,8 @@ IF !dustem_show_plot EQ 2 THEN BEGIN
185 ENDIF ELSE BEGIN 203 ENDIF ELSE BEGIN
186 norm = spec * 0. + 1 204 norm = spec * 0. + 1
187 ENDELSE 205 ENDELSE
  206 +use_cols[1]='Cornflower'
188 FOR i=0L,Ngrains-1 DO BEGIN 207 FOR i=0L,Ngrains-1 DO BEGIN
189 - use_cols[1]='Cornflower'  
190 cgoplot,st.sed.wav,st.sed.(i+1)*fact/norm,color=use_cols[i],linestyle=use_lines[i] 208 cgoplot,st.sed.wav,st.sed.(i+1)*fact/norm,color=use_cols[i],linestyle=use_lines[i]
191 ENDFOR 209 ENDFOR
192 210
@@ -213,6 +231,7 @@ ENDIF @@ -213,6 +231,7 @@ ENDIF
213 231
214 232
215 cgoplot,st.sed.wav,spec/norm,color=use_col_tot,linestyle=use_line_tot 233 cgoplot,st.sed.wav,spec/norm,color=use_col_tot,linestyle=use_line_tot
  234 +if keyword_set(fpol) then cgoplot,st.polsed.wav,specpol,color='Teal',linestyle=4
216 ;plot the normalized data as well. 235 ;plot the normalized data as well.
217 ;---------------------------------------- 236 ;----------------------------------------
218 237
@@ -221,7 +240,7 @@ frmt0='(A36)' @@ -221,7 +240,7 @@ frmt0='(A36)'
221 frmt1='(1E10.2)' 240 frmt1='(1E10.2)'
222 frmt2='(F7.2)' 241 frmt2='(F7.2)'
223 use_legend_xpos=0.50 242 use_legend_xpos=0.50
224 -use_legend_ypos=0.84 243 +if keyword_set(fpol) then use_legend_ypos=0.70 ELSE use_legend_ypos=0.84
225 use_legend_offset=0.03 ;This is the offset between lines of the legend in normalized units 244 use_legend_offset=0.03 ;This is the offset between lines of the legend in normalized units
226 legend_charsize=0.86 245 legend_charsize=0.86
227 246
@@ -236,7 +255,7 @@ IF keyword_set(legend_ypos) THEN use_legend_ypos=legend_ypos @@ -236,7 +255,7 @@ IF keyword_set(legend_ypos) THEN use_legend_ypos=legend_ypos
236 IF keyword_set(legend_offset) THEN use_legend_offset=legend_offset 255 IF keyword_set(legend_offset) THEN use_legend_offset=legend_offset
237 256
238 IF !d.name NE 'PS' THEN cleanplot 257 IF !d.name NE 'PS' THEN cleanplot
239 -;oo=0 258 +
240 tg=0 259 tg=0
241 prv_str='' 260 prv_str=''
242 IF keyword_set(res) THEN BEGIN 261 IF keyword_set(res) THEN BEGIN
@@ -327,25 +346,31 @@ IF keyword_set(res) THEN BEGIN @@ -327,25 +346,31 @@ IF keyword_set(res) THEN BEGIN
327 ENDIF 346 ENDIF
328 IF keyword_set(chi2) THEN BEGIN 347 IF keyword_set(chi2) THEN BEGIN
329 xxpos=1.29*use_legend_xpos 348 xxpos=1.29*use_legend_xpos
330 - yypos=1.13*use_legend_ypos 349 + yypos=1.13*0.84;use_legend_ypos
331 xyouts,xxpos,yypos,string('chi2=',format=frmt0)+string(chi2,format=frmt2),color=0,/normal,charsize=legend_charsize 350 xyouts,xxpos,yypos,string('chi2=',format=frmt0)+string(chi2,format=frmt2),color=0,/normal,charsize=legend_charsize
332 ENDIF 351 ENDIF
333 IF keyword_set(rchi2) THEN BEGIN 352 IF keyword_set(rchi2) THEN BEGIN
334 xxpos=1.29*use_legend_xpos 353 xxpos=1.29*use_legend_xpos
335 - yypos=1.13*use_legend_ypos-use_legend_offset 354 + yypos=1.13*0.84-use_legend_offset;use_legend_ypos-use_legend_offset
336 xyouts,xxpos,yypos,string('red. chi2=',format=frmt0)+string(rchi2,format=frmt2),color=0,/normal,charsize=legend_charsize 355 xyouts,xxpos,yypos,string('red. chi2=',format=frmt0)+string(rchi2,format=frmt2),color=0,/normal,charsize=legend_charsize
337 ENDIF 356 ENDIF
338 357
339 xtit=textoidl('\lambda (\mum)') 358 xtit=textoidl('\lambda (\mum)')
340 ;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 359 ;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
341 ;stop 360 ;stop
  361 +
342 IF keyword_set(_extra) THEN BEGIN 362 IF keyword_set(_extra) THEN BEGIN
343 extra_kept={XR:[0.,0.]} 363 extra_kept={XR:[0.,0.]}
344 extra_tags=tag_names(_extra) 364 extra_tags=tag_names(_extra)
345 ind=where(extra_tags EQ 'XR',count) 365 ind=where(extra_tags EQ 'XR',count)
346 IF count NE 0 THEN extra_kept.XR=_extra.(ind[0]) ;ELSE extra_kept=0 366 IF count NE 0 THEN extra_kept.XR=_extra.(ind[0]) ;ELSE extra_kept=0
347 ENDIF 367 ENDIF
348 -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 368 +
  369 +;stop
  370 +;,position=[0.12,0.14,0.96,0.35] old position before your polfrac display modification
  371 +if keyword_set(fpol) then begin
  372 +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
  373 +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
349 ;plot the normalized data as well. 374 ;plot the normalized data as well.
350 IF count_spec NE 0 THEN BEGIN 375 IF count_spec NE 0 THEN BEGIN
351 xx=((*!dustem_data.sed).wav)[ind_spec] 376 xx=((*!dustem_data.sed).wav)[ind_spec]
@@ -361,6 +386,7 @@ IF count_filt NE 0 THEN BEGIN @@ -361,6 +386,7 @@ IF count_filt NE 0 THEN BEGIN
361 trois_sigma=(3.*((*!dustem_data.sed).sigma)/2./sed)[ind_filt] 386 trois_sigma=(3.*((*!dustem_data.sed).sigma)/2./sed)[ind_filt]
362 cgerrplot,xx,yy-trois_sigma,yy+trois_sigma,color='Dodger Blue' 387 cgerrplot,xx,yy-trois_sigma,yy+trois_sigma,color='Dodger Blue'
363 ENDIF 388 ENDIF
  389 +
364 ;stop 390 ;stop
365 ;cgoplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,psym=16,symsize=1,thick=2,color='Dodger Blue' 391 ;cgoplot,(*!dustem_data.sed).wav,(*!dustem_data.sed).values/sed,psym=16,symsize=1,thick=2,color='Dodger Blue'
366 cgoplot,10^!x.crange,replicate(1.,2),color='black',linestyle=0 392 cgoplot,10^!x.crange,replicate(1.,2),color='black',linestyle=0
@@ -368,6 +394,24 @@ cgoplot,10^!x.crange,replicate(1.,2),color='black',linestyle=0 @@ -368,6 +394,24 @@ cgoplot,10^!x.crange,replicate(1.,2),color='black',linestyle=0
368 ;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' 394 ;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'
369 395
370 396
  397 +if keyword_set(fpol) then begin
  398 + plotsym,0,/fill
  399 + 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
  400 + xxpos=use_legend_xpos*0.35
  401 + yypos=use_legend_ypos*1.25
  402 + xyouts,xxpos,yypos,'Polarization fraction (%)',color=cgcolor('purple'),charsize=legend_charsize,/normal
  403 + yypos=use_legend_ypos*1.20
  404 + stringg='Polarization SED '+'('+textoidl('P_{\nu}')+')'
  405 + xyouts,xxpos,yypos,stringg,color=cgcolor('teal'),charsize=legend_charsize,/normal
  406 + pilotfx=fpol(0);((*!dustem_data.polfrac).values)(0);fpol(0);
  407 + cgoplot, (*!dustem_data.polfrac).wav,(*!dustem_data.polfrac).values*100,charsize=1.3,psym=8,syms=1,thick=2,color='Dodger Blue'
  408 + cgoplot, st.polsed.wav,(specpol/spec)*100/pilotfx*((*!dustem_data.polfrac).values)(0),color='purple'
  409 + cgoplot, (*!dustem_data.polfrac).wav,fpol*100/pilotfx*((*!dustem_data.polfrac).values)(0),color='Red',psym=6,syms=1
  410 + ;fpol=abs(fpol)
  411 + ;delp=(*!dustem_data.polfrac).values*100-fpol*100/pilotfx*((*!dustem_data.polfrac).values)(0)
  412 + ;cgoplot, ((*!dustem_data.polfrac).wav),((*!dustem_data.polfrac).values*100+delp),charsize=1.3,color='black',linestyle=2
  413 + ;stop
  414 +endif
371 415
372 IF keyword_set(ps) THEN BEGIN 416 IF keyword_set(ps) THEN BEGIN
373 device,/close 417 device,/close
src/idl/dustem_plot_polsed.pro
1 -PRO dustem_plot_polsed, st, p_dim, dustem_polsed, aligned=aligned, win=win 1 + PRO dustem_plot_polsed, st, p_dim, dustem_polsed, aligned=aligned, win=win
2 2
3 3
4 IF keyword_set(ps) THEN BEGIN 4 IF keyword_set(ps) THEN BEGIN
@@ -29,7 +29,7 @@ if not keyword_set(st) then begin @@ -29,7 +29,7 @@ if not keyword_set(st) then begin
29 ENDIF 29 ENDIF
30 30
31 31
32 -fact=1/(4.*!pi)/(3.e8/1.e-6/(st.polsed).wav)*1.00e17 32 +fact=1/(4.*!pi)*(*!dustem_HCD)*1.E-20/(3.e8/1.e-6/(st.polsed).wav)*1.00e17 ;applied correction here to take into account the HCD
33 fact1=1.E-20 ;This will convert data (real data) that is in MJy/sr to W 33 fact1=1.E-20 ;This will convert data (real data) that is in MJy/sr to W
34 34
35 P = st.polsed.em_tot*fact ;This is Polarized intensity P 35 P = st.polsed.em_tot*fact ;This is Polarized intensity P
src/idl/dustem_plugin_freefree.pro
@@ -42,14 +42,20 @@ IF keyword_set(help) THEN BEGIN @@ -42,14 +42,20 @@ IF keyword_set(help) THEN BEGIN
42 ENDIF 42 ENDIF
43 43
44 ;default values of input parameters 44 ;default values of input parameters
45 -Tgas=10000. ;default gas temperature 45 +Tgas=10000. ;default gas temperature
46 Amplitude=1. ;Amplitude 46 Amplitude=1. ;Amplitude
47 -paramtag=['T_gas (K)','Amp'] 47 +smallp=0.0 ;default polarization fraction
  48 +psi=0. ;default polarization angle
  49 +paramtag=['T_gas (K)','Amp','p','Psi (deg)']
48 IF keyword_set(key) THEN BEGIN 50 IF keyword_set(key) THEN BEGIN
49 a=where(key EQ 1,count1) 51 a=where(key EQ 1,count1)
50 b=where(key EQ 2,count2) 52 b=where(key EQ 2,count2)
  53 + c=where(key EQ 3,count3) ;default polarization fraction -newly added
  54 + d=where(key EQ 4,count4) ;default polarization angle -newly added
51 IF count1 NE 0 then Tgas=(val(a))(0) 55 IF count1 NE 0 then Tgas=(val(a))(0)
52 IF count2 NE 0 then Amplitude=(val(b))(0) 56 IF count2 NE 0 then Amplitude=(val(b))(0)
  57 + IF count3 NE 0 then smallp=val[c[0]] ;-newly added
  58 + IF count4 NE 0 then psi=val[d[0]] ;-newly added
53 ENDIF 59 ENDIF
54 60
55 ;IF !dustem_which EQ 'DESERT' THEN BEGIN 61 ;IF !dustem_which EQ 'DESERT' THEN BEGIN
@@ -59,12 +65,15 @@ ENDIF @@ -59,12 +65,15 @@ ENDIF
59 ;ENDELSE 65 ;ENDELSE
60 ;replaced by the following to ease the life of plugins writters 66 ;replaced by the following to ease the life of plugins writters
61 lambir=dustem_get_wavelengths() 67 lambir=dustem_get_wavelengths()
62 - 68 +Nwavs=n_elements(lambir)
63 cmic=3.e14 69 cmic=3.e14
64 nu=cmic/lambir ;Hz 70 nu=cmic/lambir ;Hz
65 mjy=1 ;output is in MJy/sr 71 mjy=1 ;output is in MJy/sr
66 lambir_ref=10000. 72 lambir_ref=10000.
67 73
  74 +
  75 +output=fltarr(Nwavs,3) ;newly added
  76 +
68 ;stop 77 ;stop
69 ;use_method='Deschenes2008' 78 ;use_method='Deschenes2008'
70 ;use_method='WallsGabaud1998' 79 ;use_method='WallsGabaud1998'
@@ -73,22 +82,22 @@ use_method='Dickinson2003_norm' @@ -73,22 +82,22 @@ use_method='Dickinson2003_norm'
73 CASE use_method OF 82 CASE use_method OF
74 'WallsGabaud1998':BEGIN 83 'WallsGabaud1998':BEGIN
75 em=1. ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway 84 em=1. ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway
76 - output=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy) 85 + output[*,0]=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy)
77 fact=Amplitude/I_halpha_R 86 fact=Amplitude/I_halpha_R
78 ;=== normalize to the requested Halpha value. 87 ;=== normalize to the requested Halpha value.
79 - output=output*fact 88 + output[*,0]=output[*,0]*fact
80 END 89 END
81 'WallsGabaud1998_scaled':BEGIN 90 'WallsGabaud1998_scaled':BEGIN
82 em=1. ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway 91 em=1. ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway
83 - output=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy)  
84 - norm=interpol(output,lambir,lambir_ref)  
85 - output=output/norm*Amplitude 92 + output[*,0]=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy)
  93 + norm=interpol(output[*,0],lambir,lambir_ref)
  94 + output[*,0]=output[*,0]/norm*Amplitude
86 END 95 END
87 'Deschenes2008':BEGIN 96 'Deschenes2008':BEGIN
88 beta_freefree=2.+1./(10.48+1.5*alog(Tgas/8.e3)-alog(nu/1.e9)) 97 beta_freefree=2.+1./(10.48+1.5*alog(Tgas/8.e3)-alog(nu/1.e9))
89 - output=nu^(-1.*beta_freefree)  
90 - norm=interpol(output,lambir,lambir_ref)  
91 - output=output/norm*Amplitude 98 + output[*,0]=nu^(-1.*beta_freefree)
  99 + norm=interpol(output[*,0],lambir,lambir_ref)
  100 + output[*,0]=output[*,0]/norm*Amplitude
92 END 101 END
93 'Dickinson2003_norm':BEGIN 102 'Dickinson2003_norm':BEGIN
94 ;stop 103 ;stop
@@ -99,12 +108,17 @@ CASE use_method OF @@ -99,12 +108,17 @@ CASE use_method OF
99 Tb=8.369e3*a*(nu_ghz)^(-2.)*T4^0.667*10^(0.029*T4)*(1.+0.08) ;in mK for 1 Rayleigh 108 Tb=8.369e3*a*(nu_ghz)^(-2.)*T4^0.667*10^(0.029*T4)*(1.+0.08) ;in mK for 1 Rayleigh
100 convert_mk_mjy, lambir, Tb, I_Mjy, /RJ 109 convert_mk_mjy, lambir, Tb, I_Mjy, /RJ
101 norm=interpol(I_Mjy,lambir,lambir_ref) 110 norm=interpol(I_Mjy,lambir,lambir_ref)
102 - output=I_Mjy/norm*Amplitude 111 + output[*,0]=I_Mjy/norm*Amplitude
103 END 112 END
104 ENDCASE 113 ENDCASE
105 114
106 -scope='ADD_SED' 115 +scope='ADD_SED+ADD_QSED+ADD_USED'
  116 +
  117 +;polarization this actually need to
  118 +polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
107 119
  120 +output[*,1]=Q
  121 +output[*,2]=U
108 122
109 123
110 the_end: 124 the_end:
src/idl/dustem_plugin_mdfy_spinning_pol.pro
1 -FUNCTION dustem_plugin_mdfy_spinning_pol, key=key, val=val, scope=scope, help=help 1 +FUNCTION dustem_plugin_mdfy_spinning_pol, key=key, val=val, scope=scope, paramtags=paramtags, help=help
2 2
3 ;+ 3 ;+
4 ; NAME: 4 ; NAME:
@@ -65,6 +65,10 @@ IF keyword_set(key) THEN BEGIN @@ -65,6 +65,10 @@ IF keyword_set(key) THEN BEGIN
65 65
66 ENDIF 66 ENDIF
67 67
  68 +
  69 +
  70 +paramtags=['p','Psi (deg)']
  71 +
68 lambir=dustem_get_wavelengths() 72 lambir=dustem_get_wavelengths()
69 Nwaves=n_elements(lambir) 73 Nwaves=n_elements(lambir)
70 74
src/idl/dustem_plugin_modify_dust_polarization.pro deleted
@@ -1,93 +0,0 @@ @@ -1,93 +0,0 @@
1 -Function dustem_plugin_modify_dust_polarization, key=key, val=val, scope=scope,help=help  
2 -  
3 -;+  
4 -; NAME:  
5 -; dustem_create_stokes  
6 -; PURPOSE:  
7 -; Produces stokes emission parameters for the dust and synchrotron components  
8 -; CATEGORY:  
9 -; DUSTEM Wrapper  
10 -; CALLING SEQUENCE:  
11 -; dustem_create_stokes(st,key=key,val=val)  
12 -; INPUTS:  
13 -; st (st = dustem_run(p_dim))  
14 -; OPTIONAL INPUT PARAMETERS:  
15 -; key = input parameter number  
16 -; val = input parameter value  
17 -; OUTPUTS:  
18 -; out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both  
19 -; OPTIONAL OUTPUT PARAMETERS:  
20 -; None  
21 -; ACCEPTED KEY-WORDS:  
22 -; help = if set, print this help  
23 -; COMMON BLOCKS:  
24 -; None  
25 -; SIDE EFFECTS:  
26 -; None  
27 -; RESTRICTIONS:  
28 -; The dustem fortran code must be installed  
29 -; The dustem idl wrapper must be installed  
30 -; PROCEDURE:  
31 -; This is a dustem plugin  
32 -;-  
33 -  
34 -IF keyword_set(help) THEN BEGIN  
35 - doc_library,'dustem_create_stokes'  
36 - out=0.  
37 - goto,the_end  
38 -ENDIF  
39 -  
40 -  
41 -  
42 -IF not KEYWORD_SET(st) THEN BEGIN  
43 -IF ptr_valid((*!dustem_fit).CURRENT_PARAM_VALUES) THEN BEGIN  
44 - p_di=(*(*!dustem_fit).CURRENT_PARAM_VALUES)  
45 -  
46 -ENDIF ELSE BEGIN  
47 - p_di=(*(*!dustem_fit).PARAM_INIT_VALUES)  
48 - ENDELSE  
49 -  
50 -st=dustem_run(p_di)  
51 -ENDIF  
52 -  
53 -  
54 -psi=0.  
55 -smallp=1.  
56 -IF keyword_set(key) THEN BEGIN  
57 - ind1=where(key EQ 1,count1)  
58 - ind2=where(key EQ 2,count2)  
59 - IF count1 NE 0 THEN smallp=val[ind1[0]] ; setting psi from pd  
60 - IF count2 NE 0 THEN psi=val[ind2[0]] ; setting psi from pd  
61 -ENDIF  
62 -  
63 -  
64 -fact = 1.e4*1.E20/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7  
65 -P=((st.polsed).em_tot)*fact  
66 -I=((st.sed).em_tot)*fact  
67 -  
68 -  
69 -  
70 -Nwaves=(size(I))[1]  
71 -  
72 -frac=P/I*smallp  
73 -tes=where(finite(frac) eq 0)  
74 -frac(tes)=0.  
75 -  
76 -  
77 -polar_ippsi2iqu,I,Q,U,frac,replicate(psi,Nwaves)  
78 -  
79 -out=fltarr(Nwaves,3)  
80 -  
81 -out[*,0]=I  
82 -out[*,1]=Q  
83 -out[*,2]=U  
84 -  
85 -scope='REPLACE_QSED+REPLACE_USED'  
86 -  
87 -return, out  
88 -  
89 -the_end:  
90 -  
91 -  
92 -end  
93 -  
src/idl/dustem_plugin_stellar_population.pro
@@ -3288,8 +3288,6 @@ ENDELSE @@ -3288,8 +3288,6 @@ ENDELSE
3288 if keyword_set(key) then begin 3288 if keyword_set(key) then begin
3289 print, 'comp_pop is:' 3289 print, 'comp_pop is:'
3290 print, comp_pop 3290 print, comp_pop
3291 -endif  
3292 -  
3293 ;integrating the mathis isrf 3291 ;integrating the mathis isrf
3294 ma_isrf_dat=!dustem_soft_dir+'data/ISRF_MATHIS.DAT' 3292 ma_isrf_dat=!dustem_soft_dir+'data/ISRF_MATHIS.DAT'
3295 ma_isrf=dustem_read_isrf(ma_isrf_dat) 3293 ma_isrf=dustem_read_isrf(ma_isrf_dat)
@@ -3303,6 +3301,9 @@ int_isrf=INT_TABULATED((ma_isrf.lambisrf)[un],(st.isrf)[un]) @@ -3303,6 +3301,9 @@ int_isrf=INT_TABULATED((ma_isrf.lambisrf)[un],(st.isrf)[un])
3303 print, 'G0_stellar_population=' 3301 print, 'G0_stellar_population='
3304 print, int_isrf/int_mathis 3302 print, int_isrf/int_mathis
3305 ;stop 3303 ;stop
  3304 +
  3305 +endif
  3306 +
3306 3307
3307 the_end: 3308 the_end:
3308 3309
src/idl/dustem_read_all_web3p8.pro
@@ -70,7 +70,7 @@ FOR i=0L,Ngrains-1 DO BEGIN @@ -70,7 +70,7 @@ FOR i=0L,Ngrains-1 DO BEGIN
70 st=dustem_read_qabs_lv(Qabs_file,silent=silent,read_densities=read_densities) 70 st=dustem_read_qabs_lv(Qabs_file,silent=silent,read_densities=read_densities)
71 st_qabs(i)=ptr_new(st) 71 st_qabs(i)=ptr_new(st)
72 ENDFOR 72 ENDFOR
73 - 73 +;stop
74 ;=== Read heat capacities 74 ;=== Read heat capacities
75 st_calor=ptrarr(Ngrains) 75 st_calor=ptrarr(Ngrains)
76 FOR i=0L,Ngrains-1 DO BEGIN 76 FOR i=0L,Ngrains-1 DO BEGIN
src/idl/dustem_sed_plot.pro
1 -PRO dustem_sed_plot,p_min,_extra=_extra,function_name=function_name,pol=pol,legend_xpos=legend_xpos,legend_ypos=legend_ypos,ps=ps,png=png 1 +PRO dustem_sed_plot,p_min,_extra=_extra,function_name=function_name,pol=pol,legend_xpos=legend_xpos,legend_ypos=legend_ypos,ps=ps,png=png,fpol=fpol
2 2
3 IF not keyword_set(function_name) THEN BEGIN 3 IF not keyword_set(function_name) THEN BEGIN
4 ;Run dustem with as an interface to mpfitfun; what does this mean? This whole procedure will have to be changed 4 ;Run dustem with as an interface to mpfitfun; what does this mean? This whole procedure will have to be changed
@@ -15,20 +15,20 @@ IF not keyword_set(function_name) THEN BEGIN @@ -15,20 +15,20 @@ IF not keyword_set(function_name) THEN BEGIN
15 st=out_st 15 st=out_st
16 ;dustem_plot_fit_sed,st,dustem_sed,cont,freefree,synchrotron,_extra=_extra,legend_xpos=legend_xpos,legend_ypos=legend_ypos 16 ;dustem_plot_fit_sed,st,dustem_sed,cont,freefree,synchrotron,_extra=_extra,legend_xpos=legend_xpos,legend_ypos=legend_ypos
17 win=1;win-act_wins+1 17 win=1;win-act_wins+1
18 - IF keyword_set(ps) THEN dustem_plot_fit_sed,st,dustem_sed,win=win,_extra=_extra,legend_xpos=legend_xpos,legend_ypos=legend_ypos,ps=ps,png=png,use_model=use_model ELSE dustem_plot_fit_sed,st,dustem_sed,_extra=_extra,win=win,legend_xpos=legend_xpos,legend_ypos=legend_ypos,use_model=use_model 18 + IF keyword_set(ps) THEN dustem_plot_fit_sed,st,dustem_sed,win=win,_extra=_extra,legend_xpos=legend_xpos,legend_ypos=legend_ypos,ps=ps,png=png,use_model=use_model,fpol=fpol ELSE dustem_plot_fit_sed,st,dustem_sed,_extra=_extra,win=win,legend_xpos=legend_xpos,legend_ypos=legend_ypos,use_model=use_model,fpol=fpol
19 19
20 ;I do not understand the reason begind the stop below - either way polarization is handled by other procedures 20 ;I do not understand the reason begind the stop below - either way polarization is handled by other procedures
21 IF keyword_set(pol) THEN BEGIN 21 IF keyword_set(pol) THEN BEGIN
22 ;stop 22 ;stop
23 IF tag_exist(!dustem_data,'polsed') THEN BEGIN 23 IF tag_exist(!dustem_data,'polsed') THEN BEGIN
24 - IF isa(*!dustem_data.polsed) THEN BEGIN 24 + IF isa(!dustem_data.polsed) THEN BEGIN
25 win+=1 25 win+=1
26 dustem_polsed=dustem_compute_polsed(p_min,st=st) 26 dustem_polsed=dustem_compute_polsed(p_min,st=st)
27 dustem_plot_polsed, st, p_dim, dustem_polsed, aligned=aligned, win=win,_Extra=extra 27 dustem_plot_polsed, st, p_dim, dustem_polsed, aligned=aligned, win=win,_Extra=extra
28 ENDIF 28 ENDIF
29 ENDIF 29 ENDIF
30 IF tag_exist(!dustem_data,'polext') THEN BEGIN 30 IF tag_exist(!dustem_data,'polext') THEN BEGIN
31 - IF isa(*!dustem_data.polext) THEN BEGIN 31 + IF isa(!dustem_data.polext) THEN BEGIN
32 win+=1 32 win+=1
33 dustem_polext=dustem_compute_polext(p_min,st=st) 33 dustem_polext=dustem_compute_polext(p_min,st=st)
34 dustem_plot_polext, st, p_dim, dustem_polext, aligned=aligned, win=win,_Extra=extra 34 dustem_plot_polext, st, p_dim, dustem_polext, aligned=aligned, win=win,_Extra=extra
src/idl/dustem_set_data.pro
1 -FUNCTION dustem_set_data,help=help,sed=sed,ext=ext,polfrac=polfrac,rchi2_weight=rchi2_weight,f_HI=f_HI 1 +FUNCTION dustem_set_data,help=help,sed=sed,ext=ext,fpol=fpol,rchi2_weight=rchi2_weight,f_HI=f_HI
2 2
3 ;+ 3 ;+
4 ; NAME: 4 ; NAME:
@@ -46,7 +46,6 @@ FUNCTION dustem_set_data,help=help,sed=sed,ext=ext,polfrac=polfrac,rchi2_weight= @@ -46,7 +46,6 @@ FUNCTION dustem_set_data,help=help,sed=sed,ext=ext,polfrac=polfrac,rchi2_weight=
46 ; The function uses two main input structures: SED and EXT. Polarization data is included within each. 46 ; The function uses two main input structures: SED and EXT. Polarization data is included within each.
47 ;- 47 ;-
48 48
49 -;fully deprecate the use of polfrac?===>YES should do so  
50 49
51 IF keyword_set(help) THEN BEGIN 50 IF keyword_set(help) THEN BEGIN
52 doc_library,'dustem_set_data' 51 doc_library,'dustem_set_data'
@@ -61,8 +60,10 @@ ENDIF @@ -61,8 +60,10 @@ ENDIF
61 ;SETTING THE DATA STRUCTURES FOR THE FITTING PROCESS - SED 60 ;SETTING THE DATA STRUCTURES FOR THE FITTING PROCESS - SED
62 61
63 IF keyword_set(sed) THEN BEGIN 62 IF keyword_set(sed) THEN BEGIN
64 -  
65 - xx=dustem_check_data(sed=sed,ist=ist,pst=pst,qst=qst,ust=ust) 63 +
  64 +
  65 + ;maybe to activate fpol here you need to set it to one? CHECK THIS OUT.
  66 + if keyword_set(fpol) then xx=dustem_check_data(sed=sed,ist=ist,pst=pst,fpol=fpol,fpst=fpst,qst=qst,ust=ust) else xx=dustem_check_data(sed=sed,ist=ist,pst=pst,fpst=fpst,qst=qst,ust=ust)
66 ;stop 67 ;stop
67 ;=== fill !dustem_data 68 ;=== fill !dustem_data
68 IF isa(ist) THEN !dustem_data.sed = ptr_new(ist) ;ELSE !dustem_data.sed = ptr_new() 69 IF isa(ist) THEN !dustem_data.sed = ptr_new(ist) ;ELSE !dustem_data.sed = ptr_new()
@@ -79,6 +80,13 @@ IF keyword_set(sed) THEN BEGIN @@ -79,6 +80,13 @@ IF keyword_set(sed) THEN BEGIN
79 if keyword_set(f_HI) then if f_HI gt 0 then $ 80 if keyword_set(f_HI) then if f_HI gt 0 then $
80 (*!dustem_data.polsed).values *= f_HI 81 (*!dustem_data.polsed).values *= f_HI
81 ENDIF 82 ENDIF
  83 + If isa(fpst) then BEGIN
  84 + ;=== fill !dustem_data
  85 + !dustem_data.polfrac = ptr_new(fpst)
  86 + ; If f_HI is specified, multiply the data by f_HI
  87 + if keyword_set(f_HI) then if f_HI gt 0 then $
  88 + (*!dustem_data.polfrac).values *= f_HI
  89 + ENDIF
82 IF isa(qst) THEN BEGIN 90 IF isa(qst) THEN BEGIN
83 ;=== fill !dustem_data 91 ;=== fill !dustem_data
84 !dustem_data.qsed = ptr_new(qst) 92 !dustem_data.qsed = ptr_new(qst)
@@ -139,6 +147,7 @@ ENDIF @@ -139,6 +147,7 @@ ENDIF
139 If !run_pol THEN BEGIN 147 If !run_pol THEN BEGIN
140 ;SED 148 ;SED
141 IF isa(pst) THEN !fit_rchi2_weight.polsed=1. 149 IF isa(pst) THEN !fit_rchi2_weight.polsed=1.
  150 + IF isa(fpst) THEN !fit_rchi2_weight.polfrac=1.
142 IF isa(qst) THEN !fit_rchi2_weight.qsed=1. 151 IF isa(qst) THEN !fit_rchi2_weight.qsed=1.
143 IF isa(ust) THEN !fit_rchi2_weight.used=1. 152 IF isa(ust) THEN !fit_rchi2_weight.used=1.
144 153
@@ -155,6 +164,7 @@ IF keyword_set(rchi2_weight) THEN BEGIN @@ -155,6 +164,7 @@ IF keyword_set(rchi2_weight) THEN BEGIN
155 164
156 IF !run_pol THEN BEGIN 165 IF !run_pol THEN BEGIN
157 IF isa(pst) THEN !fit_rchi2_weight.polsed = rchi2_weight.polsed 166 IF isa(pst) THEN !fit_rchi2_weight.polsed = rchi2_weight.polsed
  167 + IF isa(fpst) THEN !fit_rchi2_weight.polfrac = rchi2_weight.polfrac
158 IF isa(qst) THEN !fit_rchi2_weight.qsed = rchi2_weight.qsed 168 IF isa(qst) THEN !fit_rchi2_weight.qsed = rchi2_weight.qsed
159 IF isa(ust) THEN !fit_rchi2_weight.used = rchi2_weight.used 169 IF isa(ust) THEN !fit_rchi2_weight.used = rchi2_weight.used
160 170
src/idl_misc/JPBLib_for_Dustemwrap/General/convert_mk_mjy.pro
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 ;+ 18 ;+
19 -; Convert mK, either themodynamic or Rayleigh-Jeans in MJy/sr 19 +; Convert mK, either thermodynamic or Rayleigh-Jeans in MJy/sr
20 ; 20 ;
21 ; 21 ;
22 ; @param lam {in}{required}{type=float} wavelength in micron 22 ; @param lam {in}{required}{type=float} wavelength in micron