Commit 5a2643a469a48097394f73f48c731120f737645c

Authored by Ilyes Choubani
1 parent 8bab7d4b
Exists in master

cleaning/improving/filling gaps

src/idl/dustem_activate_plugins.pro
... ... @@ -69,7 +69,6 @@ FOR i=0L,n_elements(param_descs)-1 DO BEGIN
69 69  
70 70 IF parameter_type EQ 'PLUGIN' THEN BEGIN ; Selecting the plugins
71 71  
72   - stop
73 72 ftn = strmid(param_descs(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
74 73 ii = strsplit(ftn,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
75 74 ftn = strmid(ftn,0,ii) ; String containing the name of the plugin without the associated keyword
... ...
src/idl/dustem_check_data.pro
... ... @@ -331,7 +331,7 @@ IF KEYWORD_SET(data_ext) THEN begin
331 331 values = 0.5*atan(uext.values(uexpts),qext.values(qexpts))/degtorad
332 332 polar_variance_iqu2ippsi,ext.values(sedpts),qexsed.values(qexpts),uext.values(uexpts),(data_ext(testx).sigextII)(extpts),(data_ext(testqex).sigextQQ)(qexpts),(data_ext(testuex).sigextUU)(uexpts),(data_ext(testx).sigextIQ)(extpts),(data_ext(testx).sigextIU)(extpts),(data_ext(testx).sigextQU)(extpts),variance_smallp,variance_psi,variance_largep
333 333 sigma = sqrt(variance_psi)
334   - psi_em={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma}
  334 + psi_ext={instru_names:instru_names,filt_names:filt_names,wav:wav,values:values,sigma:sigma}
335 335  
336 336 goto, pexzone ; the variances for polextPSI_EXT were already computed.
337 337  
... ...
src/idl/dustem_fit_sed_readme.pro
... ... @@ -334,11 +334,8 @@ dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo
334 334 ;== INITIALIZE ANY PLUGINS
335 335 dustem_init_plugins, pd,fpd
336 336  
337   -stop
338 337 dustem_init_fixed_params,fpd,fiv
339 338  
340   -
341   -stop
342 339 ;== RUN THE FIT
343 340 tol=1.e-16
344 341 use_Nitermax=5 ;maximum number of iterations.
... ... @@ -379,7 +376,7 @@ if keyword_set(restore) then begin
379 376 file=restore
380 377 dustem_restore_system_variables,file
381 378 end
382   -
  379 +
383 380 ;== PLOT THE FIT RESULTS RESTORED FROM .SAV FILE
384 381 ; tit='Spectral Energy Distribution (Saved)'
385 382 ; ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2')
... ...
src/idl/dustem_init.pro
... ... @@ -122,7 +122,7 @@ defsysv,'!indef', exists=exists_indef
122 122 IF NOT exists_indef THEN defsysv,'!indef',-32768.
123 123  
124 124 ;define !dustem_fit
125   -dustem_fit_st={data:ptr_new(),wavelength:ptr_new(), $
  125 +dustem_fit_st={data:ptr_new(), $ ;,wavelength:ptr_new(), ;because wavelength arrays in the different datasets (data) can be different
126 126 param_descs:ptr_new(),param_init_values:ptr_new(),param_func:ptr_new(), $
127 127 fixed_param_descs:ptr_new(),fixed_param_init_values:ptr_new(), $
128 128 chi2:0.D0,rchi2:0.D0, $
... ...
src/idl/dustem_mpfit_data.pro
... ... @@ -63,7 +63,7 @@ if !run_pol then begin
63 63  
64 64 ind_data_tag=dustem_data_tag(count=count_data_tag)
65 65 tagnames=tag_names(!dustem_data)
66   - testpol = tagnames EQ 'POLSED' or tagnames EQ 'POLEXT' or tagnames EQ 'POLFRAC' or tagnames EQ 'POLSED' or tagnames EQ 'PSI_EM' or tagnames EQ 'PSI_EXT'
  66 + testpol = tagnames EQ 'POLSED' or tagnames EQ 'POLEXT' or tagnames EQ 'POLFRAC' or tagnames EQ 'PSI_EM' or tagnames EQ 'PSI_EXT'
67 67 data_ind=where(~testpol,ctestpol)
68 68 if ctestpol ne 0 then begin
69 69 match,ind_data_tag,data_ind,ind1,ind2 ;not using match2 because when matching indices, if the first is 0 it doesn't count which is wrong.
... ...
src/idl/dustem_mpfit_run.pro
... ... @@ -54,12 +54,6 @@ IF !run_ionfrac gt 0. THEN toto = dustem_create_ionfrac()
54 54  
55 55 dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values),st ;st is an output...
56 56  
57   -;stop
58   -
59   -;st1 = dustem_run(p_dim)
60   -
61   -;stop
62   -
63 57 st_model=dustem_read_all(!dustem_soft_dir)
64 58  
65 59  
... ... @@ -125,7 +119,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
125 119 ;I think this test isn't the correct one because when we want to show the SED data and not fit it we have an issue
126 120 ;with the current hiding/showing formalism!!!!
127 121  
128   - if isa(!dustem_data.sed) then dustem_out = [ dustem_out, dustem_sed ]
  122 + dustem_out = [ dustem_out, dustem_sed ]
129 123  
130 124 END
131 125  
... ... @@ -149,23 +143,23 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
149 143 ;print,"chi2 per wl: ",((*!dustem_data.ext).values-dustem_ext)^2/(*!dustem_data.ext).sigma^2
150 144  
151 145 ; Plot if needed
152   - IF !dustem_show_plot NE 0 THEN BEGIN
153   -
154   - win+=1
155   - ;dustem_plot_ext,st,yr=[1.e-6,1.e0],/ysty,xr=[0.5,40],/xsty,win=win
156   - xr=[0.3,40]
157   - yr=[1.e-26,1.e-21]
158   - dustem_plot_ext,st,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1
159   - dustem_plot_ext,st,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,multi=2
160   -
161   - win+=1
162   - ;dustem_plot_ext,st,/UV,yr=[0,2.5],/ysty,xr=[0,10],/xsty,win=win
163   - xr=[0.2,10]
164   - yr=[0,3e-21]
165   - dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1
166   - dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,multi=2
167   -
168   - ENDIF
  146 +; IF !dustem_show_plot NE 0 THEN BEGIN
  147 +;
  148 +; win+=1
  149 +; ;dustem_plot_ext,st,yr=[1.e-6,1.e0],/ysty,xr=[0.5,40],/xsty,win=win
  150 +; xr=[0.3,40]
  151 +; yr=[1.e-26,1.e-21]
  152 +; dustem_plot_ext,st,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1
  153 +; dustem_plot_ext,st,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,multi=2
  154 +;
  155 +; win+=1
  156 +; ;dustem_plot_ext,st,/UV,yr=[0,2.5],/ysty,xr=[0,10],/xsty,win=win
  157 +; xr=[0.2,10]
  158 +; yr=[0,3e-21]
  159 +; dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1
  160 +; dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,multi=2
  161 +;
  162 +; ENDIF
169 163  
170 164 ;dustem_plot_ext,st,/print_Rv ;commented this recently
171 165  
... ... @@ -277,7 +271,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
277 271 n_qsed = n_elements((*!dustem_data.qsed).values)
278 272 rchi2_qsed = chi2_qsed / n_qsed
279 273 wrchi2_qsed = rchi2_qsed * !fit_rchi2_weight.qsed
280   - if isa(!dustem_data.qsed) then dustem_out = [ dustem_out, dustem_qsed ] ; classic command
  274 + dustem_out = [ dustem_out, dustem_qsed ] ; classic command
281 275 message,"chi2 QSED = "+strtrim(chi2_qsed,2)+" rchi2 QSED = "+strtrim(rchi2_qsed,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed
282 276 print,"chi2 per wl: ",((*!dustem_data.qsed).values-dustem_qsed)^2/(*!dustem_data.qsed).sigma^2
283 277  
... ... @@ -290,7 +284,7 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
290 284 n_used = n_elements((*!dustem_data.used).values)
291 285 rchi2_used = chi2_used / n_used
292 286 wrchi2_used = rchi2_used * !fit_rchi2_weight.used
293   - if isa(!dustem_data.used) then dustem_out = [ dustem_out, dustem_used] ; classic command
  287 + dustem_out = [ dustem_out, dustem_used] ; classic command
294 288 message,"chi2 USED = "+strtrim(chi2_used,2)+" rchi2 USED = "+strtrim(rchi2_used,2),/continue;," weighted rchi2 POLSED=",wrchi2_polsed
295 289 print,"chi2 per wl: ",((*!dustem_data.used).values-dustem_used)^2/(*!dustem_data.used).sigma^2
296 290  
... ... @@ -312,9 +306,6 @@ FOR i_tag=0,count_data_tag-1 DO BEGIN
312 306 IF !run_pol and !run_lin THEN BEGIN
313 307 degtorad = !pi/180
314 308 if ~isa(dustem_used) or ~isa(dustem_qsed) then toto = dustem_compute_stokes(p_dim,st,dustem_qsed,dustem_used,Q_spec,U_spec,PSI_spec,dustem_psi_em)
315   - ;dustem_psi_em = 0.5*atan(dustem_used,dustem_qsed)/degtorad
316   -
317   -
318 309 ENDIF
319 310 END
320 311  
... ...
src/idl/dustem_restore_system_variables.pro
... ... @@ -50,16 +50,12 @@ restore,file,verbose=verbose
50 50  
51 51 defsysv,'!dustem_dat',saved_dustem_dat
52 52 defsysv,'!dustem_data',saved_dustem_data
  53 +defsysv,'!dustem_show',saved_dustem_show
53 54 defsysv,'!DUSTEM_DO_CC',saved_DUSTEM_DO_CC
54 55 defsysv,'!DUSTEM_F90_EXEC',saved_DUSTEM_F90_EXEC
55 56 defsysv,'!dustem_filters',saved_dustem_filters
56 57 defsysv,'!dustem_fit',saved_dustem_fit
57 58 defsysv,'!DUSTEM_F_HI',saved_DUSTEM_F_HI
58   -;defsysv,'!DUSTEM_IDL_CONTINUUM',saved_DUSTEM_IDL_CONTINUUM
59   -;defsysv,'!DUSTEM_IDL_FREEFREE',saved_DUSTEM_IDL_FREEFREE
60   -;defsysv,'!DUSTEM_IDL_SYNCHROTRON',saved_DUSTEM_IDL_SYNCHROTRON
61   -
62   -;defsysv, '!DUSTEM_COMPOSITE_STELLAR_POPULATION',saved_DUSTEM_COMPOSITE_STELLAR_POPULATION
63 59 defsysv,'!DUSTEM_INPUTS',saved_DUSTEM_INPUTS
64 60 defsysv,'!DUSTEM_INSTRUMENT_DESCRIPTION',saved_DUSTEM_INSTRUMENT_DESCRIPTION
65 61 defsysv,'!DUSTEM_NEVER_DO_CC',saved_DUSTEM_NEVER_DO_CC
... ... @@ -82,8 +78,6 @@ defsysv,'!RUN_RRF',saved_RUN_RRF
82 78 defsysv,'!RUN_TLS',saved_RUN_TLS
83 79 defsysv,'!RUN_UNIV',saved_RUN_UNIV
84 80 defsysv,'!DUSTEM_REDSHIFT',saved_DUSTEM_REDSHIFT
85   -;defsysv,'!DUSTEM_ISRF_STAR_ADD',saved_DUSTEM_ISRF_STAR_ADD
86   -defsysv, '!DUSTEM_SCOPE',saved_DUSTEM_SCOPE
87 81 defsysv, '!DUSTEM_PLUGIN',saved_DUSTEM_PLUGIN
88 82  
89 83 the_end:
... ...
src/idl/dustem_save_system_variables.pro
... ... @@ -80,14 +80,12 @@ ENDIF
80 80  
81 81 saved_dustem_dat=!dustem_dat
82 82 saved_dustem_data=!dustem_data
  83 +saved_dustem_show=!dustem_show
83 84 saved_dustem_do_cc=!DUSTEM_DO_CC
84 85 saved_dustem_f90_exec=!DUSTEM_F90_EXEC
85 86 saved_dustem_filters=!dustem_filters
86 87 saved_dustem_fit=!dustem_fit
87 88 saved_dustem_f_hi=!DUSTEM_F_HI
88   -;saved_dustem_IDL_CONTINUUM=!DUSTEM_IDL_CONTINUUM ;Probably not needed - further testing required
89   -;saved_DUSTEM_IDL_FREEFREE=!DUSTEM_IDL_FREEFREE ;Probably not needed - further testing required
90   -;saved_DUSTEM_IDL_SYNCHROTRON=!DUSTEM_IDL_SYNCHROTRON ;Probably not needed - further testing required
91 89 saved_DUSTEM_INPUTS=!DUSTEM_INPUTS
92 90 saved_DUSTEM_INSTRUMENT_DESCRIPTION=!DUSTEM_INSTRUMENT_DESCRIPTION
93 91 saved_DUSTEM_NEVER_DO_CC=!DUSTEM_NEVER_DO_CC
... ... @@ -110,21 +108,17 @@ saved_RUN_RRF=!RUN_RRF
110 108 saved_RUN_TLS=!RUN_TLS
111 109 saved_RUN_UNIV=!RUN_UNIV
112 110 saved_DUSTEM_REDSHIFT=!DUSTEM_REDSHIFT
113   -;saved_DUSTEM_COMPOSITE_STELLAR_POPULATION=!DUSTEM_COMPOSITE_STELLAR_POPULATION
114   -saved_DUSTEM_SCOPE=!DUSTEM_SCOPE
115 111 saved_DUSTEM_PLUGIN=!DUSTEM_PLUGIN
116 112  
117 113 save,saved_dustem_dat,$
118 114 saved_dustem_data, $
  115 + saved_dustem_show, $
119 116 saved_dustem_fit, $
120 117 saved_dustem_do_cc, $
121 118 saved_dustem_f90_exec, $
122 119 saved_dustem_filters, $
123 120 saved_dustem_fit, $
124 121 saved_dustem_f_hi, $
125   - ;saved_dustem_IDL_CONTINUUM, $ ;Probably not needed - further testing required
126   - ;saved_DUSTEM_IDL_FREEFREE, $ ;Probably not needed - further testing required
127   - ;saved_DUSTEM_IDL_SYNCHROTRON, $ ;Probably not needed - further testing required
128 122 saved_DUSTEM_INPUTS, $
129 123 saved_DUSTEM_INSTRUMENT_DESCRIPTION, $
130 124 saved_DUSTEM_NEVER_DO_CC, $
... ... @@ -147,9 +141,8 @@ save,saved_dustem_dat,$
147 141 saved_RUN_TLS, $
148 142 saved_RUN_UNIV, $
149 143 saved_DUSTEM_REDSHIFT, $
150   - saved_DUSTEM_SCOPE, $
151   - saved_DUSTEM_PLUGIN, $
152   - ;saved_DUSTEM_COMPOSITE_STELLAR_POPULATION, $
  144 + saved_DUSTEM_PLUGIN, $
  145 +
153 146 file=file
154 147  
155 148 the_end:
... ...
src/idl/dustem_set_data.pro
1   -FUNCTION dustem_set_data,m_fit=m_fit,m_show=m_show,x_fit=x_fit,x_show=x_show,sed=sed,ext=ext,polsed=polsed,polext=polext,used=used,qsed=qsed,polfrac=polfrac,psi_em=psi_em,psi_ext=psi_ext,Qext=Qext,Uext=Uext,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help
  1 +FUNCTION dustem_set_data,m_fit=m_fit,m_show=m_show,x_fit=x_fit,x_show=x_show,rchi2_weight=rchi2_weight,f_HI=f_HI,help=help
2 2  
3 3 ;+
4 4 ; NAME:
... ... @@ -53,25 +53,21 @@ IF keyword_set(help) THEN BEGIN
53 53 goto,the_end
54 54 ENDIF
55 55  
56   -;Cleaninig data/showing structure
  56 +;Cleaninig fitting/showing structure(s)
57 57 for i=0L,n_tags(!dustem_data)-1 do begin
58 58 !dustem_data.(i) = ptr_new()
59 59 !dustem_show.(i) = ptr_new()
60 60 endfor
61 61  
62   -
63   -;I have decided to do the generation of data in check_data.
64   -
  62 +;#FITTING STRUCTURE
65 63  
66 64 xx=dustem_check_data(data_sed=m_fit,data_ext=x_fit,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,psi_em=psi_em,qsed=qsed,used=used,qext=qext,uext=uext,psi_ext=psi_ext)
67 65 ;outputs whatever the input structure has, into organized seperate structures formatted for the fitting process.
68 66  
69 67 ;FITTING STRUCTURE INITIALIZATION
70   -
71 68 IF isa(sed) THEN !dustem_data.sed = ptr_new(sed)
72 69 IF isa(ext) THEN !dustem_data.ext = ptr_new(ext)
73 70  
74   -
75 71 ;####################
76 72 ;OLD VARIABLE. KEPT IT.
77 73 ; If f_HI is specified, multiply the data by f_HI
... ... @@ -84,8 +80,6 @@ endif else f_HI = 1.
84 80 defsysv,'!dustem_f_HI',f_HI
85 81 ;####################
86 82  
87   -;NOTA BENE: The user is bound to fit Q and U together.
88   -
89 83 if !run_pol then begin
90 84  
91 85 if keyword_set(m_fit) then begin
... ... @@ -139,8 +133,8 @@ if !run_pol then begin
139 133 endif
140 134  
141 135 if keyword_set(x_fit) then begin
  136 +
142 137 ;Two tests that determine what the user will eventually fit
143   -
144 138 testexstks = isa(qext) and isa(uext)
145 139  
146 140 IF ~testexstks then message, 'Extinction stokes parameters/Polarization data is not set correctly. Please check the input structure. Aborting...'
... ... @@ -168,15 +162,15 @@ if !run_pol then begin
168 162 endif
169 163 endif
170 164  
  165 +;#SHOWING STRUCTURE
171 166  
172 167 if not keyword_set(m_show) then m_show=m_fit
173 168  
174 169 ;Setting of the structure that will be displayed
175 170 yy=dustem_check_data(data_sed=m_show,data_ext=x_show,sed=sed,ext=ext,polext=polext,polsed=polsed,polfrac=polfrac,qsed=qsed,used=used,qext=qext,uext=uext,psi_em=psi_em,psi_ext=psi_ext)
176   -;stop
  171 +
177 172 IF isa(sed) THEN !dustem_show.sed = ptr_new(sed)
178 173 IF isa(ext) THEN !dustem_show.ext = ptr_new(ext)
179   -
180 174  
181 175 ;####################
182 176 ;OLD VARIABLE. KEPT IT.
... ... @@ -303,6 +297,10 @@ ENDIF ELSE BEGIN
303 297  
304 298 ENDELSE
305 299  
  300 +;Setting the data and wavelength tags in '!dustem_fit'
  301 +((*!dustem_fit).data)=ptr_new(!dustem_data)
  302 +
  303 +
306 304 the_end:
307 305  
308 306  
... ...