Commit ae290a6ad6a760e8abbb97b1ac3a2306764eddca

Authored by Annie Hughes
2 parents ab7bdcb3 6ad05c38
Exists in master

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

LabTools/IRAP/JPB/srun/make_phangs_grids.pro
@@ -13,6 +13,9 @@ PRO make_phangs_grids,bidon @@ -13,6 +13,9 @@ PRO make_phangs_grids,bidon
13 ;more {$phangs_srundir}/make_phangs_grids.log | grep "iteration " 13 ;more {$phangs_srundir}/make_phangs_grids.log | grep "iteration "
14 ;more {$phangs_srundir}/make_phangs_grids.log | grep "Will produce" 14 ;more {$phangs_srundir}/make_phangs_grids.log | grep "Will produce"
15 15
  16 +;This won't work, because it needs the Fortran to set files to the same area ...
  17 +;defsysv,'!DUSTEM_RES','/tmp/jbernard/Dustem_nohup'
  18 +
16 t0=systime(/sec) 19 t0=systime(/sec)
17 20
18 ;make grid 21 ;make grid
plugin_scopes_definition.xcat
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 \------------------------------------------------ 13 \------------------------------------------------
14 \This scope is for plugins adding to the output SEDs 14 \This scope is for plugins adding to the output SEDs
15 ADD SED 1 15 ADD SED 1
16 -ADD POLSED 1 16 +\ADD POLSED 1
17 \This scope is for plugins replacing the ISRF before fortran is run 17 \This scope is for plugins replacing the ISRF before fortran is run
18 REPLACE ISRF 2 18 REPLACE ISRF 2
19 ADD ISRF 2 19 ADD ISRF 2
20 \This scope is for plugins replacing the fortran SEDs 20 \This scope is for plugins replacing the fortran SEDs
21 REPLACE SED 3 21 REPLACE SED 3
22 -REPLACE POLSED 3 22 +\REPLACE POLSED 3
23 REPLACE POLEXT 3 23 REPLACE POLEXT 3
24 \This scope is for plugins which fully replace the Fortran, including by calling Fortran several times ... 24 \This scope is for plugins which fully replace the Fortran, including by calling Fortran several times ...
25 REPLACE FORTRAN 4 25 REPLACE FORTRAN 4
src/idl/dustem_activate_plugins.pro
@@ -78,36 +78,27 @@ ENDELSE @@ -78,36 +78,27 @@ ENDELSE
78 78
79 ;stop 79 ;stop
80 80
81 -;Run the plugins, according to their scopes 81 +;===== Run the plugins, according to their scopes (and the Fortran)
82 82
83 -;normal (additive) plugins come first as they can be used by other plugins  
84 -;The ISRF plugin is next - we can always change its scope however we please to. DustEm runs here. This is with the /force_dustem_run keyword.  
85 -;The plugins that use the DustEM output come next - we can always change their 'common' scope 83 +;The 'ADD_SED' plugins are run first. Note that their output could be used by plugins run later.
  84 +;The plugins related to 'ISRF' are run second, and the Fortrn is run at that stage, just after the corresponding plugins.
  85 +;The plugins which Replace the output of the fortran are run last.
86 86
87 ;IF /avoid is used the specified scopes are avoided. They're considered when /avoid is missing. 87 ;IF /avoid is used the specified scopes are avoided. They're considered when /avoid is missing.
88 ;using '**' so not to write the entire scope 88 ;using '**' so not to write the entire scope
89 89
90 -;=== This runs plugins with scopes including STELLAR, REPLACE and ISRF  
91 -;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD','REPLACE'], avoid=1,use_previous_fortran=use_previous_fortran  
92 -dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_SED'], avoid=1,use_previous_fortran=use_previous_fortran 90 +;=== This runs the plugins
  91 +;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_SED'], avoid=1,use_previous_fortran=use_previous_fortran
  92 +dustem_run_plugins, p_dim ,param_descs, param_values, param_func, 1, avoid=1,use_previous_fortran=use_previous_fortran
