Blame view

src/idl/dustem_plugin_stellar_population.pro 4.78 KB
a7446da7   Jean-Philippe Bernard   completely re-wri...
1
FUNCTION dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramtag=paramtag,help=help,test=test,initialize=initialize
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

a7446da7   Jean-Philippe Bernard   completely re-wri...
42
43
44
IF keyword_set(scope) THEN BEGIN
  message,'Scope keyword was set',/continue
  stop
01612ee4   Ilyes Choubani   General update: I...
45
ENDIF 
4750086c   Ilyes Choubani   nouvelle philosph...
46

a7446da7   Jean-Philippe Bernard   completely re-wri...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
IF keyword_set(paramtag) THEN BEGIN
    message,'paramtag keyword was set',/continue
    stop
;    out=0
;    goto, the_paramtag
ENDIF
scope='STELLAR_POPULATION'
stellar_isrf=0.

;==== read stellar population parameters if not already in memory
IF keyword_set(initialize) THEN BEGIN
    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
    ENDIF
    goto,the_end
01612ee4   Ilyes Choubani   General update: I...
66
ENDIF
955f09f4   Ilyes Choubani   Retrieving data f...
67

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

4750086c   Ilyes Choubani   nouvelle philosph...
70
;===========Constants (in cgs)========== (except for the stellar population distance (in pc))
a7446da7   Jean-Philippe Bernard   completely re-wri...
71
72
73
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...
74

4750086c   Ilyes Choubani   nouvelle philosph...
75
;================NOTA BENE========================================================================== 
f9089dc2   Ilyes Choubani   implementing the ...
76
77
78
79
80
81
82
83
84
;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...
85
;This will help ease and shorten the fitting procedure
f9089dc2   Ilyes Choubani   implementing the ...
86
;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...
87

a7446da7   Jean-Philippe Bernard   completely re-wri...
88
89
90
91
92
93
94
95
96
97
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
stellar_isrf=0.
spectral_types=!dustem_plugin_stellar_population.spt

paramtag=strarr(Nparam)
ii=0L
FOR i=0L,Nparam-1 DO BEGIN
        ij=index2ij([i],[Nstars,2])
2449233a   Jean-Philippe Bernard   now uses paramtag...
98
        IF ij[0,1] EQ 0 THEN cc='dist to ' ELSE cc='N of '
a7446da7   Jean-Philippe Bernard   completely re-wri...
99
100
101
        paramtag[ii]=cc+spectral_types[ij[0,0]]
        ii=ii+1
ENDFOR
01612ee4   Ilyes Choubani   General update: I...
102

a7446da7   Jean-Philippe Bernard   completely re-wri...
103
104
IF keyword_set(key) THEN BEGIN
    ;stop
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
105
    FOR i=0L,n_elements(key)-1 DO BEGIN
a7446da7   Jean-Philippe Bernard   completely re-wri...
106
107
        ij=index2ij([key[i]-1],[Nstars,2])
        paramvalues[ij[0,0],ij[0,1]]=val[i]
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
108
    ENDFOR
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
109
    ;stop
a7446da7   Jean-Philippe Bernard   completely re-wri...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    ;=== 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...
124
        ENDIF
4750086c   Ilyes Choubani   nouvelle philosph...
125
    ENDFOR
a7446da7   Jean-Philippe Bernard   completely re-wri...
126
127
128
129
    ;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
f9089dc2   Ilyes Choubani   implementing the ...
130
  
a7446da7   Jean-Philippe Bernard   completely re-wri...
131
132
133
;the_scope:
;scope='STELLAR_POPULATION'

f9089dc2   Ilyes Choubani   implementing the ...
134
the_end:
a7446da7   Jean-Philippe Bernard   completely re-wri...
135
136
137
138
139
;print,minmax(stellar_isrf)
;stop

RETURN, stellar_isrf
END