Blame view

src/idl/dustem_plugin_stellar_population.pro 4.71 KB
e3ddb2e0   Jean-Philippe Bernard   improved
1
FUNCTION dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramtag=paramtag,help=help
4750086c   Ilyes Choubani   nouvelle philosph...
2
3
4

;+
; NAME:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
5
;    dustem_plugin_stellar_population
4750086c   Ilyes Choubani   nouvelle philosph...
6
; PURPOSE:
bffa7018   Ilyes Choubani   update
7
;    replaces the default DUSTEM ISRF with a composite stellar spectrum
4750086c   Ilyes Choubani   nouvelle philosph...
8
9
10
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
bffa7018   Ilyes Choubani   update
11
;    dustem_plugin_stellar_population(key=key,val=val)
4750086c   Ilyes Choubani   nouvelle philosph...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;    val  = input parameter value
; OUTPUTS:
;    None
; 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
;-
01612ee4   Ilyes Choubani   General update: I...
33

e3ddb2e0   Jean-Philippe Bernard   improved
34
35
36
37
38
39
40
41
42
43
44
45
;================NOTA BENE========================================================================== 
;DATA IS NOW RETRIEVED FROM THIS TEXT FILE: "A Modern Mean Dwarf Stellar Color and Effective Temperature Sequence"  
;NB: intermediate spectral classes '.5' are not taken into account - this will probably have to change
;NB: Also contact we need to contact the reasercher who wrote the text file because he said so in it.
;Other luminosity classes Should be included (only MS so far). 
;BB approximation is a first degree 'bad' approximation because of the lack of radiative transfer especially at the 
;photosphere of stars. 
;REMARKS: BECAUSE WE STILL HAVEN'T SET THE DEFAULT VALUE FOR THE MAJORIY OF THE STELLAR POULATIONS,THE CORRESPONDING LINES ARE COMMENTED INSTEAD OF SETTING ARBITRARY VALUES. 
;CONSIDERED STARS: SPEC_TYPE(N=5) = OBAFG, LUM_CLASS(N=10) = IA+,IA,IAB,IB,II,III,IV,V,VI,VII 
;KM spectral types are not included because their UV part was not that important to excite the dust.
;This will help ease and shorten the fitting procedure
;If the user wants to use them without having to read the entirety of this plugin please contact the DustEmWrap team. 
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
46

4750086c   Ilyes Choubani   nouvelle philosph...
47
IF keyword_set(help) THEN BEGIN
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
48
  doc_library,'dustem_plugin_stellar_population'
4750086c   Ilyes Choubani   nouvelle philosph...
49
50
51
  goto,the_end
ENDIF

a90f313b   Jean-Philippe Bernard   fixed with the ri...
52
53
54
55
56
;print,keyword_set(scope)
;print,keyword_set(paramtag)
;print,keyword_set(key),keyword_set(val)
;stop

a7446da7   Jean-Philippe Bernard   completely re-wri...
57
58
IF keyword_set(scope) THEN BEGIN
  message,'Scope keyword was set',/continue
a90f313b   Jean-Philippe Bernard   fixed with the ri...
59
60
61
  scope='ADD_ISRF'
  stellar_isrf=0.
  goto,the_end
a90f313b   Jean-Philippe Bernard   fixed with the ri...
62
ENDIF
4750086c   Ilyes Choubani   nouvelle philosph...
63

a90f313b   Jean-Philippe Bernard   fixed with the ri...
64
65
66
67
68
69
70
;==== read stellar population parameters if not already in memory
defsysv,'!dustem_plugin_stellar_population',exist=exist
IF exist EQ 0 THEN BEGIN
    message,'Initializing stellar population parameters',/continue
    file = !dustem_wrap_soft_dir+'Data/STELLARPOPS/EEM_dwarf_UBVIJHK_colors_Teff.xcat'
    st=read_xcat(file,/silent)
    defsysv,'!dustem_plugin_stellar_population',st
a7446da7   Jean-Philippe Bernard   completely re-wri...
71
ENDIF
a90f313b   Jean-Philippe Bernard   fixed with the ri...
72
73
74
75

Nstars=n_elements(!dustem_plugin_stellar_population)
paramvalues=fltarr(Nstars,2)    ;first parameter is distance to the stars in pc, second is the number of such stars
Nparam=Nstars*2
a7446da7   Jean-Philippe Bernard   completely re-wri...
76
stellar_isrf=0.
a90f313b   Jean-Philippe Bernard   fixed with the ri...
77
spectral_types=!dustem_plugin_stellar_population.spt
a7446da7   Jean-Philippe Bernard   completely re-wri...
78