93 93
94 -;=== The line below makes fawlty go Segmentation fault. st is undefined at that stage  
95 -;=== it would run fine if avoid was set to 1  
96 -;IC: I think the segmentation fault comes from the fact that the user wants to use models that have the /pol keyword in the GRAIN.DAT file without being in polarization mode. 94 +;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_ISRF','REPLACE_ISRF'] ,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step.
  95 +dustem_run_plugins, p_dim ,param_descs, param_values, param_func, 2,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step.
97 96
98 -;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['STELLAR','ISRF'] ,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step.  
99 -dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['ADD_ISRF','REPLACE_ISRF'] ,force_dustem_run=1,st=st,use_previous_fortran=use_previous_fortran ;dustem output is available at this step. 97 +;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE_SED'],use_previous_fortran=use_previous_fortran
  98 +dustem_run_plugins, p_dim ,param_descs, param_values, param_func, 3,use_previous_fortran=use_previous_fortran
100 99
101 -;added this small condition to ensure that dustem is run  
102 -;(if no ISRF plugin is used)  
103 -; if ~isa(st) then begin  
104 -; st=dustem_run(p_dim)  
105 -; !dustem_current=ptr_new(st)  
106 -; endif  
107 -;THE ABOVE CONDITION IS UNNECESSARY SINCE DUSTEM IS CALLED ABOVE WHETHER PLUGINS ARE RUN OR NOT.  
108 -  
109 -;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE'],use_previous_fortran=use_previous_fortran  
110 -dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE_SED'],use_previous_fortran=use_previous_fortran 100 +;dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['REPLACE_SED'],use_previous_fortran=use_previous_fortran
  101 +dustem_run_plugins, p_dim ,param_descs, param_values, param_func, 4,use_previous_fortran=use_previous_fortran
111 102
112 103
113 the_end: 104 the_end:
src/idl/dustem_compute_stokes.pro
@@ -75,18 +75,25 @@ P = st.polsed.em_tot * fact ;This is Polarized intensity P @@ -75,18 +75,25 @@ P = st.polsed.em_tot * fact ;This is Polarized intensity P
75 75
76 Nwaves=(size(stI))[1] 76 Nwaves=(size(stI))[1]
77 77
78 -frac=P/stI 78 +;stop
  79 +
  80 +;This some times leads to division by 0
  81 +frac=P/stI
79 tes=where(finite(frac) eq 0) 82 tes=where(finite(frac) eq 0)
80 frac(tes)=0. 83 frac(tes)=0.
81 84
82 -scopes=tag_names((*!dustem_plugin)) 85 +scopes=(*!dustem_plugin).scope
  86 +n_plugins=n_elements(scopes)
  87 +
83 IF scopes[0] NE 'NONE' THEN BEGIN 88 IF scopes[0] NE 'NONE' THEN BEGIN
84 - FOR i=0L,n_tags(*!dustem_plugin)-1 DO BEGIN  
85 - IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'REPLACE_POLSED') THEN BEGIN  
86 - Q_spec = (*(*!dustem_plugin).(i).spec)[*,1]  
87 - U_spec = (*(*!dustem_plugin).(i).spec)[*,2]  
88 - ENDIF  
89 - ENDFOR 89 + FOR i=0L,n_plugins-1 DO BEGIN
  90 + ;IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'REPLACE_POLSED') THEN BEGIN
  91 + ;IF total(strsplit((*!dustem_plugin)[i].scope,'+',/extract) EQ 'REPLACE_POLSED') THEN BEGIN
  92 + IF total(strsplit((*!dustem_plugin)[i].scope,'+',/extract) EQ 'REPLACE_SED') THEN BEGIN
  93 + Q_spec = (*(*!dustem_plugin)[i].spec)[*,1]
  94 + U_spec = (*(*!dustem_plugin)[i].spec)[*,2]
  95 + ENDIF
  96 + ENDFOR
