Created
July 14, 2015 18:29
-
-
Save boada/e3a4ca3de3d0db280b2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from glob import glob | |
from astropy import table | |
from astropy.io import fits | |
from os.path import exists | |
files = glob('*.fit') | |
for f in files: | |
print f, '.....', | |
if not exists(f.replace('fit', 'hdf5')): | |
try: | |
t = table.Table.read(f, 'r') | |
t.write(f.replace('.fit', '.hdf5'), | |
path=f.split('_')[1]+'_'+f.split('.')[1]) | |
print 'Done' | |
except IOError: | |
data = fits.getdata(f, ignore_missing_end=True) | |
t = table.Table(data) | |
t.write(f.replace('.fit', '.hdf5'), | |
path=f.split('_')[1]+'_'+f.split('.')[1]) | |
print 'Done' | |
else: | |
print 'Already Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment