Blame view

src/idl/dustem_plugin_modify_dust_pol.pro 3.21 KB
e6ef3674   Ilyes Choubani   removed st keywor...
1
FUNCTION dustem_plugin_modify_dust_pol, key=key, val=val, scope=scope, paramtag=paramtag, help=help
6cde48ea   Ilyes Choubani   missing procedure
2
3
4
5

;+
; NAME:
;    dustem_plugin_modify_dust_pol
6a523633   Annie Hughes   unknown
6
;  
6cde48ea   Ilyes Choubani   missing procedure
7
; PURPOSE:
6a523633   Annie Hughes   unknown
8
9
;    modifies Emission Stokes Q,U values for dust polarization in st according to the given keywords and values
;
6cde48ea   Ilyes Choubani   missing procedure
10
; CATEGORY:
6a523633   Annie Hughes   unknown
11
12
;    DustEMWrap, Plugin, Mid-level, Distributed
;
6cde48ea   Ilyes Choubani   missing procedure
13
; CALLING SEQUENCE:
2fe314fa   Annie Hughes   cosmetic change t...
14
;    a=dustem_plugin_modify_dust_pol(st,[key=][val=][,scope=][,paramtag=][,paramdefault=][,/help])
6a523633   Annie Hughes   unknown
15
;
6cde48ea   Ilyes Choubani   missing procedure
16
; INPUTS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
17
;    st = dustem structure
6a523633   Annie Hughes   unknown
18
;
6cde48ea   Ilyes Choubani   missing procedure
19
; OPTIONAL INPUT PARAMETERS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
20
21
;    key  = input parameter numbers (first = polarization fraction in %, default=1.%, second=polarization angle, default=0.)
;    val  = input parameter values
6a523633   Annie Hughes   unknown
22
;
6cde48ea   Ilyes Choubani   missing procedure
23
24
; OUTPUTS:
;    out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
6a523633   Annie Hughes   unknown
25
;
6cde48ea   Ilyes Choubani   missing procedure
26
; OPTIONAL OUTPUT PARAMETERS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
27
28
;    scope = if set, returns only the scope of the pluggin
;    paramtag = if set, returns only the parameter tags
6a523633   Annie Hughes   unknown
29
;
6cde48ea   Ilyes Choubani   missing procedure
30
31
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
6a523633   Annie Hughes   unknown
32
;
6cde48ea   Ilyes Choubani   missing procedure
33
34
; COMMON BLOCKS:
;    None
6a523633   Annie Hughes   unknown
35
;
6cde48ea   Ilyes Choubani   missing procedure
36
37
; SIDE EFFECTS:
;    None
6a523633   Annie Hughes   unknown
38
;
6cde48ea   Ilyes Choubani   missing procedure
39
40
41
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
6a523633   Annie Hughes   unknown
42
43
44
45
46
;
; MODIFICATION HISTORY:
;    Written by IC 2022
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
6cde48ea   Ilyes Choubani   missing procedure
47
48
49
;-

IF keyword_set(help) THEN BEGIN
eab2e158   Jean-Philippe Bernard   did some (sometim...
50
  doc_library,'dustem_plugin_modify_dust_pol'
6cde48ea   Ilyes Choubani   missing procedure
51
  out=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
52
  GOTO,the_end
6cde48ea   Ilyes Choubani   missing procedure
53
ENDIF
1fcff162   Ilyes Choubani   removed stop from...
54
       
5f04fa07   Ilyes Choubani   general update
55
IF keyword_set(scope) THEN BEGIN
91e991b5   Ilyes Choubani   Applying correcti...
56
    out=0
01612ee4   Ilyes Choubani   General update: I...
57
    GOTO, the_end
5f04fa07   Ilyes Choubani   general update
58
59
60
ENDIF 

IF keyword_set(paramtag) THEN BEGIN
5f04fa07   Ilyes Choubani   general update
61
    out=0.
01612ee4   Ilyes Choubani   General update: I...
62
    GOTO, the_end
5f04fa07   Ilyes Choubani   general update
63
64
ENDIF 

01612ee4   Ilyes Choubani   General update: I...
65
;Retrieving this sytem variable  (dustem output)  
91e991b5   Ilyes Choubani   Applying correcti...
66
67
68
69
if ~isa(!dustem_current) then begin
    out =0 
    goto, the_end 
ENDIF else st=(*!dustem_current)
01612ee4   Ilyes Choubani   General update: I...
70

eab2e158   Jean-Philippe Bernard   did some (sometim...
71
;below are the default values for the plugin parameters
2fe314fa   Annie Hughes   cosmetic change t...
72
smallp_fact=1.     ;This is the default dust polarization factor
d571675e   Jean-Philippe Bernard   went back to a mu...
73
psi=0.             ;This is the default polarization angle
5f04fa07   Ilyes Choubani   general update
74

6cde48ea   Ilyes Choubani   missing procedure
75
76
77
IF keyword_set(key) THEN BEGIN 
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
d571675e   Jean-Philippe Bernard   went back to a mu...
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
68598bce   Ilyes Choubani   reducing number o...
79
  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
80
81
ENDIF

6cde48ea   Ilyes Choubani   missing procedure
82
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...
83
84
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
85
    
6cde48ea   Ilyes Choubani   missing procedure
86
87
Nwaves=(size(I))[1]

19961cc2   Ilyes Choubani   fixing NaN values...
88
89
90
;0/0 division in frac
;since we divide by I we only need to avoid its null indices 

6a523633   Annie Hughes   unknown
91
frac_model=P*0.
19961cc2   Ilyes Choubani   fixing NaN values...
92
indI = where(I ne 0, countI)
6a523633   Annie Hughes   unknown
93
if countI ne 0 then frac_model[indI] = P[indI]/I[indI] ;This is the polarization fraction in the model
19961cc2   Ilyes Choubani   fixing NaN values...
94

d571675e   Jean-Philippe Bernard   went back to a mu...
95
frac_used=frac_model*smallp_fact
6cde48ea   Ilyes Choubani   missing procedure
96

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

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

19961cc2   Ilyes Choubani   fixing NaN values...
101

6ddd46ab   Ilyes Choubani   removed extra dim...
102
out=fltarr(Nwaves,3) ; modified this. This is the only plugin that has this number of outputs.
6cde48ea   Ilyes Choubani   missing procedure
103

eab2e158   Jean-Philippe Bernard   did some (sometim...
104
;degtorad = !pi/180
6cde48ea   Ilyes Choubani   missing procedure
105
106
107
108

out[*,0]=I
out[*,1]=Q
out[*,2]=U
6ddd46ab   Ilyes Choubani   removed extra dim...
109
110
111
; out[*,3]=frac_used
; ;out[*,4]=0.5*atan(U,Q)/degtorad
; out[*,4]=psi_used
6cde48ea   Ilyes Choubani   missing procedure
112

eab2e158   Jean-Philippe Bernard   did some (sometim...
113
RETURN, out
6cde48ea   Ilyes Choubani   missing procedure
114
115

the_end:
91e991b5   Ilyes Choubani   Applying correcti...
116
scope='REPLACE_POLSED'
2fe314fa   Annie Hughes   cosmetic change t...
117
paramtag=['p',textoidl('\psi')+' [deg]']
91e991b5   Ilyes Choubani   Applying correcti...
118

6cde48ea   Ilyes Choubani   missing procedure
119

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