90 ENDIF 97 ENDIF
91 98
92 IF ~isa(Q_spec) && ~isa(U_spec) THEN BEGIN 99 IF ~isa(Q_spec) && ~isa(U_spec) THEN BEGIN
@@ -94,18 +101,14 @@ ENDIF @@ -94,18 +101,14 @@ ENDIF
94 ENDIF 101 ENDIF
95 102
96 IF scopes[0] NE 'NONE' THEN BEGIN 103 IF scopes[0] NE 'NONE' THEN BEGIN
97 - FOR i=0L,n_tags(*!dustem_plugin)-1 DO BEGIN  
98 -  
99 - IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN BEGIN  
100 -  
101 - Q_spec+=(*(*!dustem_plugin).(i).spec)[*,1]  
102 - U_spec+=(*(*!dustem_plugin).(i).spec)[*,2]  
103 -  
104 - 104 + FOR i=0L,n_plugins-1 DO BEGIN
  105 + ;IF total(strsplit((*(*!dustem_plugin).(i).scope),'+',/extract) EQ 'ADD_POLSED') THEN BEGIN
  106 + ;IF total(strsplit((*!dustem_plugin)[i].scope,'+',/extract) EQ 'ADD_POLSED') THEN BEGIN
  107 + IF total(strsplit((*!dustem_plugin)[i].scope,'+',/extract) EQ 'ADD_SED') THEN BEGIN
  108 + Q_spec+=(*(*!dustem_plugin)[i].spec)[*,1]
  109 + U_spec+=(*(*!dustem_plugin)[i].spec)[*,2]
105 ENDIF 110 ENDIF
106 -  
107 ENDFOR 111 ENDFOR
108 -  
109 ENDIF 112 ENDIF
110 ;----------------------------------------- 113 ;-----------------------------------------
111 ind=where(finite(U_spec) NE 1 OR finite(Q_spec) NE 1,count) 114 ind=where(finite(U_spec) NE 1 OR finite(Q_spec) NE 1,count)
src/idl/dustem_fit_intensity_mbb_example.pro
@@ -162,7 +162,7 @@ if keyword_set(wait) then begin @@ -162,7 +162,7 @@ if keyword_set(wait) then begin
162 end 162 end
163 163
164 ;== INITIALISE DUSTEM 164 ;== INITIALISE DUSTEM
165 -dustem_init,model=use_model,polarization=use_polarization 165 +dustem_init,model=use_model,polarization=use_polarization,/show_plots
166 !dustem_nocatch=1 166 !dustem_nocatch=1
167 !dustem_verbose=use_verbose 167 !dustem_verbose=use_verbose
168 IF keyword_set(noobj) THEN !dustem_noobj=1 168 IF keyword_set(noobj) THEN !dustem_noobj=1
src/idl/dustem_init_plugins.pro
@@ -88,7 +88,13 @@ plugin_names=plugin_names[un] @@ -88,7 +88,13 @@ plugin_names=plugin_names[un]
88 parameter_types=parameter_types[un] 88 parameter_types=parameter_types[un]
89 89
90 ind=where(parameter_types EQ 'PLUGIN',Nplugins) 90 ind=where(parameter_types EQ 'PLUGIN',Nplugins)
91 -one_plugin_st={name:'',spec:ptr_new(),scope:'',paramtag:ptr_new()} 91 +;===== This is the dustem structure describing the plugin scopes
  92 +one_plugin_st={name:'', $ ;name of the plugin
  93 + spec:ptr_new(), $ ;output of the plugin (a spectrum)
  94 + scope:'', $ ;scope of the plugin
  95 + run_order:0L, $ ;plugin run order
  96 + paramtag:ptr_new() $ ;parameter names
  97 + }
