I'm trying to make sure that all the files(here in my case 'ccf_table','bis_file') are there in the directory before the code proceed to start the computations. And if either of them(bis_file,ccf_table) is not there in directory for any of the input file('filename' in my case) then just simply pass that input file.
path = "/home/Desktop/s1d_data"
for filename in os.listdir(path):
if filename.endswith("_s1d_A.fits"):
s1d_hdu = fits.open(filename)
s1d_header = s1d_hdu[0].header
date = s1d_header['DATE-OBS']
date2 = date = date[0:19]
ccf_table = glob('HARPS.' + date2 + '*_ccf_G2_A.tbl')
bis_file = glob('HARPS.' + date2 + '*_bis_G2_A.fits')
filelist = ['ccf_table','bis_file']
while True:
list1 = []
for file in filelist:
list1.append(os.path.isfile(file))
if all(list1):
break
else:
pass
df=pd.read_table(ccf_table[0],skiprows=2,usecols=(0,4),names=['order','rv'],)
df = df.rv.mean()
out_name = s1d_header['OBJECT'] +'-' + s1d_header['DATE-OBS'] +'.fits'
That's what i've tried until now but didn't get the desired result.Any help would be appreciated.