def main(file_path): darklist = functions.find_objname(file_path,functions.read_config_file("BIAS_HEADER")) master_dark = average_darks(darklist) try: functions.save_fits(master_dark,file_path+"temp/master_dark.fits") except IOError: os.system("mkdir "+file_path+"temp/") functions.save_fits(master_dark,file_path+"temp/master_dark.fits")
def main(file_path): darklist = functions.find_objname(file_path,functions.read_config_file("FLAT_HEADER")) if len(darklist) == 0: print "Error: no flats found" raise IOError master_dark = average_darks(darklist,file_path+"temp/master_dark.fits") try: functions.save_fits(master_dark,file_path+"temp/master_flat.fits") except IOError: os.system("mkdir "+file_path+"temp/") functions.save_fits(master_dark,file_path+"temp/master_flat.fits")
def main(file_path): ### Setup setup_dir(file_path) if functions.read_config_file("DELETE_ALL") == "true": delete_all(file_path) ### Make bias if not os.path.exists(file_path+"temp/master_dark.fits"): import master_dark master_dark.main(file_path) ### Make flatfield if not os.path.exists(file_path+"temp/master_flat.fits"): flatfield.main(file_path) ### load sciencelist sciencelist_temp = functions.find_objname(file_path,functions.read_config_file("OBJECT_HEADER")) ### Check if each one has been fully downloaded sciencelist = [] for fits in sciencelist_temp: try: test = pyfits.getdata(fits) sciencelist.append(fits) print "OK",fits except ValueError: pass for fits in sciencelist: fits_base = string.split(fits,"/")[-1] fits_base = string.split(fits_base,".")[0] if not os.path.exists(file_path+"reduced/"+fits_base+".fits"): print "********************************" print "Reducing",fits fits_path = process(fits,file_path+"reduced/") flatfield.apply_flatfield(fits_path,file_path+"temp/master_flat.fits",file_path+"temp/master_dark.fits") ### Now extract sources in reference image, match, and do photometry import fistar,transcoord,fiphot refimage = functions.read_config_file("REFERENCE_IMAGE") refimage_coords=fistar.fistar(file_path+"reduced/"+refimage) reflist = loadtxt(functions.read_config_file("OBJECT_LIST")) ###reformat reflist so that it reflects the refimage actual star coordinates ### So that the extraction coordinates are exact new_reflist = [] for star in reflist: dist = sqrt((star[1]-refimage_coords[:,1])**2 + (star[2]-refimage_coords[:,2])**2) indx = argmin(dist) star[1] = refimage_coords[indx,1] star[2] = refimage_coords[indx,2] new_reflist.append(star) savetxt(file_path+"reduced/object_list",array(new_reflist)) for fits in sciencelist: fits_base = string.split(fits,"/")[-1] fits_base = string.split(fits_base,".")[0] if not os.path.exists(file_path+"/reduced/"+fits_base+".fits.phot"): ### transform the coordinates of extraction transcoord.transcoord(file_path+"/reduced/"+fits_base+".fits",file_path+"reduced/object_list",file_path+"reduced/"+refimage+".fistar") ### Now apply fiphot and get real photometry out fiphot.fiphot(file_path+"/reduced/"+fits_base+".fits")