92 98
93 IF Nplugins EQ 0 THEN BEGIN 99 IF Nplugins EQ 0 THEN BEGIN
94 plugin_st=replicate(one_plugin_st,1) 100 plugin_st=replicate(one_plugin_st,1)
@@ -114,6 +120,18 @@ FOR i=0L,Nplugins-1 DO BEGIN @@ -114,6 +120,18 @@ FOR i=0L,Nplugins-1 DO BEGIN
114 toto=execute(str) 120 toto=execute(str)
115 plugin_st[i].paramtag=ptr_new(paramtag) 121 plugin_st[i].paramtag=ptr_new(paramtag)
116 ENDFOR 122 ENDFOR
  123 +;derive the run order from the scopes
  124 +file_scopes=!dustem_wrap_soft_dir+'plugin_scopes_definition.xcat'
  125 +scope_st=read_xcat(file_scopes,/silent)
  126 +possible_scopes=scope_st.objective+'_'+scope_st.target
  127 +FOR i=0L,Nplugins-1 DO BEGIN
  128 + ind=where(possible_scopes EQ plugin_st[i].scope,count)
  129 + IF count EQ 0 THEN BEGIN
  130 + message,'scope '+plugin_st[i].scope+' not recognized',/continue
  131 + stop
  132 + ENDIF
  133 + plugin_st[i].run_order=scope_st[ind[0]].run_order
  134 +ENDFOR
117 135
118 ;creates the !dustem_plugin structure 136 ;creates the !dustem_plugin structure
119 defsysv, '!dustem_plugin', ptr_new(plugin_st) 137 defsysv, '!dustem_plugin', ptr_new(plugin_st)
src/idl/dustem_plugin_freefree.pro
@@ -23,8 +23,11 @@ FUNCTION dustem_plugin_freefree,key=key $ @@ -23,8 +23,11 @@ FUNCTION dustem_plugin_freefree,key=key $
23 ; 23 ;
24 ; OPTIONAL INPUT PARAMETERS: 24 ; OPTIONAL INPUT PARAMETERS:
25 ; key = input parameter number 25 ; key = input parameter number
  26 +; 1 : Tgas [K]
  27 +; 2 : free-free Amplitude []
  28 +; 3 : polarization fraction [%] (default=0)
  29 +; 4 : polarization angle [deg]
26 ; val = input parameter value 30 ; val = input parameter value
27 -;  
28 ; OUTPUTS: 31 ; OUTPUTS:
29 ; freefree = free-free spectrum (on dustem wavelengths) 32 ; freefree = free-free spectrum (on dustem wavelengths)
30 ; 33 ;
@@ -77,29 +80,21 @@ IF keyword_set(key) THEN BEGIN @@ -77,29 +80,21 @@ IF keyword_set(key) THEN BEGIN
77 b=where(key EQ 2,count2) 80 b=where(key EQ 2,count2)
78 c=where(key EQ 3,count3) ;default polarization fraction -newly added 81 c=where(key EQ 3,count3) ;default polarization fraction -newly added
79 d=where(key EQ 4,count4) ;default polarization angle -newly added 82 d=where(key EQ 4,count4) ;default polarization angle -newly added
80 - IF count1 NE 0 then Tgas=(val(a))(0)  
81 - IF count2 NE 0 then Amplitude=(val(b))(0)  
82 - IF count3 NE 0 then smallp=val[c[0]] ;-newly added  
83 - IF count4 NE 0 then psi=val[d[0]] ;-newly added 83 + IF count1 NE 0 then Tgas=val[a[0]]
  84 + IF count2 NE 0 then Amplitude=val[b[0]]
  85 + IF count3 NE 0 then smallp=val[c[0]]
  86 + IF count4 NE 0 then psi=val[d[0]]
