Blame view

src/idl/dustem_plugin_modify_dust_pol.pro 2.82 KB
eab2e158   Jean-Philippe Bernard   did some (sometim...
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

;+
; NAME:
;    dustem_plugin_modify_dust_pol
; PURPOSE:
eab2e158   Jean-Philippe Bernard   did some (sometim...
7
;    modifies stokes Q,U values for dust polarization in st according to the given keywords and values
6cde48ea   Ilyes Choubani   missing procedure
8
9
10
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
eab2e158   Jean-Philippe Bernard   did some (sometim...
11
;    a=dustem_plugin_modify_dust_pol(st,[key=][val=][,scope=][,paramtag=][,/help])
6cde48ea   Ilyes Choubani   missing procedure
12
; INPUTS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
13
;    st = dustem structure
6cde48ea   Ilyes Choubani   missing procedure
14
; OPTIONAL INPUT PARAMETERS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
15
16
;    key  = input parameter numbers (first = polarization fraction in %, default=1.%, second=polarization angle, default=0.)
;    val  = input parameter values
6cde48ea   Ilyes Choubani   missing procedure
17
18
19
; OUTPUTS:
;    out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
; OPTIONAL OUTPUT PARAMETERS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
20
21
;    scope = if set, returns only the scope of the pluggin
;    paramtag = if set, returns only the parameter tags
6cde48ea   Ilyes Choubani   missing procedure
22
23
24
25
26
27
28
29
30
31
32
33
34
35
; 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
eab2e158   Jean-Philippe Bernard   did some (sometim...
36
  doc_library,'dustem_plugin_modify_dust_pol'
6cde48ea   Ilyes Choubani   missing procedure
37
  out=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
38
  GOTO,the_end
6cde48ea   Ilyes Choubani   missing procedure
39
40
ENDIF

5f04fa07   Ilyes Choubani   general update
41
42
IF keyword_set(scope) THEN BEGIN
    out=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
43
    GOTO, the_scope
5f04fa07   Ilyes Choubani   general update
44
45
46
47
ENDIF 

IF keyword_set(paramtag) THEN BEGIN
    out=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
48
    GOTO, the_paramtag
5f04fa07   Ilyes Choubani   general update
49
50
ENDIF 

eab2e158   Jean-Philippe Bernard   did some (sometim...
51
52
;below are the default values for the plugin parameters
smallp=1.     ;This is 1% fixed polarization
6cde48ea   Ilyes Choubani   missing procedure
53
psi=0.
5f04fa07   Ilyes Choubani   general update
54

6cde48ea   Ilyes Choubani   missing procedure
55
56
57
IF keyword_set(key) THEN BEGIN 
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
5f04fa07   Ilyes Choubani   general update
58
  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...
59
  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
60
61
ENDIF

6cde48ea   Ilyes Choubani   missing procedure
62
fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7
eab2e158   Jean-Philippe Bernard   did some (sometim...
63
64
P=((st.polsed).em_tot)*fact   ; This is the polarized emission P
I=((st.sed).em_tot)*fact      ; This is the total intensity emission I
5f04fa07   Ilyes Choubani   general update
65
    
6cde48ea   Ilyes Choubani   missing procedure
66
67
Nwaves=(size(I))[1]

eab2e158   Jean-Philippe Bernard   did some (sometim...
68
69
70
71
72
73
74
75
76
77
78
frac_model=P/I    ;This is the polarization fraction in the model
frac_used=frac_model
IF keyword_set(key) THEN BEGIN
  IF count1 NE 0 THEN BEGIN
    frac_used[*]=smallp/100.
  ENDIF
ENDIF

;frac=P/I*smallp
tes=where(finite(frac_used) eq 0,count)
IF count NE 0 THEN frac_used[tes]=0.
6cde48ea   Ilyes Choubani   missing procedure
79

eab2e158   Jean-Philippe Bernard   did some (sometim...
80
psi_used = replicate(psi,Nwaves)
5f04fa07   Ilyes Choubani   general update
81

eab2e158   Jean-Philippe Bernard   did some (sometim...
82
polar_ippsi2iqu,I,Q,U,frac_used,psi_used
6cde48ea   Ilyes Choubani   missing procedure
83

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

eab2e158   Jean-Philippe Bernard   did some (sometim...
86
;degtorad = !pi/180
6cde48ea   Ilyes Choubani   missing procedure
87
88
89
90

out[*,0]=I
out[*,1]=Q
out[*,2]=U
eab2e158   Jean-Philippe Bernard   did some (sometim...
91
92
93
out[*,3]=frac_used
;out[*,4]=0.5*atan(U,Q)/degtorad
out[*,4]=psi_used
6cde48ea   Ilyes Choubani   missing procedure
94

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

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

eab2e158   Jean-Philippe Bernard   did some (sometim...
101
RETURN, out
6cde48ea   Ilyes Choubani   missing procedure
102
103
104

the_end:

eab2e158   Jean-Philippe Bernard   did some (sometim...
105
END
6cde48ea   Ilyes Choubani   missing procedure