a90f313b   Jean-Philippe Bernard   fixed with the ri...
79
80
81
82
83
84
85
86
87
88
IF keyword_set(paramtag) THEN BEGIN
    message,'paramtag keyword was set',/continue
    paramtag=strarr(Nparam)
    ii=0L
    FOR i=0L,Nparam-1 DO BEGIN
            ij=index2ij([i],[Nstars,2])
            IF ij[0,1] EQ 0 THEN cc='dist to ' ELSE cc='N of '
            paramtag[ii]=cc+spectral_types[ij[0,0]]
            ii=ii+1
    ENDFOR
a90f313b   Jean-Philippe Bernard   fixed with the ri...
89
90
    stellar_isrf=0.
    goto, the_end
01612ee4   Ilyes Choubani   General update: I...
91
ENDIF
a90f313b   Jean-Philippe Bernard   fixed with the ri...
92
stellar_isrf=0.
955f09f4   Ilyes Choubani   Retrieving data f...
93

a7446da7   Jean-Philippe Bernard   completely re-wri...
94
;stop
4750086c   Ilyes Choubani   nouvelle philosph...
95

4750086c   Ilyes Choubani   nouvelle philosph...
96
;===========Constants (in cgs)========== (except for the stellar population distance (in pc))
a7446da7   Jean-Philippe Bernard   completely re-wri...
97
98
99
rsun2cm = 6.957e10   ;Rsun in cm
c2a = 3e18 ;speed of light in ansgtroms/s (because of the Astron's PLANCK function)
pc2cm = 3.086e18 ;cm (cgs)
4750086c   Ilyes Choubani   nouvelle philosph...
100

a7446da7   Jean-Philippe Bernard   completely re-wri...
101
102
IF keyword_set(key) THEN BEGIN
    ;stop
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
103
    FOR i=0L,n_elements(key)-1 DO BEGIN
a7446da7   Jean-Philippe Bernard   completely re-wri...
104
105
        ij=index2ij([key[i]-1],[Nstars,2])
        paramvalues[ij[0,0],ij[0,1]]=val[i]
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
106
    ENDFOR
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
107
    ;stop
a7446da7   Jean-Philippe Bernard   completely re-wri...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
    ;=== compute ISRF
    isrf_st=((*!dustem_params).isrf)
    stellar_isrf=dblarr(n_elements(isrf_st)) ; array of zeros to contain the new ISRF values. 
    FOR i=0L,Nstars-1 DO BEGIN
        IF paramvalues[i,0] NE 0. THEN BEGIN
            TEFF=!dustem_plugin_stellar_population[i].TEFF      ;in K
            Rstar=!dustem_plugin_stellar_population[i].R_Rsun   ;in solar radius
            Lstar=!dustem_plugin_stellar_population[i].logL
            dist=paramvalues[i,0]*pc2cm  ; in cm
            number_of_stars=paramvalues[i,1]
            omega=(Rstar*rsun2cm/dist)^2
            print,number_of_stars,dist,Teff,omega
            this_component=number_of_stars*omega*dustem_planck_function(Teff,isrf_st.lambisrf) ;MJy
            stellar_isrf=stellar_isrf+this_component
4750086c   Ilyes Choubani   nouvelle philosph...
122
        ENDIF
4750086c   Ilyes Choubani   nouvelle philosph...
123
    ENDFOR
a7446da7   Jean-Philippe Bernard   completely re-wri...
124
125
126
    ;pass output into ergs/cm2/s/Hz
    fact=1./1.e20*1.e7/1.e4
    stellar_isrf=stellar_isrf*fact  ;ergs/cm2/s/Hz
6baf9f1f   Jean-Philippe Bernard   fixed a few issue...
127
    stellar_isrf=stellar_isrf/(*!dustem_params).G0
a7446da7   Jean-Philippe Bernard   completely re-wri...
128
ENDIF
a7446da7   Jean-Philippe Bernard   completely re-wri...
129

a7446da7   Jean-Philippe Bernard   completely re-wri...
130
131
;stop

a90f313b   Jean-Philippe Bernard   fixed with the ri...
132
133
134
the_end:

RETURN,stellar_isrf
a7446da7   Jean-Philippe Bernard   completely re-wri...
135
END