84 ENDIF 87 ENDIF
85 88
86 -;IF !dustem_which EQ 'DESERT' THEN BEGIN  
87 -; lambir=((*!dustem_params).gemissiv.lambir)  
88 -;ENDIF ELSE BEGIN  
89 -; lambir=((*!dustem_params).lambda.lambda)  
90 -;ENDELSE  
91 -;replaced by the following to ease the life of plugins writters  
92 lambir=dustem_get_wavelengths() 89 lambir=dustem_get_wavelengths()
93 Nwavs=n_elements(lambir) 90 Nwavs=n_elements(lambir)
94 cmic=3.e14 91 cmic=3.e14
95 nu=cmic/lambir ;Hz 92 nu=cmic/lambir ;Hz
96 mjy=1 ;output is in MJy/sr 93 mjy=1 ;output is in MJy/sr
97 -lambir_ref=10000.  
98 - 94 +lambir_ref=10000. ;in mic (this is 1cm)
99 95
100 -output=fltarr(Nwavs,3) ;newly added 96 +output=fltarr(Nwavs,3)
101 97
102 -;stop  
103 ;use_method='Deschenes2008' 98 ;use_method='Deschenes2008'
104 ;use_method='WallsGabaud1998' 99 ;use_method='WallsGabaud1998'
105 use_method='Dickinson2003_norm' 100 use_method='Dickinson2003_norm'
@@ -140,10 +135,7 @@ ENDCASE @@ -140,10 +135,7 @@ ENDCASE
140 polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs) 135 polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
141 136
142 output[*,1]=Q 137 output[*,1]=Q
143 -output[*,2]=U  
144 -;output[*,3]=replicate(smallp,Nwavs)  
145 -;output[*,4]=replicate(psi,Nwavs)  
146 - 138 +output[*,2]=U
147 139
148 the_end: 140 the_end:
149 RETURN,output 141 RETURN,output
src/idl/dustem_plugin_mbbdy.pro
@@ -52,7 +52,8 @@ w0=100. ; Theoretical wavelength (3THz) where optical depth equals unity @@ -52,7 +52,8 @@ w0=100. ; Theoretical wavelength (3THz) where optical depth equals unity
52 smallp=0. 52 smallp=0.
53 psi=0. 53 psi=0.
54 54
55 -scope='ADD_SED+ADD_POLSED' 55 +;scope='ADD_SED+ADD_POLSED'
  56 +scope='ADD_SED'
56 paramtag=['Amp',textoidl('T_{MBB}')+' [K]',textoidl('\beta'),'p','Psi [deg]'] 57 paramtag=['Amp',textoidl('T_{MBB}')+' [K]',textoidl('\beta'),'p','Psi [deg]']
57 58
58 IF keyword_set(key) THEN BEGIN 59 IF keyword_set(key) THEN BEGIN
src/idl/dustem_plugin_modify_dust_pol.pro
@@ -5,31 +5,33 @@ FUNCTION dustem_plugin_modify_dust_pol, key=key, val=val, scope=scope, paramtag= @@ -5,31 +5,33 @@ FUNCTION dustem_plugin_modify_dust_pol, key=key, val=val, scope=scope, paramtag=
5 ; dustem_plugin_modify_dust_pol 5 ; dustem_plugin_modify_dust_pol
6 ; 6 ;
7 ; PURPOSE: 7 ; PURPOSE:
8 -; modifies Emission Stokes Q,U values for dust polarization in st according to the given keywords and values  
9 -; 8 +; Replaces the emission in polarization (Stokes Q,U) with a fixed polarization angle and fraction
  9 +; Q,U to be replaced are computed from the total intensity as:
  10 +; Q=I*val[0]*p*cos(2*val[1])
  11 +; U=I*val[0]*p*sin(2*val[1])
  12 +; where I is the total intensity in the model and p is the polarization fraction in the model
10 ; CATEGORY: 13 ; CATEGORY:
11 ; DustEMWrap, Plugin, Mid-level, Distributed 14 ; DustEMWrap, Plugin, Mid-level, Distributed
12 ; 15 ;
13 ; CALLING SEQUENCE: 16 ; CALLING SEQUENCE:
14 -; a=dustem_plugin_modify_dust_pol(st,[key=][val=][,scope=][,paramtag=][,paramdefault=][,/help]) 17 +; a=dustem_plugin_modify_dust_pol([key=][val=][,scope=][,paramtag=][,paramdefault=][,/help])
15 ; 18 ;
16 ; INPUTS: 19 ; INPUTS:
17 ; st = dustem structure 20 ; st = dustem structure
18 ; 21 ;
19 ; OPTIONAL INPUT PARAMETERS: 22 ; OPTIONAL INPUT PARAMETERS:
20 -; key = input parameter numbers (first = polarization fraction in %, default=1.%, second=polarization angle, default=0.) 23 +; key = input parameter numbers
  24 +; first = multiplication factor for the polarization fraction
  25 +; second = polarization angle [deg], default=0.
