def time_calibration(input_file): """ Obtain the calibration for time (hjd) by pyraf and the airmass for each image. Include in the header all information. """ original_path = os.getcwd() save_path = input_file['save_path'] #change to save data reduction directory os.chdir(save_path) print '\n Reading the list of images ....\n' planet = input_file['exoplanet'] #set exoplanet name images = sorted(glob.glob('AB'+planet+'*.fits')) print images #include de RA,DEC and epoch of the exoplanet RA,DEC,epoch = input_file['RA'],input_file['DEC'],input_file['epoch'] #obtain ST JD using iraf task and introduce in the header for i in range(len(images)): hdr = fits.getheader(images[i]) if int(split(hdr['UT'],':')[0]) < int(hdr['timezone']): new_date = use.yesterday(hdr['date-obs']) #print images[i], new_date else: new_date = hdr['date-obs'] year,month,day = split(new_date,'-') iraf.asttimes(year=year,month=month,day=day,time=hdr['loctime'],obs=input_file['observatory']) JD = iraf.asttimes.jd #obtain julian date LMST = iraf.asttimes.lmst #obtain the sideral time LMST = use.sexagesimal_format(LMST) #convert sideral time in sexagesimal format iraf.hedit(images[i],'ST',LMST,add='yes',verify='no',show='no',update='yes') #create the ST keyword in the header iraf.ccdhedit(images[i],'LMST',LMST,type='string') #include the mean sideral time in the header iraf.ccdhedit(images[i],'JD',JD,type='string') #include de julian date in the header #include RA, and DEC of the object in your header iraf.ccdhedit(images[i],"RA",RA,type="string") #include right ascention in the header iraf.ccdhedit(images[i],"DEC",DEC,type="string") #include declination in the header iraf.ccdhedit(images[i],"epoch",epoch,type="string") #include epoch in the header # use.update_progress((i+1.)/len(images)) print '\n Setting airmass ....\n' for i in range(len(images)): print '# ',images[i] #iraf.hedit(images[i],'airmass',airmass,add='yes') #iraf.hedit(images[i],'HJD',HJD,add='yes') iraf.setairmass.observatory = input_file['observatory'] iraf.setairmass(images[i]) iraf.setjd.time = 'ut' iraf.setjd(images[i]) print '\n.... done.\n' #export information hjd, jd, airmass, st = [],[],[],[] for i in range(len(images)): hdr = fits.getheader(images[i]) hjd.append(hdr['HJD']) jd.append(hdr['JD']) airmass.append(hdr['airmass']) st.append(hdr['st']) #saving the data data = DataFrame([list(hjd),list(jd),list(st),list(airmass)]).T data.columns = ['HJD','JD','ST','Airmass'] data.to_csv('results_iraf_calibrations.csv') #change to workings directory os.chdir(original_path) return
def local_to_sidereal_time(date, time, observatory): """ From date, time and observatory name (e.g. OSN) calculate the sidereal local time """ year, month, day = date.split("-") hour, minute, second = time.split(":") # iraf's routine asttimes needs the time in hours! time_hours = float(hour) + float(minute)/60. + float(second)/3600. screen = sys.stdout sys.stdout = open("temporal.txt", "w") iraf.asttimes(observatory=observatory, year=year, month=month, day=day, \ time=time_hours) sys.stdout = screen for lines in open("temporal.txt"): if len(lines) > 2: sidereal_time = lines.split()[-1] os.remove("temporal.txt") return sidereal_time
images = sorted(glob.glob('AB'+planet+'*.fits')) print images #include de RA,DEC and epoch of the exoplanet RA,DEC,epoch = input_data['RA'],input_data['DEC'],input_data['epoch'] #obtain ST JD using iraf task and introduce in the header for i in range(len(images)): hdr = fits.getheader(images[i]) if int(split(hdr['UT'],':')[0]) < int(hdr['timezone']): new_date = use.yesterday(hdr['date-obs']) #print images[i], new_date else: new_date = hdr['date-obs'] year,month,day = split(new_date,'-') iraf.asttimes(year=year,month=month,day=day,time=hdr['loctime'],obs=input_data['observatory']) JD = iraf.asttimes.jd #obtain julian date LMST = iraf.asttimes.lmst #obtain the sideral time LMST = use.sexagesimal_format(LMST) #convert sideral time in sexagesimal format iraf.hedit(images[i],'ST',LMST,add='yes',verify='no',show='no',update='yes') #create the ST keyword in the header iraf.ccdhedit(images[i],'LMST',LMST,type='string') #include the mean sideral time in the header iraf.ccdhedit(images[i],'JD',JD,type='string') #include de julian date in the header #include RA, and DEC of the object in your header iraf.ccdhedit(images[i],"RA",RA,type="string") #include right ascention in the header iraf.ccdhedit(images[i],"DEC",DEC,type="string") #include declination in the header iraf.ccdhedit(images[i],"epoch",epoch,type="string") #include epoch in the header # use.update_progress((i+1.)/len(images)) print '\n Setting airmass ....\n' for i in range(len(images)): print '# ',images[i]