-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfits2ascii.py
executable file
·35 lines (26 loc) · 982 Bytes
/
fits2ascii.py
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
#!/usr/bin/env python
from __future__ import print_function
import os
import numpy as np
from pyraf import iraf
from astropy.io import fits
from astropy import units as u
from astropy.coordinates import SkyCoord, FK5, ICRS
def fits2ascii(input_files):
if '.list' in input_files:
input_files = [line.rstrip('\n') for line in open(input_files)]
elif len(input_files.split()) > 1:
pass
elif '.fits' in input_files:
input_files = [input_files]
for input_file in input_files:
try:
output_file = input_file.split('.fits')[0] + '.dat'
iraf.wspectext(input_file+'[*,1]', output_file, header=False)
print(input_file, ' > ', output_file)
except:
print(input_file, ' failed...')
def main():
input_files = raw_input('Enter fits file, list of them or file with a list in it (with ".list" extension) to convert to ascii: ')
fits2ascii(input_files)
main()