Commit af6214c98fc46d61e1e00901a5d36edc99755df9

Authored by Ilyes Choubani
1 parent 53711375
Exists in master

Added Modified-Black-body plugin

src/idl/dustem_activate_plugins.pro
... ... @@ -102,8 +102,6 @@ FOR i=0L,n_elements(p_min)-1 DO BEGIN
102 102  
103 103 (*!dustem_scope).(k)=ptr_new(scope)
104 104  
105   - tgnms=tag_names((*!dustem_scope))
106   -
107 105 str='((*!dustem_plugin).('+strtrim(k,2)+'))=ptr_new('+ftn+'(key=index,val=value)'+')' & str=str(0)
108 106 toto=execute(str) & IF !dustem_verbose NE 0 THEN message,strupcase(strmid(ftn,7)),/info
109 107  
... ...
src/idl/dustem_cc.pro
... ... @@ -132,7 +132,7 @@ FOR i=0L,Nbands-1 DO BEGIN
132 132 'NUINU=CSTE': BEGIN
133 133 spec_int=interpol(spec2,wavein2,*(st.use_wavelengths(ii)))
134 134 num=integral(*(st.use_wavelengths(ii)),spec_int*(*(st.use_transmissions(ii)))/(*(st.use_wavelengths(ii)))^2.,st.use_wmin(ii),st.use_wmax(ii),/double)
135   - den=integral(*(st.use_wavelengths(ii)),(*(st.use_transmissions(ii)))/(*(st.use_wavelengths(ii))),st.use_wmin(ii),st.use_wmax(ii),/double)
  135 + den=integral(*(st.use_wavelengths(ii)),(*(st.use_transmissions(ii)))/(*(st.use_wavelengths(ii))),st.use_wmin(ii),st.use_wmax(ii),/double)
136 136 cc(i)=num/den/spec0*(st.central_wavelengths(ii))
137 137 END
138 138 'MIPS': BEGIN
... ...
src/idl/dustem_compute_sed.pro
... ... @@ -59,6 +59,9 @@ spec = st.sed.em_tot * fact
59 59  
60 60 ;ADDING PLUGIN TO SPECTRUM----------------
61 61 ;if n_tags(!dustem_data.sed) gt 1 then begin ; executing only when !dustem_data.sed is set meaning that this allows for the creation of fake seds
  62 +
  63 +
  64 +
62 65 scopes=tag_names((*!dustem_scope))
63 66 IF scopes[0] NE 'NONE' THEN BEGIN
64 67 for i=0L,n_tags(*!dustem_scope)-1 do begin
... ...
src/idl/dustem_init_plugins.pro
... ... @@ -23,30 +23,30 @@ for i=0L,n_elements(pd)-1 do begin
23 23 ENDFOR
24 24  
25 25  
26   -
27   -IF KEYWORD_SET(fpd) THEN BEGIN
28   -
29   - for i=0L,n_elements(fpd)-1 do begin
30   - fi=strtrim(strmid(fpd(i),0,strlen(plugind_detect_string)),2)
31   - if fi eq plugind_detect_string then begin
32   - if isa((*!dustem_fit).fixed_param_descs) then begin
33   -
34   - ftn = strmid((*(*!dustem_fit).fixed_param_descs)(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
35   -
36   - endif else ftn = strmid((*(*!dustem_fit).param_descs)(i),0)
37   -
38   -
39   - ii = strsplit(ftn,'_',count=countx)
40   - ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
41   - ftn = strmid(ftn,14,ii-14) ; String containing the name of the plugin without the associated keyword
42   - plugin_names=[plugin_names,ftn]
43   - Nplugins=Nplugins+1
44   - ENDIF
45   - ENDFOR
46   -
47   -
48   -ENDIF
49   -
  26 +;Dustem_init_fixed_params works so we do not need this block
  27 +;
  28 +; IF KEYWORD_SET(fpd) THEN BEGIN
  29 +;
  30 +; for i=0L,n_elements(fpd)-1 do begin
  31 +; fi=strtrim(strmid(fpd(i),0,strlen(plugind_detect_string)),2)
  32 +; if fi eq plugind_detect_string then begin
  33 +; if isa((*!dustem_fit).fixed_param_descs) then begin
  34 +;
  35 +; ftn = strmid((*(*!dustem_fit).fixed_param_descs)(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
  36 +;
  37 +; endif else ftn = strmid((*(*!dustem_fit).param_descs)(i),0)
  38 +;
  39 +;
  40 +; ii = strsplit(ftn,'_',count=countx)
  41 +; ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
  42 +; ftn = strmid(ftn,14,ii-14) ; String containing the name of the plugin without the associated keyword
  43 +; plugin_names=[plugin_names,ftn]
  44 +; Nplugins=Nplugins+1
  45 +; ENDIF
  46 +; ENDFOR
  47 +;
  48 +;
  49 +; ENDIF
50 50  
51 51 IF Nplugins EQ 0 THEN BEGIN
52 52 plugin_names=['NONE']
... ...
src/idl/dustem_plot_fit_sed.pro
... ... @@ -193,6 +193,11 @@ IF tag_exist(*!dustem_scope,'SYNCHROTRON') THEN BEGIN
193 193 cgoplot,st.sed.wav,(*(*!dustem_plugin).synchrotron)[*,0],color='Crimson',linestyle=3
194 194 ENDIF
195 195  
  196 +IF tag_exist(*!dustem_scope,'MBBDY') THEN BEGIN
  197 + cgoplot,st.sed.wav,(*(*!dustem_plugin).mbbdy)[*,0],color='Magenta',linestyle=3
  198 +ENDIF
  199 +
  200 +
196 201 cgoplot,st.sed.wav,spec/norm,color=use_col_tot,linestyle=use_line_tot
197 202 ;plot the normalized data as well.
198 203 ;----------------------------------------
... ...
src/idl/dustem_plugin_mbbdy.pro 0 โ†’ 100755
... ... @@ -0,0 +1,97 @@
  1 +FUNCTION dustem_plugin_mbbdy ,key=key,val=val,scope=scope,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; dustem_plugin_mbbdy
  6 +; PURPOSE:
  7 +; DUSTEM plugin to compute modified black-body emission
  8 +; CATEGORY:
  9 +; DUSTEM Wrapper
  10 +; CALLING SEQUENCE:
  11 +; output=dustem_plugin_mbbdy([,key=][,val=])
  12 +; INPUTS:
  13 +; None
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; key = input parameter number
  16 +; val = input parameter value
  17 +; OUTPUTS:
  18 +; output = MBB spectrum (on dustem wavelengths) (output[*,0] is Stokes I, output[*,1] Stokes Q and output[*,2] Stokes U)
  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 +; None
  29 +; PROCEDURE:
  30 +; This is a dustem plugin
  31 +; EXAMPLES
  32 +;
  33 +; MODIFICATION HISTORY:
  34 +; Written by JPB
  35 +;-
  36 +
  37 +IF keyword_set(help) THEN BEGIN
  38 + doc_library,'dustem_plugin_mbbdy'
  39 + output=0.
  40 + goto,the_end
  41 +ENDIF
  42 +
  43 +;default values of input parameters
  44 +amp = 0.5 ; Amplitude of the modified black-body emission
  45 +temp = 19 ; Temperature of the dust species
  46 +beta = 1.8 ; Emissivity index
  47 +
  48 +w0=100. ; Theoretical wavelength (3THz) where optical depth equals unity
  49 +;check formula of modified black body in the optically thin case
  50 +
  51 +;default polarization values
  52 +smallp=0.
  53 +psi=0.
  54 +
  55 +
  56 +IF keyword_set(key) THEN BEGIN
  57 +
  58 + ind1=where(key EQ 1,count1) ; reading amp
  59 + ind2=where(key EQ 2,count2) ; reading temp
  60 + ind3=where(key EQ 3,count3) ; reading beta
  61 +
  62 + ;In the case this plugin is used in polarization
  63 + ind4=where(key EQ 4,count4) ; reading smallp
  64 + ind5=where(key EQ 5,count5) ; reading psi
  65 +
  66 +
  67 + IF count1 NE 0 then amp=val[ind1[0]] ;else default value
  68 + IF count2 NE 0 then temp=val[ind2[0]] ; // //
  69 + IF count3 NE 0 then beta=val[ind3[0]] ; // //
  70 + IF count4 NE 0 then smallp=val[ind4[0]] ; // //
  71 + IF count5 NE 0 then psi=val[ind5[0]] ; // //
  72 +
  73 +ENDIF
  74 +
  75 +lambir=dustem_get_wavelengths()
  76 +Nwavs=n_elements(lambir)
  77 +spec=amp*(lambir/w0)^(-1.*beta)*dustem_planck_function(temp,lambir)
  78 +
  79 +
  80 +;see Deschenes et al 2008, eq 6
  81 +output=fltarr(Nwavs,3)
  82 +output[*,0]=spec
  83 +
  84 +;polarization this actually need to
  85 +polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
  86 +
  87 +output[*,1]=Q
  88 +output[*,2]=U
  89 +
  90 +
  91 +scope='ADD_SED+ADD_QSED+ADD_USED'
  92 +
  93 +
  94 +the_end:
  95 +RETURN,output
  96 +
  97 +END
... ...