Blame view

src/idl/dustem_write_isrf_lv.pro 2.13 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    a Stellar ISRF is added based on the content of !dustem_isrf_star_add
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by J.P. Bernard
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@irap.omp.eu) in case of problems.
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_fit_sed_readme'
  goto,the_end
ENDIF

;=== add stellar component if needed.
;stop
ind=where(!dustem_isrf_star_add.amplitude NE 0.,Nstars)
IF Nstars NE 0 THEN BEGIN
	cmic=3.e14
	pc2m=3.08e16     ;1pc=3.08e16 km
	rsun2m=6.957e8   ;Rsun=6.957e5 km
	wave_angstroem=st.LAMBISRF*1.e4      ;mic to Angstroem 
	stellar_component=fltarr(n_elements(st))
	FOR i=0L,Nstars-1 DO BEGIN
		omega=!pi*((!dustem_isrf_star_add[i].radius*Rsun2m)/(!dustem_isrf_star_add[i].distance*pc2m))^2
		Ilambda=planck(wave_angstroem,!dustem_isrf_star_add[i].temperature)/(4.*!pi) ;ergs/cm2/s/A/sr
		Inu=Ilambda*st.LAMBISRF^2/cmic  ;ergs/cm2/s/Hz/sr
		stellar_component=stellar_component+!dustem_isrf_star_add[i].amplitude*omega*Inu ;
	ENDFOR
	st.isrf=st.isrf+stellar_component
ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
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

Ncomments=6
c=strarr(Ncomments)

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

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

389a2b1d   Jean-Philippe Bernard   improved
88
89
the_end:

427f1205   Jean-Michel Glorian   version 4.2 merged
90
91
92
;stop

END