Beispiel #1
0
   def __init__(self, obsdate, imdir, prodir, server='smtp.saao.ac.za', readme='readme.fast.template',  \
                sdbhost='sdb.salt', sdbname='sdb', sdbuser='', \
                password='', hmin=350,  wmin=400, cmap='gray', \
                sexfile='/home/ccd/tools/qred.sex', update=True,
                scale='zscale', contrast=0.1, imreduce=True, clobber=False, log=None, verbose=True):

        #set up the variables
        self.obsdate=obsdate
        self.imdir=imdir
        self.prodir=prodir
        self.imreduce=imreduce
        self.clobber=clobber
        self.scamwatch=True
        self.rsswatch=True
        self.hrswatch=True 
        self.hrbwatch=True
        self.objsection=None
        self.sdbhost=sdbhost
        self.sdbname=sdbname
        self.sdbuser=sdbuser
        self.password=password
        self.server=server
        self.readme=readme
        self.sexfile=sexfile
        self.update=update
        self.headfiles=[]
        self.pickle_file='%s_obslog.p' % self.obsdate

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("SALTFIRST")

        #set up observation log from database
        self.create_obslog()

        #look for any initial data
        self.checkfordata(self.obsdate, self.imdir)

        #example data
        #image='../salt/scam/data/2006/1016/raw/S200610160009.fits'
        #self.hdu=saltio.openfits(image)
        #name=getbasename(self.hdu)
        #imlist=getimagedetails(self.hdu)
        #obsdict={}
        #obsdict[name]=imlist

        #set up each of the tabs
        if len(self.obsdict)>0:
           name=self.obsdict.order()[-1]
           imlist=self.obsdict[name]
        else:
           name=''
           imlist=[]
           self.hdu=None
        self.infoTab=InfoWidget(name, imlist)
        self.dqTab=DQWidget(name, imlist)
        #self.imageTab=ImageWidget(self.hdu, hmin=hmin, wmin=wmin, cmap=cmap, scale=scale, contrast=contrast)
        self.specTab=SpectraViewWidget(None, None, None, hmin=hmin, wmin=wmin)
        self.obsTab=ObsLogWidget(self.obsdict, obsdate=self.obsdate)
        #create the tabs
        self.tabWidget=QtGui.QTabWidget()
        self.tabWidget.addTab(self.infoTab, 'Info')
        self.tabWidget.addTab(self.dqTab, 'DQ')
        #self.tabWidget.addTab(self.imageTab, 'Image')
        self.tabWidget.addTab(self.specTab, 'Spectra')
        self.tabWidget.addTab(self.obsTab, 'Log')
        #create button to reset the filewatcher
        self.checkButton = QtGui.QPushButton("Check for Data")
        self.checkButton.clicked.connect(self.clickfordata)
     
        #layout the widgets
        mainLayout = QtGui.QVBoxLayout(self.main)
        mainLayout.addWidget(self.tabWidget)
        mainLayout.addWidget(self.checkButton)
        #set up thrading
        self.threadlist=[]
        self.thread=QtCore.QThread()
        self.nothread=False

        #add the file watching capability
        self.addwatcher()

        #add a timer to check on data and update obslog in database
        self.ctimer=QtCore.QTimer()
        ctime=5*60*1000
        self.ctimer.start(ctime)
        self.connect(self.ctimer, QtCore.SIGNAL("timeout()"), self.updatetime)
        #add signal catches
        self.connect(self, QtCore.SIGNAL('updatespec(QString)'), self.updatespecview)
        self.connect(self.thread, QtCore.SIGNAL('finishedthread(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('cellclicked(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('updateobslogdb(QString)'), self.updateobslogdb)
        self.connect(self.obsTab, QtCore.SIGNAL('updatecals(QString)'), self.updatecals)
        self.connect(self.specTab, QtCore.SIGNAL('updateextract(int,int)'), self.updateextract)
        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Beispiel #2
0
   def __init__(self, obsdate, imdir, prodir, server='smtp.saao.ac.za', readme='readme.fast.template',  \
                sdbhost='sdb.salt', sdbname='sdb', sdbuser='', \
                password='', hmin=350,  wmin=400, cmap='gray', \
                sexfile='/home/ccd/tools/qred.sex', update=True,
                scale='zscale', contrast=0.1, imreduce=True, clobber=False, log=None, verbose=True):

        #set up the variables
        self.obsdate=obsdate
        self.imdir=imdir
        self.prodir=prodir
        self.imreduce=imreduce
        self.clobber=clobber
        self.scamwatch=True
        self.rsswatch=True
        self.hrswatch=True 
        self.hrbwatch=True
        self.objsection=None
        self.sdbhost=sdbhost
        self.sdbname=sdbname
        self.sdbuser=sdbuser
        self.password=password
        self.server=server
        self.readme=readme
        self.sexfile=sexfile
        self.update=update
        self.headfiles=[]
        self.pickle_file='%s_obslog.p' % self.obsdate

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("SALTFIRST")

        #set up observation log from database
        self.create_obslog()

        #look for any initial data
        self.checkfordata(self.obsdate, self.imdir)

        #example data
        #image='../salt/scam/data/2006/1016/raw/S200610160009.fits'
        #self.hdu=saltio.openfits(image)
        #name=getbasename(self.hdu)
        #imlist=getimagedetails(self.hdu)
        #obsdict={}
        #obsdict[name]=imlist

        #set up each of the tabs
        if len(self.obsdict)>0:
           name=self.obsdict.order()[-1]
           imlist=self.obsdict[name]
        else:
           name=''
           imlist=[]
           self.hdu=None
        self.infoTab=InfoWidget(name, imlist)
        self.dqTab=DQWidget(name, imlist)
        #self.imageTab=ImageWidget(self.hdu, hmin=hmin, wmin=wmin, cmap=cmap, scale=scale, contrast=contrast)
        self.specTab=SpectraViewWidget(None, None, None, hmin=hmin, wmin=wmin)
        self.obsTab=ObsLogWidget(self.obsdict, obsdate=self.obsdate)
        #create the tabs
        self.tabWidget=QtGui.QTabWidget()
        self.tabWidget.addTab(self.infoTab, 'Info')
        self.tabWidget.addTab(self.dqTab, 'DQ')
        #self.tabWidget.addTab(self.imageTab, 'Image')
        self.tabWidget.addTab(self.specTab, 'Spectra')
        self.tabWidget.addTab(self.obsTab, 'Log')
        #create button to reset the filewatcher
        self.checkButton = QtGui.QPushButton("Check for Data")
        self.checkButton.clicked.connect(self.clickfordata)
     
        #layout the widgets
        mainLayout = QtGui.QVBoxLayout(self.main)
        mainLayout.addWidget(self.tabWidget)
        mainLayout.addWidget(self.checkButton)
        #set up thrading
        self.threadlist=[]
        self.thread=QtCore.QThread()
        self.nothread=False

        #add the file watching capability
        self.addwatcher()

        #add a timer to check on data and update obslog in database
        self.ctimer=QtCore.QTimer()
        ctime=5*60*1000
        self.ctimer.start(ctime)
        self.connect(self.ctimer, QtCore.SIGNAL("timeout()"), self.updatetime)
        #add signal catches
        self.connect(self, QtCore.SIGNAL('updatespec(QString)'), self.updatespecview)
        self.connect(self.thread, QtCore.SIGNAL('finishedthread(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('cellclicked(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('updateobslogdb(QString)'), self.updateobslogdb)
        self.connect(self.obsTab, QtCore.SIGNAL('updatecals(QString)'), self.updatecals)
        self.connect(self.specTab, QtCore.SIGNAL('updateextract(int,int)'), self.updateextract)
        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Beispiel #3
0
class FirstWindow(QtGui.QMainWindow):

   def __init__(self, obsdate, imdir, prodir, server='smtp.saao.ac.za', readme='readme.fast.template',  \
                sdbhost='sdb.salt', sdbname='sdb', sdbuser='', \
                password='', hmin=350,  wmin=400, cmap='gray', \
                sexfile='/home/ccd/tools/qred.sex', update=True,
                scale='zscale', contrast=0.1, imreduce=True, clobber=False, log=None, verbose=True):

        #set up the variables
        self.obsdate=obsdate
        self.imdir=imdir
        self.prodir=prodir
        self.imreduce=imreduce
        self.clobber=clobber
        self.scamwatch=True
        self.rsswatch=True
        self.hrswatch=True 
        self.hrbwatch=True
        self.objsection=None
        self.sdbhost=sdbhost
        self.sdbname=sdbname
        self.sdbuser=sdbuser
        self.password=password
        self.server=server
        self.readme=readme
        self.sexfile=sexfile
        self.update=update
        self.headfiles=[]
        self.pickle_file='%s_obslog.p' % self.obsdate

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("SALTFIRST")

        #set up observation log from database
        self.create_obslog()

        #look for any initial data
        self.checkfordata(self.obsdate, self.imdir)

        #example data
        #image='../salt/scam/data/2006/1016/raw/S200610160009.fits'
        #self.hdu=saltio.openfits(image)
        #name=getbasename(self.hdu)
        #imlist=getimagedetails(self.hdu)
        #obsdict={}
        #obsdict[name]=imlist

        #set up each of the tabs
        if len(self.obsdict)>0:
           name=self.obsdict.order()[-1]
           imlist=self.obsdict[name]
        else:
           name=''
           imlist=[]
           self.hdu=None
        self.infoTab=InfoWidget(name, imlist)
        self.dqTab=DQWidget(name, imlist)
        #self.imageTab=ImageWidget(self.hdu, hmin=hmin, wmin=wmin, cmap=cmap, scale=scale, contrast=contrast)
        self.specTab=SpectraViewWidget(None, None, None, hmin=hmin, wmin=wmin)
        self.obsTab=ObsLogWidget(self.obsdict, obsdate=self.obsdate)
        #create the tabs
        self.tabWidget=QtGui.QTabWidget()
        self.tabWidget.addTab(self.infoTab, 'Info')
        self.tabWidget.addTab(self.dqTab, 'DQ')
        #self.tabWidget.addTab(self.imageTab, 'Image')
        self.tabWidget.addTab(self.specTab, 'Spectra')
        self.tabWidget.addTab(self.obsTab, 'Log')
        #create button to reset the filewatcher
        self.checkButton = QtGui.QPushButton("Check for Data")
        self.checkButton.clicked.connect(self.clickfordata)
     
        #layout the widgets
        mainLayout = QtGui.QVBoxLayout(self.main)
        mainLayout.addWidget(self.tabWidget)
        mainLayout.addWidget(self.checkButton)
        #set up thrading
        self.threadlist=[]
        self.thread=QtCore.QThread()
        self.nothread=False

        #add the file watching capability
        self.addwatcher()

        #add a timer to check on data and update obslog in database
        self.ctimer=QtCore.QTimer()
        ctime=5*60*1000
        self.ctimer.start(ctime)
        self.connect(self.ctimer, QtCore.SIGNAL("timeout()"), self.updatetime)
        #add signal catches
        self.connect(self, QtCore.SIGNAL('updatespec(QString)'), self.updatespecview)
        self.connect(self.thread, QtCore.SIGNAL('finishedthread(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('cellclicked(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('updateobslogdb(QString)'), self.updateobslogdb)
        self.connect(self.obsTab, QtCore.SIGNAL('updatecals(QString)'), self.updatecals)
        self.connect(self.specTab, QtCore.SIGNAL('updateextract(int,int)'), self.updateextract)
        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

   def create_obslog(self):
       """Check to see if there are any files in the database, and if so, create the observing log"""
       if os.path.isfile(self.pickle_file) and 0:
          self.obsdict = pickle.load( open( self.pickle_file, "rb" ) )
       else:
          self.obsdict = OrderedDict()

   def updateextract(self, y1, y2):
       print y1, y2
       name=self.specTab.name
       iminfo=self.obsdict[name]
       lampid=iminfo[headerList.index('LAMPID')].strip().upper()
       objsection='[%i:%i]' % (y1, y2)
       if self.specTab.defaultBox.checkState():
               print "Updating Object Section"
               self.objsection=objsection
       else:
               self.objsection=None
       outpath='./'
       outfile=outpath+'smbxp'+name
       logfile='saltclean.log'
       verbose=True
       y1, y2=quickap(outfile, objsection=objsection, clobber=True, logfile=logfile, verbose=verbose)
       #quickspec(outfile, lampid, findobj=False, objsection=objsection, clobber=True, logfile=logfile, verbose=verbose)
       self.specTab.updaterange(y1,y2)
       self.updatespecview(name)


   def updatetime(self):
       """Check to see if the data or logs need updating"""
       print "Checking for updates at %s" % time.asctime()

       #check for any new data
       self.clickfordata('')

       #update the obstab to the sdb
       self.obsTab.printfornightlog()

       self.updatecals()

   def updateobslogdb(self, logstr):
       #print logstr
       print "Updating Obslog for ", self.obsdate
       sdbloadobslog(logstr, self.obsdate, self.sdbhost, self.sdbname, self.sdbuser, self.password)
       pickle.dump(self.obsdict, open(self.pickle_file, 'wb'))
       

   def updatecals(self):
       print "Loading Calibration Data"
       findcal(self.obsdate, self.sdbhost, self.sdbname, self.sdbuser, self.password)


   def updateimlist(self, name, key, value):
       print "UPDATE:", name, key, value

   def updatespecview(self, name):
       name = str(name)
       print "UPDATING SPECVIEW with %s" % name
       specfile='./smbxp'+name.split('.fits')[0]+'.txt'
       warr, farr, snarr=np.loadtxt(specfile, usecols=(0,1,2), unpack=True)
       self.specTab.loaddata(warr, farr, snarr, name)
       self.specTab.redraw_canvas()

   def converttoname(self, infile): 
       """Given a file name, find the raw salt file name"""

   def updatetabs(self, infile):
       name=str(infile)
       imlist=self.obsdict[name]
       detmode=imlist[headerList.index('DETMODE')].strip().upper()
       obsmode=imlist[headerList.index('OBSMODE')].strip().upper()

       #update the information panel
       try:
           self.infoTab.update(name, self.obsdict[name])
           print "UPDATING tabs with %s" % name
       except Exception, e:
           print e
           return

       if self.thread.isRunning() and self.nothread:
           self.nothread=False

       #update the DQ tab
       try:
           self.dqTab.updatetab(name, self.obsdict[name])
           #self.dqTab=DQWidget(name, self.obsdict[name])
           #self.tabWidget.removeTab(1)
           #self.tabWidget.insertTab(1, self.dqTab, 'DQ')
       except Exception, e:
           print e
           return
Beispiel #4
0
class FirstWindow(QtGui.QMainWindow):

   def __init__(self, obsdate, imdir, prodir, server='smtp.saao.ac.za', readme='readme.fast.template',  \
                sdbhost='sdb.salt', sdbname='sdb', sdbuser='', \
                password='', hmin=350,  wmin=400, cmap='gray', \
                sexfile='/home/ccd/tools/qred.sex', update=True,
                scale='zscale', contrast=0.1, imreduce=True, clobber=False, log=None, verbose=True):

        #set up the variables
        self.obsdate=obsdate
        self.imdir=imdir
        self.prodir=prodir
        self.imreduce=imreduce
        self.clobber=clobber
        self.scamwatch=True
        self.rsswatch=True
        self.hrswatch=True 
        self.hrbwatch=True
        self.objsection=None
        self.sdbhost=sdbhost
        self.sdbname=sdbname
        self.sdbuser=sdbuser
        self.password=password
        self.server=server
        self.readme=readme
        self.sexfile=sexfile
        self.update=update
        self.headfiles=[]
        self.pickle_file='%s_obslog.p' % self.obsdate

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("SALTFIRST")

        #set up observation log from database
        self.create_obslog()

        #look for any initial data
        self.checkfordata(self.obsdate, self.imdir)

        #example data
        #image='../salt/scam/data/2006/1016/raw/S200610160009.fits'
        #self.hdu=saltio.openfits(image)
        #name=getbasename(self.hdu)
        #imlist=getimagedetails(self.hdu)
        #obsdict={}
        #obsdict[name]=imlist

        #set up each of the tabs
        if len(self.obsdict)>0:
           name=self.obsdict.order()[-1]
           imlist=self.obsdict[name]
        else:
           name=''
           imlist=[]
           self.hdu=None
        self.infoTab=InfoWidget(name, imlist)
        self.dqTab=DQWidget(name, imlist)
        #self.imageTab=ImageWidget(self.hdu, hmin=hmin, wmin=wmin, cmap=cmap, scale=scale, contrast=contrast)
        self.specTab=SpectraViewWidget(None, None, None, hmin=hmin, wmin=wmin)
        self.obsTab=ObsLogWidget(self.obsdict, obsdate=self.obsdate)
        #create the tabs
        self.tabWidget=QtGui.QTabWidget()
        self.tabWidget.addTab(self.infoTab, 'Info')
        self.tabWidget.addTab(self.dqTab, 'DQ')
        #self.tabWidget.addTab(self.imageTab, 'Image')
        self.tabWidget.addTab(self.specTab, 'Spectra')
        self.tabWidget.addTab(self.obsTab, 'Log')
        #create button to reset the filewatcher
        self.checkButton = QtGui.QPushButton("Check for Data")
        self.checkButton.clicked.connect(self.clickfordata)
     
        #layout the widgets
        mainLayout = QtGui.QVBoxLayout(self.main)
        mainLayout.addWidget(self.tabWidget)
        mainLayout.addWidget(self.checkButton)
        #set up thrading
        self.threadlist=[]
        self.thread=QtCore.QThread()
        self.nothread=False

        #add the file watching capability
        self.addwatcher()

        #add a timer to check on data and update obslog in database
        self.ctimer=QtCore.QTimer()
        ctime=5*60*1000
        self.ctimer.start(ctime)
        self.connect(self.ctimer, QtCore.SIGNAL("timeout()"), self.updatetime)
        #add signal catches
        self.connect(self, QtCore.SIGNAL('updatespec(QString)'), self.updatespecview)
        self.connect(self.thread, QtCore.SIGNAL('finishedthread(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('cellclicked(QString)'), self.updatetabs)
        self.connect(self.obsTab, QtCore.SIGNAL('updateobslogdb(QString)'), self.updateobslogdb)
        self.connect(self.obsTab, QtCore.SIGNAL('updatecals(QString)'), self.updatecals)
        self.connect(self.specTab, QtCore.SIGNAL('updateextract(int,int)'), self.updateextract)
        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

   def create_obslog(self):
       """Check to see if there are any files in the database, and if so, create the observing log"""
       if os.path.isfile(self.pickle_file) and 0:
          self.obsdict = pickle.load( open( self.pickle_file, "rb" ) )
       else:
          self.obsdict = OrderedDict()

   def updateextract(self, y1, y2):
       print y1, y2
       name=self.specTab.name
       iminfo=self.obsdict[name]
       lampid=iminfo[headerList.index('LAMPID')].strip().upper()
       objsection='[%i:%i]' % (y1, y2)
       if self.specTab.defaultBox.checkState():
               print "Updating Object Section"
               self.objsection=objsection
       else:
               self.objsection=None
       outpath='./'
       outfile=outpath+'smbxp'+name
       logfile='saltclean.log'
       verbose=True
       y1, y2=quickap(outfile, objsection=objsection, clobber=True, logfile=logfile, verbose=verbose)
       #quickspec(outfile, lampid, findobj=False, objsection=objsection, clobber=True, logfile=logfile, verbose=verbose)
       self.specTab.updaterange(y1,y2)
       self.updatespecview(name)


   def updatetime(self):
       """Check to see if the data or logs need updating"""
       print "Checking for updates at %s" % time.asctime()

       #check for any new data
       self.clickfordata('')

       #update the obstab to the sdb
       self.obsTab.printfornightlog()

       self.updatecals()

   def updateobslogdb(self, logstr):
       #print logstr
       print "Updating Obslog for ", self.obsdate
       sdbloadobslog(logstr, self.obsdate, self.sdbhost, self.sdbname, self.sdbuser, self.password)
       pickle.dump(self.obsdict, open(self.pickle_file, 'wb'))
       

   def updatecals(self):
       print "Loading Calibration Data"
       findcal(self.obsdate, self.sdbhost, self.sdbname, self.sdbuser, self.password)


   def updateimlist(self, name, key, value):
       print "UPDATE:", name, key, value

   def updatespecview(self, name):
       name = str(name)
       print "UPDATING SPECVIEW with %s" % name
       specfile='./smbxp'+name.split('.fits')[0]+'.txt'
       warr, farr, snarr=np.loadtxt(specfile, usecols=(0,1,2), unpack=True)
       self.specTab.loaddata(warr, farr, snarr, name)
       self.specTab.redraw_canvas()

   def converttoname(self, infile): 
       """Given a file name, find the raw salt file name"""

   def updatetabs(self, infile):
       name=str(infile)
       imlist=self.obsdict[name]
       detmode=imlist[headerList.index('DETMODE')].strip().upper()
       obsmode=imlist[headerList.index('OBSMODE')].strip().upper()

       #update the information panel
       try:
           self.infoTab.update(name, self.obsdict[name])
           print "UPDATING tabs with %s" % name
       except Exception, e:
           print e
           return

       if self.thread.isRunning() and self.nothread:
           self.nothread=False

       #update the DQ tab
       try:
           self.dqTab.updatetab(name, self.obsdict[name])
           #self.dqTab=DQWidget(name, self.obsdict[name])
           #self.tabWidget.removeTab(1)
           #self.tabWidget.insertTab(1, self.dqTab, 'DQ')
       except Exception, e:
           print e
           return