1 | subroutine ave_stelspec(STELLAR) |
---|
2 | |
---|
3 | !================================================================== |
---|
4 | ! |
---|
5 | ! Purpose |
---|
6 | ! ------- |
---|
7 | ! Average the chosen high resolution stellar spectrum over the |
---|
8 | ! visible bands in the model. |
---|
9 | ! |
---|
10 | ! Authors |
---|
11 | ! ------- |
---|
12 | ! Robin Wordsworth (2010). |
---|
13 | ! |
---|
14 | ! Called by |
---|
15 | ! --------- |
---|
16 | ! setspv.F |
---|
17 | ! |
---|
18 | ! Calls |
---|
19 | ! ----- |
---|
20 | ! none |
---|
21 | ! |
---|
22 | !================================================================== |
---|
23 | |
---|
24 | use radinc_h, only: L_NSPECTV |
---|
25 | use radcommon_h, only: BWNV, DWNV, tstellar |
---|
26 | |
---|
27 | implicit none |
---|
28 | |
---|
29 | #include "datafile.h" |
---|
30 | #include "callkeys.h" |
---|
31 | |
---|
32 | real*8 STELLAR(L_NSPECTV) |
---|
33 | ! integer startype |
---|
34 | |
---|
35 | integer Nfine |
---|
36 | parameter(Nfine=5000) |
---|
37 | integer ifine |
---|
38 | |
---|
39 | real lam(Nfine) |
---|
40 | real stel_f(Nfine) |
---|
41 | real band |
---|
42 | real dl |
---|
43 | |
---|
44 | character(len=50) :: file_id |
---|
45 | character(len=100) :: file_path |
---|
46 | |
---|
47 | real lam_temp |
---|
48 | double precision stel_temp |
---|
49 | |
---|
50 | STELLAR(:)=0.0 |
---|
51 | |
---|
52 | ! load high resolution wavenumber data |
---|
53 | file_id='/stellar_spectra/lam.txt' |
---|
54 | file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id)) |
---|
55 | |
---|
56 | open(110,file=file_path,form='formatted') |
---|
57 | do ifine=1,Nfine |
---|
58 | read(110,*) lam(ifine) |
---|
59 | enddo |
---|
60 | close(110) |
---|
61 | |
---|
62 | dl=lam(2)-lam(1) |
---|
63 | |
---|
64 | |
---|
65 | if(stelbbody)then |
---|
66 | tstellar=stelTbb |
---|
67 | do ifine=1,Nfine |
---|
68 | lam_temp=lam(ifine) |
---|
69 | call blackl(dble(lam_temp*1e-6),dble(tstellar),stel_temp) |
---|
70 | stel_f(ifine)=stel_temp |
---|
71 | enddo |
---|
72 | else |
---|
73 | ! load high resolution stellar data |
---|
74 | if(startype.eq.1)then |
---|
75 | file_id='/stellar_spectra/sol.txt' |
---|
76 | tstellar=5800. |
---|
77 | elseif(startype.eq.2)then |
---|
78 | file_id='/stellar_spectra/gl581.txt' |
---|
79 | tstellar=3200. |
---|
80 | elseif(startype.eq.3)then |
---|
81 | file_id='/stellar_spectra/adleo.txt' |
---|
82 | tstellar=3200. |
---|
83 | elseif(startype.eq.4)then |
---|
84 | file_id='/stellar_spectra/gj644.txt' |
---|
85 | print*,'Find out tstellar before using this star!' |
---|
86 | call abort |
---|
87 | elseif(startype.eq.5)then |
---|
88 | file_id='/stellar_spectra/hd128167.txt' |
---|
89 | tstellar=6700. ! Segura et al. (2003) |
---|
90 | else |
---|
91 | print*,'Error: unknown star type chosen' |
---|
92 | call abort |
---|
93 | endif |
---|
94 | file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id)) |
---|
95 | |
---|
96 | open(111,file=file_path,form='formatted') |
---|
97 | do ifine=1,Nfine |
---|
98 | read(111,*) stel_f(ifine) |
---|
99 | enddo |
---|
100 | close(111) |
---|
101 | endif |
---|
102 | |
---|
103 | |
---|
104 | ! sum data by band |
---|
105 | band=1 |
---|
106 | do ifine = 1,Nfine |
---|
107 | |
---|
108 | if(lam(Nfine-ifine+1) .lt. real(10000.0/BWNV(band+1)))then |
---|
109 | band=band+1 |
---|
110 | endif |
---|
111 | if(band .gt. L_NSPECTV)then |
---|
112 | goto 9999 ! ok, ok, I know they're evil |
---|
113 | endif |
---|
114 | STELLAR(band)=STELLAR(band)+stel_f(Nfine-ifine+1)*dl |
---|
115 | |
---|
116 | end do |
---|
117 | |
---|
118 | 9999 continue |
---|
119 | STELLAR=STELLAR/sum(STELLAR) |
---|
120 | |
---|
121 | |
---|
122 | end subroutine ave_stelspec |
---|