21 ; val = input parameter values 26 ; val = input parameter values
22 -;  
23 ; OUTPUTS: 27 ; OUTPUTS:
24 -; out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both 28 +; out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
25 ; 29 ;
26 ; OPTIONAL OUTPUT PARAMETERS: 30 ; OPTIONAL OUTPUT PARAMETERS:
27 ; scope = if set, returns only the scope of the pluggin 31 ; scope = if set, returns only the scope of the pluggin
28 ; paramtag = if set, returns only the parameter tags 32 ; paramtag = if set, returns only the parameter tags
29 -;  
30 ; ACCEPTED KEY-WORDS: 33 ; ACCEPTED KEY-WORDS:
31 ; help = if set, print this help 34 ; help = if set, print this help
32 -;  
33 ; COMMON BLOCKS: 35 ; COMMON BLOCKS:
34 ; None 36 ; None
35 ; 37 ;
@@ -53,20 +55,25 @@ IF keyword_set(help) THEN BEGIN @@ -53,20 +55,25 @@ IF keyword_set(help) THEN BEGIN
53 ENDIF 55 ENDIF
54 56
55 IF keyword_set(scope) THEN BEGIN 57 IF keyword_set(scope) THEN BEGIN
  58 + ;scope='REPLACE_POLSED'
  59 + scope='REPLACE_SED'
56 out=0 60 out=0
57 GOTO, the_end 61 GOTO, the_end
58 ENDIF 62 ENDIF
59 63
60 IF keyword_set(paramtag) THEN BEGIN 64 IF keyword_set(paramtag) THEN BEGIN
  65 + paramtag=['p',textoidl('\psi')+' [deg]']
61 out=0. 66 out=0.
62 GOTO, the_end 67 GOTO, the_end
63 ENDIF 68 ENDIF
64 69
65 ;Retrieving this sytem variable (dustem output) 70 ;Retrieving this sytem variable (dustem output)
66 -if ~isa(!dustem_current) then begin  
67 - out=0 71 +IF ~isa(!dustem_current) then begin
  72 + out=0
68 goto, the_end 73 goto, the_end
69 -ENDIF else st=(*!dustem_current) 74 +ENDIF ELSE BEGIN
  75 + st=(*!dustem_current)
  76 +ENDELSE
70 77
71 ;below are the default values for the plugin parameters 78 ;below are the default values for the plugin parameters
72 smallp_fact=1. ;This is the default dust polarization factor 79 smallp_fact=1. ;This is the default dust polarization factor
@@ -76,12 +83,13 @@ IF keyword_set(key) THEN BEGIN @@ -76,12 +83,13 @@ IF keyword_set(key) THEN BEGIN
76 ind1=where(key EQ 1,count1) 83 ind1=where(key EQ 1,count1)
77 ind2=where(key EQ 2,count2) 84 ind2=where(key EQ 2,count2)
78 IF count1 NE 0 THEN smallp_fact=val[ind1[0]] ; setting smallp from pd - this is another polarization fraction (constant) that is applied to the total dust emission 85 IF count1 NE 0 THEN smallp_fact=val[ind1[0]] ; setting smallp from pd - this is another polarization fraction (constant) that is applied to the total dust emission
79 - IF count2 NE 0 THEN psi=val[ind2[0]] & !dustem_psi = psi ; setting psi from pd. !dustem_psi here helps for the plotting. 86 + IF count2 NE 0 THEN psi=val[ind2[0]]
  87 + !dustem_psi = psi ; setting psi from pd. !dustem_psi here helps for the plotting.
80 ENDIF 88 ENDIF
81 89
82 fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7 90 fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7
83 -P=((st.polsed).em_tot)*fact ; This is the polarized emission P  
84 -I=((st.sed).em_tot)*fact ; This is the total intensity emission I 91 +P=((st.polsed).em_tot)*fact ; This is the polarized emission P currently in the model
  92 +I=((st.sed).em_tot)*fact ; This is the total intensity emission I currently in the model
