Exemple #1
0
def guidertable(els, mintime, maxtime):
   """Extract the guider data from the els"""
   #extract the guider data from the els
   sel_cmd='_timestamp_, guidance_available, ee50, mag50'
   tab_cmd='tpc_guidance_status__timestamp '
   log_cmd="_timestamp_>'%s' and _timestamp_<'%s'" % (mintime, maxtime)
   gui_rec=saltmysql.select(els, sel_cmd, tab_cmd, log_cmd)
   if len(gui_rec)<2:  return None


   gtime_list=[]
   ee50_arr=np.zeros(len(gui_rec))
   mag50_arr=np.zeros(len(gui_rec))
   avail_list=[]
   for i in range(len(gui_rec)):
       gtime_list.append(gui_rec[i][0])
       ee50_arr[i]=gui_rec[i][2]
       mag50_arr[i]=gui_rec[i][3]
       avail_list.append(gui_rec[i][1])
   avail_arr=(np.array(avail_list)=='T')

   #write the results to a fits table
   guicol=[]
   guicol.append(pyfits.Column(name='Timestamp', format='20A', array=gtime_list))
   guicol.append(pyfits.Column(name='Available', format='L', array=avail_arr ))
   guicol.append(pyfits.Column(name='EE50', format='F', array=ee50_arr ))
   guicol.append(pyfits.Column(name='mag50', format='F', array=mag50_arr ))

   guitab= saltio.fitscolumns(guicol)
   guihdu= pyfits.new_table(guitab)
   guihdu.name='Guider'
   return guihdu
Exemple #2
0
def seeingtable(sdb, mintime, maxtime):
   #extract the seeing data from the sdb
   sel_cmd='DateTime, Mass, Dimm'
   tab_cmd='MassDimm'
   log_cmd="DateTime>'%s' and DateTime<'%s'" % (mintime, maxtime)
   see_rec=saltmysql.select(sdb, sel_cmd, tab_cmd, log_cmd)
   if len(see_rec)<2:  return None

   stime_list=[]
   mass_arr=np.zeros(len(see_rec))
   dimm_arr=np.zeros(len(see_rec))
   for i in range(len(see_rec)):
       stime_list.append(see_rec[i][0])
       mass_arr[i]=see_rec[i][1]
       dimm_arr[i]=see_rec[i][2]
 
   seecol=[]
   seecol.append(pyfits.Column(name='Timestamp', format='20A', array=stime_list))
   seecol.append(pyfits.Column(name='MASS', format='F', array=mass_arr ))
   seecol.append(pyfits.Column(name='DIMM', format='F', array=dimm_arr ))

   seetab= saltio.fitscolumns(seecol)
   seehdu= pyfits.new_table(seetab)
   seehdu.name='Seeing'
   return seehdu
Exemple #3
0
def createobslogfits(headerDict):
   """Create the fits table for the observation log"""
   # define generic columns of output table
   col=[]
   for k, f in zip(headerList, formatList):
       print k,f, headerDict[k]
       col.append(pyfits.Column(name=k, format=f, array=headerDict[k]))
   for k, f in zip(scamheaderList, scamformatList):
       print k,f, headerDict[k]
       col.append(pyfits.Column(name=k, format=f, array=headerDict[k]))
   for k, f in zip(rssheaderList, rssformatList):
       print k,f, headerDict[k]
       col.append(pyfits.Column(name=k, format=f, array=headerDict[k]))
   # construct FITS table from columns
   table = saltio.fitscolumns(col)

   # write FITS table to output file
   struct=saltio.newfitstable(table)

   # name the table extension
   saltkey.new('EXTNAME','OBSLOG','extension name', struct)

   # housekeeping keywords
   saltkey.put('SAL-TLM',time.asctime(time.localtime()), struct)

   return struct
Exemple #4
0
def weathertable(els, mintime, maxtime):
   """Creates the weather table from the data in the els
   """
   #now extact weather information from the els
   sel_cmd='_timestamp_, air_pressure, dewpoint, rel_humidity, wind_mag_30m, wind_dir_30m, wind_mag_10m, wind_dir_10m, temperatures, rain_detected'
   tab_cmd='bms_external_conditions__timestamp'
   log_cmd="_timestamp_>'%s' and _timestamp_<'%s'" % (mintime, maxtime)
   wea_rec=saltmysql.select(els, sel_cmd, tab_cmd, log_cmd)
   if len(wea_rec)<2:  return None

   time_list=[]
   air_arr=np.zeros(len(wea_rec))
   dew_arr=np.zeros(len(wea_rec))
   hum_arr=np.zeros(len(wea_rec))
   w30_arr=np.zeros(len(wea_rec))
   w30d_arr=np.zeros(len(wea_rec))
   w10_arr=np.zeros(len(wea_rec))
   w10d_arr=np.zeros(len(wea_rec))
   t02_arr=np.zeros(len(wea_rec))
   t05_arr=np.zeros(len(wea_rec))
   t10_arr=np.zeros(len(wea_rec))
   t15_arr=np.zeros(len(wea_rec))
   t20_arr=np.zeros(len(wea_rec))
   t25_arr=np.zeros(len(wea_rec))
   t30_arr=np.zeros(len(wea_rec))

   for i in range(len(wea_rec)):
       time_list.append(str(wea_rec[i][0]))
       air_arr[i]=wea_rec[i][1]
       dew_arr[i]=wea_rec[i][2]
       hum_arr[i]=wea_rec[i][3]
       w30_arr[i]=wea_rec[i][4]
       w30d_arr[i]=wea_rec[i][5]
       w10_arr[i]=wea_rec[i][6]
       w10d_arr[i]=wea_rec[i][7]
       t_arr=converttemperature(wea_rec[i][8])
       t02_arr[i]=t_arr[0]       
       t05_arr[i]=t_arr[1]       
       t10_arr[i]=t_arr[2]       
       t15_arr[i]=t_arr[3]       
       t20_arr[i]=t_arr[4]       
       t25_arr[i]=t_arr[5]       
       t30_arr[i]=t_arr[6]       
   weacol=[]
   weacol.append(pyfits.Column(name='TimeStamp', format='20A', array=time_list ))
   weacol.append(pyfits.Column(name='Air Pressure', format='F', array=air_arr ))
   weacol.append(pyfits.Column(name='Dew Point', format='F', array=dew_arr ))
   weacol.append(pyfits.Column(name='Humidy', format='F', array=hum_arr ))
   weacol.append(pyfits.Column(name='Wind 30m', format='F', array=w30_arr ))
   weacol.append(pyfits.Column(name='Wind 30m Direction', format='F', array=w30d_arr ))
   weacol.append(pyfits.Column(name='Wind 10m', format='F', array=w10_arr ))
   weacol.append(pyfits.Column(name='Wind 10m Direction', format='F', array=w10d_arr ))
   weacol.append(pyfits.Column(name='Temperature  2m', format='F', array=t02_arr ))
   weacol.append(pyfits.Column(name='Temperature  5m', format='F', array=t05_arr ))
   weacol.append(pyfits.Column(name='Temperature 10m', format='F', array=t10_arr ))
   weacol.append(pyfits.Column(name='Temperature 15m', format='F', array=t15_arr ))
   weacol.append(pyfits.Column(name='Temperature 20m', format='F', array=t20_arr ))
   weacol.append(pyfits.Column(name='Temperature 25m', format='F', array=t25_arr ))
   weacol.append(pyfits.Column(name='Temperature 30m', format='F', array=t30_arr ))

   weatab= saltio.fitscolumns(weacol)
   weahdu = pyfits.new_table(weatab)
   weahdu.name='Weather'
   return weahdu