Blame view

src/idl/dustem_plugin_modify_dust_pol.pro 2.47 KB
5f04fa07   Ilyes Choubani   general update
1
Function dustem_plugin_modify_dust_pol, st, key=key, val=val, scope=scope, paramtag=paramtag, help=help
6cde48ea   Ilyes Choubani   missing procedure
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

;+
; NAME:
;    dustem_plugin_modify_dust_pol
; PURPOSE:
;    Produces stokes emission parameters for the dust and synchrotron components
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
;    dustem_create_stokes(st,key=key,val=val)
; INPUTS:
;
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;    val  = input parameter value
; OUTPUTS:
;    out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    This is a dustem plugin
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_create_stokes'
  out=0.
  goto,the_end
ENDIF

5f04fa07   Ilyes Choubani   general update
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
IF keyword_set(scope) THEN BEGIN
    out=0.
    goto, the_scope
ENDIF 

IF keyword_set(paramtag) THEN BEGIN
    out=0.
    goto, the_paramtag
ENDIF 

; if not keyword_set(st) then begin
;     ;stop
;     IF  ptr_valid((*!dustem_fit).CURRENT_PARAM_VALUES) THEN BEGIN
;         p_di=(*(*!dustem_fit).CURRENT_PARAM_VALUES)
;         
;     ENDIF ELSE BEGIN
;               p_di=(*(*!dustem_fit).PARAM_INIT_VALUES)    
;           ENDELSE 
;               
;     st=dustem_run(p_di)      
; endif
6cde48ea   Ilyes Choubani   missing procedure
61
62
63

psi=0.
smallp=1.
5f04fa07   Ilyes Choubani   general update
64

6cde48ea   Ilyes Choubani   missing procedure
65
66
67
IF keyword_set(key) THEN BEGIN 
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
5f04fa07   Ilyes Choubani   general update
68
  IF count1 NE 0 THEN smallp=val[ind1[0]] ; setting smallp from pd - this is another polarization fraction (constant) that is applied to the total dust emission
68598bce   Ilyes Choubani   reducing number o...
69
  IF count2 NE 0 THEN psi=val[ind2[0]] & !dustem_psi = psi ; setting psi from pd.  !dustem_psi here helps for the plotting.   
6cde48ea   Ilyes Choubani   missing procedure
70
71
ENDIF

6cde48ea   Ilyes Choubani   missing procedure
72
73
74
fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7
P=((st.polsed).em_tot)*fact
I=((st.sed).em_tot)*fact
5f04fa07   Ilyes Choubani   general update
75
    
6cde48ea   Ilyes Choubani   missing procedure
76
77
78
79
80
81
Nwaves=(size(I))[1]

frac=P/I*smallp
tes=where(finite(frac) eq 0)
frac(tes)=0.

5f04fa07   Ilyes Choubani   general update
82
83
84
;psi_em = replicate(psi,Nwaves)

polar_ippsi2iqu,I,Q,U,frac,replicate(psi,Nwaves);psi_em  
6cde48ea   Ilyes Choubani   missing procedure
85

5f04fa07   Ilyes Choubani   general update
86
out=fltarr(Nwaves,5) ; modified this. This is the only plugin that has this number of outputs.
6cde48ea   Ilyes Choubani   missing procedure
87

5f04fa07   Ilyes Choubani   general update
88
degtorad = !pi/180
6cde48ea   Ilyes Choubani   missing procedure
89
90
91
92

out[*,0]=I
out[*,1]=Q
out[*,2]=U
5f04fa07   Ilyes Choubani   general update
93
94
out[*,3]=frac
out[*,4]=0.5*atan(U,Q)/degtorad
6cde48ea   Ilyes Choubani   missing procedure
95

5f04fa07   Ilyes Choubani   general update
96
the_scope:
68598bce   Ilyes Choubani   reducing number o...
97
scope='REPLACE_POLSED'
6cde48ea   Ilyes Choubani   missing procedure
98

5f04fa07   Ilyes Choubani   general update
99
100
101
the_paramtag:
paramtag=['p','Psi (deg)']

6cde48ea   Ilyes Choubani   missing procedure
102
103
104
105
return, out

the_end:

6cde48ea   Ilyes Choubani   missing procedure
106
end