85 93
86 Nwaves=(size(I))[1] 94 Nwaves=(size(I))[1]
87 95
@@ -90,7 +98,7 @@ Nwaves=(size(I))[1] @@ -90,7 +98,7 @@ Nwaves=(size(I))[1]
90 98
91 frac_model=P*0. 99 frac_model=P*0.
92 indI = where(I ne 0, countI) 100 indI = where(I ne 0, countI)
93 -if countI ne 0 then frac_model[indI] = P[indI]/I[indI] ;This is the polarization fraction in the model 101 +if countI ne 0 then frac_model[indI] = P[indI]/I[indI] ;This is the polarization fraction currently in the model
94 102
95 frac_used=frac_model*smallp_fact 103 frac_used=frac_model*smallp_fact
96 104
@@ -98,22 +106,15 @@ psi_used = replicate(psi,Nwaves) @@ -98,22 +106,15 @@ psi_used = replicate(psi,Nwaves)
98 106
99 polar_ippsi2iqu,I,Q,U,frac_used,psi_used 107 polar_ippsi2iqu,I,Q,U,frac_used,psi_used
100 108
101 -out=fltarr(Nwaves,3) ; modified this. This is the only plugin that has this number of outputs.  
102 -  
103 -;degtorad = !pi/180 109 +out=fltarr(Nwaves,3)
104 110
105 out[*,0]=I 111 out[*,0]=I
106 out[*,1]=Q 112 out[*,1]=Q
107 out[*,2]=U 113 out[*,2]=U
108 -; out[*,3]=frac_used  
109 -; ;out[*,4]=0.5*atan(U,Q)/degtorad  
110 -; out[*,4]=psi_used  
111 114
112 RETURN, out 115 RETURN, out
113 116
114 the_end: 117 the_end:
115 -scope='REPLACE_POLSED'  
116 -paramtag=['p',textoidl('\psi')+' [deg]']  
117 118
118 119
119 END 120 END
src/idl/dustem_plugin_synchrotron.pro
@@ -64,7 +64,8 @@ s=3 ;power spectrum of CR E distribution @@ -64,7 +64,8 @@ s=3 ;power spectrum of CR E distribution
64 A=1 ;Synchrotron radiation amplitude at 10 mm 64 A=1 ;Synchrotron radiation amplitude at 10 mm
65 psi=0. ;default polarization angle 65 psi=0. ;default polarization angle
66 smallp=0.3;0.3 ;default polarization fraction 66 smallp=0.3;0.3 ;default polarization fraction
67 -scope='ADD_SED+ADD_POLSED' 67 +;scope='ADD_SED+ADD_POLSED'
  68 +scope='ADD_SED'
68 ;paramtag=['s (plaw_index)','Amp','p','Psi (deg)'] 69 ;paramtag=['s (plaw_index)','Amp','p','Psi (deg)']
69 paramtag=[textoidl('\alpha_{CR}'),'Amp','p',textoidl('\psi')+' [deg]'] 70 paramtag=[textoidl('\alpha_{CR}'),'Amp','p',textoidl('\psi')+' [deg]']
70 paramdefault=[s,A,smallp,psi] 71 paramdefault=[s,A,smallp,psi]
src/idl/dustem_read_dustem_lv.pro
@@ -79,6 +79,7 @@ ENDWHILE @@ -79,6 +79,7 @@ ENDWHILE
79 ;readf,unit,str 79 ;readf,unit,str
80 CLOSE,unit 80 CLOSE,unit
81 free_lun,unit 81 free_lun,unit
  82 +
