From 5135b1945f75d60ee8a5b94854739b2343938e38 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bernard Date: Tue, 13 Jul 2021 17:52:29 +0200 Subject: [PATCH] cleaned --- src/idl/dustem_fit_sed_readme.pro | 90 ++++++++++++++++++++++++++++++++---------------------------------------------------------- 1 file changed, 32 insertions(+), 58 deletions(-) diff --git a/src/idl/dustem_fit_sed_readme.pro b/src/idl/dustem_fit_sed_readme.pro index 2ad3a32..d977097 100644 --- a/src/idl/dustem_fit_sed_readme.pro +++ b/src/idl/dustem_fit_sed_readme.pro @@ -1,4 +1,4 @@ -PRO dustem_fit_sed_readme,postcript=postcript,mode=mode,help=help,png=png +PRO dustem_fit_sed_readme,postcript=postcript,model=model,help=help,png=png,itermax=itermax ;This Readme describes how to fit SEDs with dustem ;It runs on the SED stored into the file sample_SED.xcat @@ -25,7 +25,7 @@ PRO dustem_fit_sed_readme,postcript=postcript,mode=mode,help=help,png=png ; CATEGORY: ; Dustem ; CALLING SEQUENCE: -; dustem_fit_sed_readme,postcript=postcript,mode=mode,help=help +; dustem_fit_sed_readme,postcript=postcript,model=model,help=help ; INPUTS: ; None ; OPTIONAL INPUT PARAMETERS: @@ -35,7 +35,7 @@ PRO dustem_fit_sed_readme,postcript=postcript,mode=mode,help=help,png=png ; OPTIONAL OUTPUT PARAMETERS: ; None ; ACCEPTED KEY-WORDS: -; mode = Selects one of the dust mixture used by dustem +; model = Selects one of the dust mixture used by dustem ; 'COMPIEGNE_ETAL2010' from Compiegne et al 2010 (default) ; 'DBP90' from Desert et al 1990 ; 'DL01' from Draine & Li 2001 @@ -52,7 +52,7 @@ PRO dustem_fit_sed_readme,postcript=postcript,mode=mode,help=help,png=png ; PROCEDURE: ; None ; EXAMPLES -; dustem_fit_sed_readme,mode='COMPIEGNE_ETAL2010' +; dustem_fit_sed_readme,model='COMPIEGNE_ETAL2010' ; MODIFICATION HISTORY: ; Written by J.P. Bernard April 1st 2011 ; see evolution details on the dustem cvs maintained at CESR @@ -64,10 +64,10 @@ IF keyword_set(help) THEN BEGIN goto,the_end ENDIF -IF keyword_set(mode) THEN BEGIN - use_mode=strupcase(mode) +IF keyword_set(model) THEN BEGIN + use_model=strupcase(model) ENDIF ELSE BEGIN - use_mode='COMPIEGNE_ETAL2010' ;Default is last dustem model + use_model='COMPIEGNE_ETAL2010' ;Default is last dustem model ENDELSE IF keyword_set(png) THEN BEGIN @@ -79,7 +79,7 @@ ENDIF ;=== initialise dustem ;dustem_init,/wrap ;dustem_init -dustem_init,mode=use_mode +dustem_init,model=use_model !dustem_verbose=1 !dustem_show_plot=1 @@ -99,21 +99,13 @@ ind=where(spec.error EQ 0.,count) IF count NE 0 THEN spec(ind).error=0.2*spec(ind).spec ind=where(spec.instru EQ 'FIRAS',count) IF count NE 0 THEN spec(ind).error=0.2*spec(ind).spec -;=== Draine Model SED for U=1. by C. Bot -;;dir=getenv('DUSTEM_SOFT_DIR')+'/src/dustem3.8_web/SEDs/' -;dir=!dustem_wrap_soft_dir+'/Data/SEDs/' -;file=dir+'SED_DraineModel_U1.0.xcat' -;spec=read_xcat(file,/silent) -;=== Fake SED made from Dustem outputs -;spec=dustem_compute_sed(p_dim,st=st,cont=cont,_extra=extra) ;=== Set which parameters you want to fit -;CASE getenv('DUSTEM_WHICH') OF CASE !dustem_which OF 'WEB3p8':BEGIN ;=== This is to use Desert model ;=== must have done dustem_init,/DBP90 - CASE use_mode OF + CASE use_model OF 'DBP90':BEGIN pd = [ $ '(*!dustem_params).G0', $ ;G0 @@ -193,6 +185,25 @@ CASE !dustem_which OF ; fiv=[1.0] ; dustem_init_fixed_params,fpd,fiv END + 'AJ13':BEGIN + pd = [ $ + '(*!dustem_params).G0', $ ;G0 + '(*!dustem_params).grains(1).mdust_o_mh',$ ;PAH1 mass fraction + '(*!dustem_params).grains(0).mdust_o_mh',$ ;PAH0 mass fraction + '(*!dustem_params).grains(2).mdust_o_mh', $ ;amCBEx + '(*!dustem_params).grains(3).mdust_o_mh', $ ;amCBEx + '(*!dustem_params).grains(4).mdust_o_mh', $ ;aSil + 'dustem_create_continuum_2'] ;Intensity of NIR continuum + iv = [1.0, 7.8e-4, 7.8e-4,1.65e-4,1.45e-3,7.8e-3,0.001] + Npar=n_elements(pd) + ulimed=replicate(0,Npar) + llimed=replicate(1,Npar) + llims=replicate(0.,Npar) + ;=== Fixed parameters +; fpd=['(*!dustem_params).G0'] ;Fixed parameter description +; fiv=[1.0] +; dustem_init_fixed_params,fpd,fiv + END ENDCASE END ELSE: BEGIN @@ -217,54 +228,29 @@ ENDCASE st=dustem_set_data(sed=spec) -;VG : dustem_set_data turned into a function to be used indifferently for sed, ext, polext -;dustem_set_data,spec -;defsysv, '!dustem_data', {sed:ptr_new()} ;Data to fit - ;== SET THE FITTED PARAMETERS dustem_init_parinfo,pd,iv,up_limited=ulimed,lo_limited=llimed,up_limits=ulims,lo_limits=llims ;==== below is to reset the defaults keywords for PAH which in newer version of the fortran include spin and mix, ... ;(*!dustem_params).grains[0].TYPE_KEYWORDS='logn' ;(*!dustem_params).grains[1].TYPE_KEYWORDS='logn' -(*!dustem_params).grains[0].TYPE_KEYWORDS='logn' -(*!dustem_params).grains[1].TYPE_KEYWORDS='logn' ;stop -;dustem_sort_params ;hprint,*(*!dustem_fit).param_descs ;hprint,*(*!dustem_fit).param_init_values ;hprint,*(*!dustem_fit).param_func + ;=== RUN fit tol=1.e-14 -;tol=1.e-2 -;Nitermax=20 ;maximum number of iteration. This is the criterium which will stop the fit procedure -Nitermax=2 ;maximum number of iteration. This is the criterium which will stop the fit procedure +use_Nitermax=2 ;maximum number of iteration. This is the criterium which will stop the fit procedure +IF keyword_set(itermax) THEN use_Nitermax=itermax loadct,13 !y.range=[1e-4,10] ;This is to ajust plot range from outside the routine t1=systime(0,/sec) -res=dustem_mpfit_data(tol=tol,Nitermax=Nitermax,gtol=gtol,/xlog,/ylog) -;res=dustem_mpfit_sed(tol=tol,Nitermax=Nitermax) ;,func_name=func_name,cf_min=cf_min) +res=dustem_mpfit_data(tol=tol,Nitermax=use_Nitermax,gtol=gtol,/xlog,/ylog) t2=systime(0,/sec) -;=== With FXD Model -;Final parameters : 0.00012425071 0.00022732277 0.0021897348 0.00047272697 4.4916225 -;Iter 6 CHI-SQUARE = 76.345245 DOF = 6 -;=== With MC Model -;Final parameters : 0.00012292305 0.00020672300 0.0020245400 0.00076911024 4.9751991 -;Iter 6 CHI-SQUARE = 76.047516 DOF = 6 -;=== With LV Model -;Final parameters : 0.00013302325 0.0010706767 0.0039392709 0.00074149811 4.7549752 -;Iter 10 CHI-SQUARE = 90.478020 DOF = 6 -;=== With LV Model using GRAIN_DBP.DAT -;Iter 7 CHI-SQUARE = 117.27229 DOF = 6 -;Final parameters : 0.00011163016 0.00015163894 0.0017526653 0.00096639410 5.8391213 - -;stop - ;=== SAVE FIT RESULTS -;file_out=getenv('DUSTEM_RES')+'DUSTEM_fit_example.sav' file_out='/tmp/DUSTEM_fit_example.sav' -;dustem_save_sed_fit,file_out dustem_save_system_variables,file_out message,'Saved '+file_out,/continue @@ -277,9 +263,6 @@ message,'Saved '+file_out,/continue file='/tmp/DUSTEM_fit_example.sav' dustem_restore_system_variables,file -;file=!dustem_res+'DUSTEM_fit_example.sav' -;dustem_restore_sed_fit,file - ;=== Plot best fit yr=[1e-4,10] xr=[1,2000] @@ -293,15 +276,6 @@ rchi2=(*!dustem_fit).rchi2 window,2 ;=== RESTORE FIT RESULTS -;=== initialise dustem -;dustem_init,mode=use_mode -;file=getenv('DUSTEM_RES')+'DUSTEM_fit_example.sav' - -;==== below is to reset the defaults keywords for PAH which in newer version of the fortran include spin and mix, ... -;(*!dustem_params).grains[0].TYPE_KEYWORDS='logn' -;(*!dustem_params).grains[1].TYPE_KEYWORDS='logn' - -;=== recover best fit values res=*(*!dustem_fit).current_param_values chi2=(*!dustem_fit).chi2 rchi2=(*!dustem_fit).rchi2 -- libgit2 0.21.2