コード例 #1
0
ファイル: saltsafekey.py プロジェクト: swj1442291549/pysalt
def mkheader(file, keyword, value, comment):
    """create keyword with mkheader IRAF tool i.e. without opening the whole file"""

    try:
        tmpfile = saltsafeio.tmpfile('.', False)
        tmp = saltsafeio.openascii(tmpfile, 'w')
        tmp.write('%-8s= \'%-18s\' / %-s\n' % (keyword, value, comment))
        saltsafeio.closeascii(tmp)
        iraf.noao.artdata.mkheader(file, tmpfile, append='y', verbose='n')
        saltsafeio.delete(tmpfile, False)
    except:
        raise SaltIOError('Cannot edit keyword ' + keyword + ' in ' + file)
コード例 #2
0
ファイル: saltsafekey.py プロジェクト: apodemus/pysalt3
def mkheader(file,keyword,value,comment):
    """create keyword with mkheader IRAF tool i.e. without opening the whole file"""

    try:
        tmpfile=saltsafeio.tmpfile('.',False)
        tmp=saltsafeio.openascii(tmpfile,'w')
        tmp.write('%-8s= \'%-18s\' / %-s\n' % (keyword,value,comment))
        saltsafeio.closeascii(tmp)
        iraf.noao.artdata.mkheader(file,tmpfile,append='y',verbose='n')
        saltsafeio.delete(tmpfile,False)
    except:
        raise SaltIOError('Cannot edit keyword '+keyword+' in '+file)
コード例 #3
0
ファイル: saltfast.py プロジェクト: saltastro/pipetools
def maketempreadmefast(pid, sdb, readme):
   """Creates the readme file to send to the PI.  It adds on the observing log for those
      observations
   """
   #read in the readme
   f=saltio.openascii(readme, 'r')
   rstring=f.read()
   saltio.closeascii(f)

   #replace propcode with the actual propcode
   if pid: rstring=rstring.replace('PROPCODE', pid)

   #add in the observing log

   return rstring 
コード例 #4
0
ファイル: saltpipe.py プロジェクト: saltastro/pipetools
def checkfordata(rawpath, prefix, obsdate, log):
   """Check to see if the data have downloaded correctly"""
   lastnum=1
   saltio.fileexists(rawpath+'disk.file')
   content = saltio.openascii(rawpath+'disk.file','r')
   for line in content:
       lastnum = saltstring.filenumber(line)
   saltio.closeascii(content)
   lastfile = saltstring.filename(prefix,obsdate,lastnum-1)

   if lastnum==1: return lastnum

   #check to see that the data are present
   if (os.path.isfile(rawpath+lastfile) or os.path.isfile(rawpath+lastfile.replace('fits','bin'))):
       message  = 'Data download complete for %s\n' % rawpath
       log.message(message)
   else:
       message  = 'Data download incomplete to %s' % rawpath
       log.error(message)

   return lastnum
コード例 #5
0
ファイル: saltemail.py プロジェクト: saltastro/pipetools
       except SaltIOError:
           msg="No notifications necessary for %s" % obsdate
           log.warning
           return

       #loop through each of the pids and send the email
       for pid in pids:
         propinfo=findpropinfo(pid, sdb)
         if propinfo:
           for pi, email in zip(propinfo[pid][0], propinfo[pid][1]):
               letter=saltio.openascii(readme,'r')
               msg=letter.read()
               msg=msg.replace('yourname',pi)
               msg=msg.replace('YYYY-INST-PID',pid.upper())
               msg=msg.replace('yyyymmdd',obsdate)
               saltio.closeascii(letter)

               #set up the message to be sent
               recip = []
               #uncomment the following lines if you just want to send the email
               #to yourself
               #email='*****@*****.**'
               #bcclist=[]
               recip.append(email)
               for bccobj in bcclist:
                   recip.append(bccobj)
               msg = MIMEText(msg)
               msg['Subject'] = 'SALT data available for download for %s' % pid.upper()
               msg['From'] = sender
               msg['To'] = email
               msg['bcc'] = bcc
コード例 #6
0
ファイル: old_slotview.py プロジェクト: astrophysaxist/pysalt
def slotview(newfits,indata , fileout, srcfile, fps=10.0, phottype='square', sigdet=5, contpix=10, \
    driftlimit=10, clobber=True,logfile='slotview.log',verbose=True):

    
