Blame view

src/idl/dustem_plugin_stellar_population.pro 4.81 KB
a90f313b   Jean-Philippe Bernard   fixed with the ri...
1
FUNCTION dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramtag=paramtag,help=help,test=test
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
;-
dcf48925   Ilyes Choubani   added spectral class
33
;- HISTORY: ADDED STELLAR LUMINOSITY CLASSES
01612ee4   Ilyes Choubani   General update: I...
34

2bbb56cf   Jean-Philippe Bernard   modified to fix b...
35
36
IF keyword_set(test) THEN stop

4750086c   Ilyes Choubani   nouvelle philosph...
37
IF keyword_set(help) THEN BEGIN
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
38
  doc_library,'dustem_plugin_stellar_population'
4750086c   Ilyes Choubani   nouvelle philosph...
39
40
41
  goto,the_end
ENDIF

a90f313b   Jean-Philippe Bernard   fixed with the ri...
42
43
44
45
46
;print,keyword_set(scope)
;print,keyword_set(paramtag)
;print,keyword_set(key),keyword_set(val)
;stop

a7446da7   Jean-Philippe Bernard   completely re-wri...
47
48
IF keyword_set(scope) THEN BEGIN
  message,'Scope keyword was set',/continue
a90f313b   Jean-Philippe Bernard   fixed with the ri...
49
50
51
52
53
54
55
  ;scope='STELLAR_POPULATION'
  ;scope='REPLACE_ISRF'
  scope='ADD_ISRF'
  stellar_isrf=0.
  goto,the_end
  ;stop
ENDIF
4750086c   Ilyes Choubani   nouvelle philosph...
56

a90f313b   Jean-Philippe Bernard   fixed with the ri...
57
58
59
60
61
62
63
;==== 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...
64
ENDIF
a90f313b   Jean-Philippe Bernard   fixed with the ri...
65
66
67
68

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...
69
stellar_isrf=0.
a90f313b   Jean-Philippe Bernard   fixed with the ri...
70
spectral_types=!dustem_plugin_stellar_population.spt
a7446da7   Jean-Philippe Bernard   completely re-wri...
71

a90f313b   Jean-Philippe Bernard   fixed with the ri...
72
73
74
75
76
77
78
79
80
81
82
83
84
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
    ;stop
    stellar_isrf=0.
    goto, the_end
01612ee4   Ilyes Choubani   General update: I...
85
ENDIF
a90f313b   Jean-Philippe Bernard   fixed with the ri...
86
stellar_isrf=0.
955f09f4   Ilyes Choubani   Retrieving data f...
87

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

4750086c   Ilyes Choubani   nouvelle philosph...
90
;===========Constants (in cgs)========== (except for the stellar population distance (in pc))
a7446da7   Jean-Philippe Bernard   completely re-wri...
91
92
93
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...
94

4750086c   Ilyes Choubani   nouvelle philosph...
95
;================NOTA BENE========================================================================== 
f9089dc2   Ilyes Choubani   implementing the ...
96
97
98
99
100
101
102
103
104
;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.
4750086c   Ilyes Choubani   nouvelle philosph...
105
;This will help ease and shorten the fitting procedure
f9089dc2   Ilyes Choubani   implementing the ...
106
;If the user wants to use them without having to read the entirety of this plugin please contact the DustEmWrap team. 
4750086c   Ilyes Choubani   nouvelle philosph...
107

a7446da7   Jean-Philippe Bernard   completely re-wri...
108
109
IF keyword_set(key) THEN BEGIN
    ;stop
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
110
    FOR i=0L,n_elements(key)-1 DO BEGIN
a7446da7   Jean-Philippe Bernard   completely re-wri...
111
112
        ij=index2ij([key[i]-1],[Nstars,2])
        paramvalues[ij[0,0],ij[0,1]]=val[i]
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
113
    ENDFOR
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
114
    ;stop
a7446da7   Jean-Philippe Bernard   completely re-wri...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    ;=== 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...
129
        ENDIF
4750086c   Ilyes Choubani   nouvelle philosph...
130
    ENDFOR
a7446da7   Jean-Philippe Bernard   completely re-wri...
131
132
133
134
    ;pass output into ergs/cm2/s/Hz
    fact=1./1.e20*1.e7/1.e4
    stellar_isrf=stellar_isrf*fact  ;ergs/cm2/s/Hz
ENDIF
a7446da7   Jean-Philippe Bernard   completely re-wri...
135

a7446da7   Jean-Philippe Bernard   completely re-wri...
136
137
;stop

a90f313b   Jean-Philippe Bernard   fixed with the ri...
138
139
140
the_end:

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