;== Initialize DustemWrap dustem_init ;== set DustemWrap behavior !dustem_verbose=1 !dustem_show_plot=1 ;== Read an SED dir=!dustem_wrap_soft_dir+'/Data/SEDs/' file=dir+'Gal_composite_spectrum.xcat' spec=read_xcat(file,/silent) ;=== SET THE OBSERVATION STRUCTURE dustem_set_data,spec ;== define which model parameters to vary ;=== pd is the parameter definition pd=[$ '(*!dustem_params).G0', $ ;G0 radiation field intensity '(*!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 mass fraction '(*!dustem_params).grains(3).mdust_o_mh',$ ;amCBEx mass fraction '(*!dustem_params).grains(4).mdust_o_mh',$ ;aSil mass fraction 'dustem_create_continuum_2'] ;Intensity of NIR continuum Npar=n_elements(pd) ;=== iv gives the corresponding initial values iv = [1.0, 7.8e-4, 7.8e-4,1.65e-4,1.45e-3,7.8e-3,0.001] ;=== The following indicate if the parameters are upper or lower limited ulimed=replicate(0,Npar) llimed=replicate(1,Npar) ;=== The following gives corresponding lower limits llims=replicate(0.,Npar) ;== SET THE FITTED PARAMETERS dustem_init_parinfo,pd,iv,up_limited=ulimed, $ lo_limited=llimed,up_limits=ulims,lo_limits=llims ;== Run the SED fitting tol=1.e-14 ;Tolerance used Nitermax=3 ;maximum number of iteration ;This is the criterium which will stop the fit procedure loadct,13 ;This is to ajust plot range !y.range=[1e-4,10] res=dustem_mpfit_sed(tol=tol,Nitermax=Nitermax) ;=== Plot best fit yr=[1e-4,10] & xr=[1,2000] tit='DUSTEM Example' ytit=textoidl('I_\nu (MJy/sr) for N_H=10^{20} H/cm^2') xtit=textoidl('\lambda (\mum)') errors=(*(*!dustem_fit).current_param_errors)*(*(*!dustem_fit).param_init_values) chi2=(*!dustem_fit).chi2 rchi2=(*!dustem_fit).rchi2 loadct,13 dustem_sed_plot,(*(*!dustem_fit).current_param_values), $ ytit=ytit,xtit=xtit,title=tit,yr=yr,xr=xr,/ysty,/xsty, $ res=res,errors=errors,chi2=chi2,rchi2=rchi2