#set up the variables
    status = 0
    entries = []
    vig_lo = {}
    vig_hi = {}
    hour = 0
    min = 0
    sec = 0.
    time0 = 0.
    nframes = 0
    sleep=0

    with logging(logfile,debug) as log:

        #enter in the input data
        saltio.fileexists(newfits)

        #set the sleep parameter
        if fps>0: sleep=1.0/(fps)

        # read in the data file
        id, time, ratio, rerr, tx, ty, tflux, terr, cx, cy, cflux, cerr=st.readlcfile(indata)

        # read extraction region defintion file
        amp, x, y, x_o, y_o, r, br1, br2=st.readsrcfile(srcfile)



        #determine the size of the data arrays
        struct = saltio.openfits(newfits)
        naxis1 = saltkey.get('NAXIS1',struct[1])
        naxis2 = saltkey.get('NAXIS2',struct[1])

        # Plot all of the data and the first image
        # Create GUI
        App = QtGui.QApplication([])
        aw=SlotViewWindow(struct, id, tflux, cflux, ratio, time, phottype, sleep,   \
                     tx, ty, cx, cy, r, br1, br2, naxis1, naxis2, sigdet, contpix, driftlimit)
        aw.show()

        # Start application event loop
        app_exit=App.exec_()
        
        # Check if GUI was executed succesfully
        if app_exit!=0:
             raise SALTError('InterIdentify GUI has unexpected exit status '+str(exit))

        ratio, tflux, cflux, gframe, newphot=aw.ratio, aw.tflux, aw.cflux, aw.goodframes, aw.newphot

        #close the input file
        saltio.closefits(struct)

        # Update the indata file if necessary
        lc=saltio.openascii(fileout,'w')

        for i in range(len(ratio)):
            x['target']=tx[i]
            x['comparison']=cx[i]
            y['target']=ty[i]
            y['comparison']=cy[i]
            reltime=False
            if gframe[i]:
                st.writedataout(lc, id[i], time[i], x, y, tflux[i], terr[i], \
                    cflux[i], cerr[i], ratio[i], rerr[i], time[0], reltime)

        saltio.closeascii(lc)
コード例 #7
0
ファイル: slotview.py プロジェクト: swj1442291549/pysalt
def slotview(newfits,indata , fileout, srcfile, fps=10.0, phottype='square', sigdet=5, contpix=10, \
    driftlimit=10, clobber=True,logfile='slotview.log',verbose=True):

    #set up the variables
    status = 0
    entries = []
    vig_lo = {}
    vig_hi = {}
    hour = 0
    min = 0
    sec = 0.
    time0 = 0.
    nframes = 0
    sleep = 0

    with logging(logfile, debug) as log:

        #enter in the input data
        saltio.fileexists(newfits)

        #set the sleep parameter
        if fps > 0: sleep = 1.0 / (fps)

        # read in the data file
        id, time, ratio, rerr, tx, ty, tflux, terr, cx, cy, cflux, cerr = st.readlcfile(
            indata)

        # read extraction region defintion file
        amp, x, y, x_o, y_o, r, br1, br2 = st.readsrcfile(srcfile)

        #determine the size of the data arrays
        struct = saltio.openfits(newfits)
        naxis1 = saltkey.get('NAXIS1', struct[1])
        naxis2 = saltkey.get('NAXIS2', struct[1])

        # Plot all of the data and the first image
        # Create GUI
        App = QtGui.QApplication([])
        aw=SlotViewWindow(struct, id, tflux, cflux, ratio, time, phottype, sleep,   \
                     tx, ty, cx, cy, r, br1, br2, naxis1, naxis2, sigdet, contpix, driftlimit)
        aw.show()

        # Start application event loop
        app_exit = App.exec_()

        # Check if GUI was executed succesfully
        if app_exit != 0:
            raise SALTError('InterIdentify GUI has unexpected exit status ' +
                            str(exit))

        ratio, tflux, cflux, gframe, newphot = aw.ratio, aw.tflux, aw.cflux, aw.goodframes, aw.newphot

        #close the input file
        saltio.closefits(struct)

        # Update the indata file if necessary
        lc = saltio.openascii(fileout, 'w')

        for i in range(len(ratio)):
            x['target'] = tx[i]
            x['comparison'] = cx[i]
            y['target'] = ty[i]
            y['comparison'] = cy[i]
            reltime = False
            if gframe[i]:
                st.writedataout(lc, id[i], time[i], x, y, tflux[i], terr[i], \
                    cflux[i], cerr[i], ratio[i], rerr[i], time[0], reltime)

        saltio.closeascii(lc)