-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_all_fits.py
57 lines (41 loc) · 1.32 KB
/
get_all_fits.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
from os.path import isdir , isfile , join
import numpy as np
import astropy as ap
from astropy.io import fits
if __name__ == '__main__':
# getting all directories in current working dir
wd = './'
dir_names = [wd + f + '/' for f in os.listdir (wd) if isdir(join(wd,f))]
star_params = np.loadtxt ('star_parameters.csv', skiprows=1 , dtype=str, delimiter=',')
# print(star_params[:,0])
cmd_list = []
for d in dir_names :
if '00_m_16' in d or 'small_asteroid_lightcurve_CFHT_data' in d: continue
file_names = [d + f for f in os.listdir(d) if isfile(join(d,f))]
for f in file_names:
# only working on new files around asteroid chip
if not 'on' in f: continue
if not ( 'EL157' in f or 'FF14' in f or 'GE1' in f or 'EN156' in f): continue
try:
file = fits.open (f)
# print( f'{f} is a fits file')
except Exception as e:
# print( f'{f} is not a fits file' )
continue
L = 0
a = 0
oid = f.split('_')[1]
# print(oid)
for i in range(len(star_params)):
if oid in star_params[i,0]:
L = star_params[i,1]
a = star_params[i,2]
break
command = f'\n{f[:]}'
print(command)
cmd_list.append(command)
# for i in cmd_list: print(i)
# output = open('ast_files.txt', 'w+')
output = open('fits_files_all_chips1.txt', 'w+')
output.writelines( cmd_list )