Skip to content

Commit 02b0ce6

Browse files
author
Carlos Brandt
committed
Add fortran code to convert final table to SED builder
1 parent 344dbe0 commit 02b0ce6

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

bin/conv2sedfile.f

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
PROGRAM conv2sedfile
2+
c
3+
c Reads a swift_deepsky flux output file and produces a SED input file
4+
c
5+
c
6+
IMPLICIT none
7+
INTEGER*4 i,rah,ram,dd,dm,im
8+
INTEGER*4 ier, lu_in, lu_out, lenact, in,length
9+
REAL*4 mjd,freq1kev, freq, err, one, rasec, dsec, flux, test
10+
REAL*8 ra, dec
11+
CHARACTER*1 sign
12+
CHARACTER*80 input_file,output_file
13+
CHARACTER*300 string
14+
LOGICAL there,ok
15+
c
16+
ok = .TRUE.
17+
CALL rdforn(string,length)
18+
IF ( length.NE.0 ) THEN
19+
CALL rmvlbk(string)
20+
input_file= string(1:lenact(string))
21+
ELSE
22+
WRITE (*,'('' Enter input file '',$)')
23+
READ (*,'(a)') input_file
24+
ENDIF
25+
lu_in = 10
26+
lu_out = 11
27+
INQUIRE (FILE=input_file,EXIST=there)
28+
IF (.NOT.there) THEN
29+
write (*,'('' file '',a,'' not found '')')
30+
& input_file(1:lenact(input_file))
31+
STOP
32+
ENDIF
33+
open(lu_in,file=input_file,status='old',iostat=ier)
34+
in = index (input_file,'.')
35+
output_file=input_file(1:in-1)//'4SED.txt'
36+
open(lu_out,file=output_file,status='unknown',iostat=ier)
37+
IF (ier.ne.0) THEN
38+
write (*,*) ' Error ',ier,' opening file ', input_file
39+
ENDIF
40+
string=''
41+
READ(lu_in,'(a)',end=99) string
42+
one = 1.0
43+
freq1kev = 2.418e17
44+
mjd = 55000.0
45+
sign=''
46+
DO WHILE(ok)
47+
READ(lu_in,'(a)',end=99) string
48+
in = index(string(1:lenact(string)),';')
49+
READ(string(1:in-1),'(i2,x,i2,x,f6.3)') rah,ram,rasec
50+
im = index(string(in+1:lenact(string)),';')+in
51+
READ(string(in+2:im-1),'(i2,x,i2,x,f6.3)') dd,dm,dsec
52+
sign(1:1) = string((in+1):(in+1))
53+
call chra(ra,rah,ram,rasec,0)
54+
call chdec(dec,dd,dm,dsec,0)
55+
IF (sign(1:1) == '-') dec=-dec
56+
DO i = 1,4
57+
in = im
58+
im = index(string(in+1:lenact(string)),';')+in
59+
ENDDO
60+
READ(string(in+1:im-1),*) flux
61+
in = im
62+
im = index(string(in+1:lenact(string)),';')+in
63+
READ(string(in+1:im-1),*) err
64+
c print *,' flux err ', flux, err
65+
freq = freq1kev*5.0
66+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
67+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | | '')')
68+
& ra,dec,freq,one,flux,err,mjd,mjd
69+
c 0.5 KeV flux
70+
in = im
71+
im = index(string(in+1:lenact(string)),';')+in
72+
READ(string(in+1:im-1),*) flux
73+
in = im
74+
im = index(string(in+1:lenact(string)),';')+in
75+
READ(string(in+1:im-1),*) err
76+
c print *,' flux err ', flux, err
77+
freq = freq1kev*0.5
78+
in = im
79+
im = index(string(in+1:lenact(string)),';')+in
80+
READ(string(in+1:im-1),*) test ! test if upper limit
81+
IF (test < 0. ) THEN
82+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
83+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | | '')')
84+
& ra,dec,freq,one,flux,err,mjd,mjd
85+
ELSE
86+
flux = test
87+
err = 0.
88+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
89+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | UL | '')')
90+
& ra,dec,freq,one,flux,err,mjd,mjd
91+
ENDIF
92+
c 1.5 KeV flux
93+
in = im
94+
im = index(string(in+1:lenact(string)),';')+in
95+
READ(string(in+1:im-1),*) flux
96+
in = im
97+
im = index(string(in+1:lenact(string)),';')+in
98+
READ(string(in+1:im-1),*) err
99+
c print *,' flux err ', flux, err
100+
freq = freq1kev*1.5
101+
in = im
102+
im = index(string(in+1:lenact(string)),';')+in
103+
READ(string(in+1:im-1),*) test ! test if upper limit
104+
IF (test < 0. ) THEN
105+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
106+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | | '')')
107+
& ra,dec,freq,one,flux,err,mjd,mjd
108+
ELSE
109+
flux = test
110+
err = 0.
111+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
112+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | UL | '')')
113+
& ra,dec,freq,one,flux,err,mjd,mjd
114+
ENDIF
115+
c 4.5 KeV flux
116+
in = im
117+
im = index(string(in+1:lenact(string)),';')+in
118+
READ(string(in+1:im-1),*) flux
119+
in = im
120+
im = index(string(in+1:lenact(string)),';')+in
121+
READ(string(in+1:im-1),*) err
122+
c print *,' 4.5kev flux err ', flux, err
123+
freq = freq1kev*4.5
124+
in = im
125+
im = index(string(in+1:lenact(string)),';')+in
126+
c print *,' in im ', in, im
127+
READ(string(in+1:lenact(string)),*) test ! test if upper limit
128+
IF (test < 0. ) THEN
129+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
130+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | | '')')
131+
& ra,dec,freq,one,flux,err,mjd,mjd
132+
ELSE
133+
flux = test
134+
err = 0.
135+
write(lu_out,'(f10.5,'' | '',f10.5,'' | '',e10.4,'' | '',e10.2,'' | '',
136+
& e10.4,'' | '',e10.3,'' | '',f10.2,'' | '',f10.2,'' | UL | '')')
137+
& ra,dec,freq,one,flux,err,mjd,mjd
138+
ENDIF
139+
ENDDO
140+
99 CONTINUE
141+
END

0 commit comments

Comments
 (0)