file_name = sys.argv[2] os.chdir(file_path) ####################################################################### ### Find the Ne Ar arc lamp exposure closest to the object exposure ### ####################################################################### ### Find object JD hdulist = pyfits.open(file_name) object_MJD = hdulist[0].header['MJD-OBS'] hdulist.close() ### Compile list of NeAr arcs object_list = functions.ccdlist_extract(iraf.ccdlist("*.fits",Stdout = 1)) NeAr_match = functions.ccdlist_identify(object_list,"Ne-Ar") ### Open each fine and find its MJD arc_MJD = [] for i in range(len(NeAr_match)): hdulist = pyfits.open(object_list[NeAr_match[i]][0]) arc_MJD.append([abs(hdulist[0].header['MJD-OBS'] - object_MJD),object_list[NeAr_match[i]][0]]) hdulist.close() ### Sort arc_MJD according to closest time to object exposure arc_MJD = functions.sort_array(arc_MJD,0) ### Choose 2 arc images if the 2nd arc frame was taken <30min from object if len(arc_MJD) > 1: if arc_MJD[1][0] < 0.02: arc_names = arc_MJD[0][1] + "\n" + arc_MJD[1][1] + "\n"
### Go through the folders, identify and reduce each smooth image smooth_files_list = [] stars_to_try = ["ltt4364","eg131"] for star in stars_to_try: count = 1 for i in range(len(folders_to_search)): file_path_current = file_path + folders_to_search[i] ### Find any smooth star exposures ccdlist_info = iraf.ccdlist(file_path_current + "*.fits", Stdout = 1) ccdlist_info = functions.ccdlist_extract(ccdlist_info) ccdlist_match = functions.ccdlist_identify(ccdlist_info,star) ### Reduce any such exposures if len(ccdlist_match) > 0: for j in range(len(ccdlist_match)): file_name = ccdlist_info[ccdlist_match[j]][2] + ".fits" file_path_temp = file_path_current + "temp/" file_path_reduced = file_path_current + "reduced/" print "currently reducing image " + file_path_current + file_name smooth_files_list,count = reduce_image(file_path_current,file_name,file_path_reduced,smooth_files_list,count) ### If exposures were found for starX, then break the for loop if count > 1: break
### Start of program ### ######################## ### Make the required folders print "Making directories temp and reduced" os.system("mkdir " + file_path + "temp") os.system("mkdir " + file_path + "reduced") ######################## ### Form master bias ### ######################## ### Find the bias images print "Finding the bias frame(s)" ccdlist_info = iraf.ccdlist(file_path + "*.fits", Stdout=1) ccdlist_info = functions.ccdlist_extract(ccdlist_info) ccdlist_match = functions.ccdlist_identify(ccdlist_info,"bias") os.system("rm " + file_path_temp + "master_bias.fits") if len(ccdlist_match) < 1: print "!!!!!!! No Bias frames found, using default bias !!!!!!!" os.system("cp default_cal_frames/bias.fits " + file_path_temp + "master_bias.fits") if len(ccdlist_match) >= 1: input_list = "" for i in range(len(ccdlist_match)): bias_file_path = ccdlist_info[ccdlist_match[i]][0] input_list = input_list + bias_file_path + "\n" functions.write_string_to_file(input_list,file_path + "bias_list") print "The bias files found are:" print input_list iraf.combine(