82 str=strcompress(str) 83 str=strcompress(str)
83 str=strtrim(str,2) 84 str=strtrim(str,2)
84 vv=str_sep(str,' ') 85 vv=str_sep(str,' ')
@@ -100,12 +101,11 @@ Nlines=n_elements(wav) @@ -100,12 +101,11 @@ Nlines=n_elements(wav)
100 101
101 instruc='one_st={wav:0.,' 102 instruc='one_st={wav:0.,'
102 FOR i=0L,Ngrains-1 DO BEGIN 103 FOR i=0L,Ngrains-1 DO BEGIN
103 - instruc=instruc+'em_grain_'+strtrim(i+1,2)+':0.,' 104 + instruc=instruc+'em_grain_'+strtrim(i+1,2)+':0.D0,'
104 ENDFOR 105 ENDFOR
105 -instruc=instruc+'em_tot:0.}' 106 +instruc=instruc+'em_tot:0.D0}'
106 message,'Executing '+instruc,/info 107 message,'Executing '+instruc,/info
107 toto=execute(instruc) 108 toto=execute(instruc)
108 -  
109 st=replicate(one_st,Nlines) 109 st=replicate(one_st,Nlines)
110 110
111 st.wav=wav 111 st.wav=wav
@@ -113,6 +113,7 @@ FOR i=0L,Ngrains-1 DO BEGIN @@ -113,6 +113,7 @@ FOR i=0L,Ngrains-1 DO BEGIN
113 instruc='st.(i+1)='+'em_grain_'+strtrim(i+1,2) 113 instruc='st.(i+1)='+'em_grain_'+strtrim(i+1,2)
114 message,'Executing '+instruc,/info 114 message,'Executing '+instruc,/info
115 toto=execute(instruc) 115 toto=execute(instruc)
  116 + ;stop
116 ENDFOR 117 ENDFOR
117 st.em_tot=em_tot 118 st.em_tot=em_tot
118 119
src/idl/dustem_run_plugins.pro
1 -PRO dustem_run_plugins, p_dim ,$  
2 - param_descs,$  
3 - param_values,$  
4 - param_func,$  
5 - scopes,$  
6 - st=st,$  
7 - avoid=avoid,$  
8 - force_dustem_run=force_dustem_run,$  
9 - use_previous_fortran=use_previous_fortran, $  
10 - help=help 1 +PRO dustem_run_plugins, p_dim $
  2 + ,param_descs $
  3 + ,param_values $
  4 + ,param_func $
  5 + ,run_order $
  6 + ,st=st $
  7 + ,avoid=avoid $
  8 + ,force_dustem_run=force_dustem_run $
  9 + ,use_previous_fortran=use_previous_fortran $
  10 + ,help=help
11 11
12 ;+ 12 ;+
13 ; NAME: 13 ; NAME:
@@ -28,7 +28,7 @@ PRO dustem_run_plugins, p_dim ,$ @@ -28,7 +28,7 @@ PRO dustem_run_plugins, p_dim ,$
28 ; param_descs = parameter description vector 28 ; param_descs = parameter description vector
29 ; param_values = current parameter values 29 ; param_values = current parameter values
30 ; param-func = plugin indices array 30 ; param-func = plugin indices array
31 -; scopes = scopes of plugins 31 +; run_order = run order of the plugins to be run
32 ; 32 ;
33 ; OPTIONAL INPUT PARAMETERS: 33 ; OPTIONAL INPUT PARAMETERS:
34 ; avoid = scopes should be avoided 34 ; avoid = scopes should be avoided
@@ -85,12 +85,14 @@ Nplugins=n_elements(*!dustem_plugin) @@ -85,12 +85,14 @@ Nplugins=n_elements(*!dustem_plugin)
85 must_be_run=intarr(Nplugins) 85 must_be_run=intarr(Nplugins)
86 86
87 FOR i=0L,Nplugins-1 DO BEGIN 87 FOR i=0L,Nplugins-1 DO BEGIN
88 - FOR j=0L,n_elements(scopes)-1 DO BEGIN  
89 - pos=strposmulti((*!dustem_plugin)[i].scope,scopes[j],count)  
90 - IF count NE 0 THEN must_be_run[i]=1  
91 - ENDFOR 88 + IF (*!dustem_plugin)[i].run_order EQ run_order THEN BEGIN
  89 + must_be_run[i]=1
  90 + ENDIF
92 ENDFOR 91 ENDFOR
93 92
  93 +;print,must_be_run
  94 +;stop
  95 +
94 ;=== run plugins that need be run 96 ;=== run plugins that need be run
95 FOR i=0L,Nplugins-1 DO BEGIN 97 FOR i=0L,Nplugins-1 DO BEGIN
96 IF must_be_run[i] THEN BEGIN 98 IF must_be_run[i] THEN BEGIN