Blame view

src/idl/dustem_write_isrf_lv.pro 4.23 KB
389a2b1d   Jean-Philippe Bernard   improved
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
PRO dustem_write_isrf_lv,file,st,help=help

;+
; NAME:
;    dustem_write_isrf_lv
; PURPOSE:
;    Writes file ISRF.DAT used by DustemWrapper
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    dustem_write_isrf_lv,file,st[,/help]
; INPUTS:
;    file : file name 
;    st   : input ISRF structure
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
4750086c   Ilyes Choubani   nouvelle philosph...
23
; COMMON BLOCKS: 
389a2b1d   Jean-Philippe Bernard   improved
24
25
26
27
28
29
30
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
; PROCEDURE:
4750086c   Ilyes Choubani   nouvelle philosph...
31
;    a Stellar ISRF is added based on the content of (*(*!dustem_plugin).stellar_population)
389a2b1d   Jean-Philippe Bernard   improved
32
33
34
;-

IF keyword_set(help) THEN BEGIN
4750086c   Ilyes Choubani   nouvelle philosph...
35
  doc_library,'dustem_write_isrf_lv'
389a2b1d   Jean-Philippe Bernard   improved
36
37
38
  goto,the_end
ENDIF

427f1205   Jean-Michel Glorian   version 4.2 merged
39

4750086c   Ilyes Choubani   nouvelle philosph...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
IF tag_exist((*!dustem_scope),'STELLAR_POPULATION') && ISA(((*!dustem_plugin).stellar_population)) THEN BEGIN
    c2a = 3e18 ;speed of light in ansgtroms/s (because of the Astron's PLANCK function)
    pc2cm = 3.086e18 ;cm (cgs)
    wave_angstrom = st.lambisrf*1.e4 ;mic to Angstrom (Astron Planck's function uses wavelengths in Angstroms)

    stellar_component=fltarr(n_elements(st)) ; array of zeros to contain the new ISRF values. 
     
    Ncomments = n_elements(((*(*!dustem_plugin).stellar_population).popid))*3+4
    c = strarr(Ncomments)
    
    
    ;First and last lines of the new composite ISRF.DAT file
    c(0)='# DUSTEM: exciting radiation field featuring'
    c(1)='# Mathis ISRF'
    c(Ncomments-2)='# Nbr of points'
    c(Ncomments-1)='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)'

    FOR i=0L,n_elements(((*(*!dustem_plugin).stellar_population).popid))-1 DO BEGIN ; Looping over all the stellar populations
        
        ;The initial procedure had omega multiplied by a !pi factor. Its presence in the Planck (Astron) procedure makes for a good reason to discuss this with J.P.  
        
        omega =  (((*(*!dustem_plugin).stellar_population).radius)[i]/(((*(*!dustem_plugin).stellar_population).distance)[i]*pc2cm))^2 ; Dilution factor of a stellar population
            
        Inu = planck(wave_angstrom,((*(*!dustem_plugin).stellar_population).temperature)[i])/(4.*!pi)*(wave_angstrom)^2/c2a ; ergs/cm2/s/Hz/sr
        
        ;========================================================NOTA BENE==================================================
        ;Deving the amplitudes of the stellar populations by G0 as the composite ISRF is multiplied by the latter as a whole
        ;===================================================================================================================
        
        stellar_component=stellar_component+((*(*!dustem_plugin).stellar_population).amplitude)[i]*((*(*!dustem_plugin).stellar_population).nstars)[i]*omega*Inu;/((*!dustem_params).gas.G0)
        
        ;Rest of the lines of the new composite ISRF.DAT file
        c(3*i+2) = '#'+((*(*!dustem_plugin).stellar_population).popid)[i]   
        c(3*i+3) = '# Blackbody with     T='+string(((*(*!dustem_plugin).stellar_population).temperature)[i])  
        c(3*i+4) = '# dilution factor wdil='+string(omega)
            
    ENDFOR
    
    print,'stellar_component is:'
    
    print, stellar_component
    
    print, 'isrf is:'
    print, st.isrf

    
    st.isrf=st.isrf+stellar_component/((*!dustem_params).G0)
    openw,unit,file,/get_lun
        
    FOR i=0,Ncomments-1 DO BEGIN
        printf,unit,c(i)
    ENDFOR

    n_waves=n_elements(st)
    printf,unit,n_waves

    FOR i=0L,n_waves-1 DO BEGIN
        printf,unit,st(i).lambisrf,st(i).isrf
    ENDFOR

    close,unit
    free_lun,unit
    
    
ENDIF ELSE BEGIN

    Ncomments=6
    c=strarr(Ncomments)
    
    ;First lines of the ISRF.DAT file
    c(0)='# DUSTEM: exciting radiation field featuring'
    c(1)='# Mathis ISRF'
    c(2)='# Blackbody with     T=   0.0000E+00'
    c(3)='# dilution factor wdil=   1.0000E+00'
    c(4)='# Nbr of points'
    c(5)='# wave (microns), 4*pi*Inu (erg/cm2/s/Hz)'

    openw,unit,file,/get_lun
427f1205   Jean-Michel Glorian   version 4.2 merged
118

4750086c   Ilyes Choubani   nouvelle philosph...
119
120
121
    FOR i=0,Ncomments-1 DO BEGIN
        printf,unit,c(i)
    ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
122

4750086c   Ilyes Choubani   nouvelle philosph...
123
124
    n_waves=n_elements(st)
    printf,unit,n_waves
427f1205   Jean-Michel Glorian   version 4.2 merged
125

4750086c   Ilyes Choubani   nouvelle philosph...
126
127
128
    FOR i=0L,n_waves-1 DO BEGIN
        printf,unit,st(i).lambisrf,st(i).isrf
    ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
129

4750086c   Ilyes Choubani   nouvelle philosph...
130
131
    close,unit
    free_lun,unit
427f1205   Jean-Michel Glorian   version 4.2 merged
132

4750086c   Ilyes Choubani   nouvelle philosph...
133
    the_end:
427f1205   Jean-Michel Glorian   version 4.2 merged
134

427f1205   Jean-Michel Glorian   version 4.2 merged
135

4750086c   Ilyes Choubani   nouvelle philosph...
136
ENDELSE
389a2b1d   Jean-Philippe Bernard   improved
137

427f1205   Jean-Michel Glorian   version 4.2 merged
138
139

END