Beispiel #1
0
    def getTimeSeriesRow(self, xeniaDB, platformRec, rowEntryDate):
        recList = []
        #try:
        if (self.getObsData):
            dataRow = self.getObsData.next()
            if (self.lineNum > 0):
                for xeniaKey in self.difObsMap:
                    xeniaOb = self.difObsMap[xeniaKey]
                    if (len(xeniaOb)):
                        dataRec = multi_obs()
                        sOrder = 1
                        #The units are encoded into the column name, for example:
                        #sea_water_temperature (C)
                        obsParts = re.findall("^(\w*)\s\((.{1,})\)", xeniaKey)
                        #Get the xenia units. If we get None back, then we'll assume we're in the correct units.
                        uom = self.uomConverter.getXeniaUOMName(
                            obsParts[0][1].lower())
                        if (uom == None):
                            uom = obsParts[0][1].lower()

                        mTypeId = self.xeniaToDifMapping.getMtypeFromXenia(
                            xeniaOb)
                        for rec in platformRec.sensors:
                            if (mTypeId == rec.m_type_id):
                                dataRec.m_type_id = rec.m_type_id
                                dataRec.sensor_id = rec.row_id
                                break
                        if (dataRec.m_type_id and dataRec.sensor_id):
                            dataRec.m_date = self.getDateTime(dataRow)
                            dataRec.row_entry_date = rowEntryDate
                            dataRec.platform_handle = platformRec.platform_handle
                            dataRec.m_lon, dataRec.m_lat = self.getFixedLonLatValue(
                                dataRow)
                            dataRec.m_value = self.getDataValue(
                                xeniaKey, dataRow)
                            if (dataRec.m_value == None and self.logger):
                                self.logger.error("None data value returned.")
                            dataRec.m_z = self.getDepth(dataRow)
                            recList.append(dataRec)
                        else:
                            if (self.logger):
                                self.logger.error(
                                    "No m_type_id or sensor_id found for observation: %s"
                                    % (xeniaOb))
                self.lineNum += 1
            #No more rows to pull, so we return the empty list.
            #except StopIteration:
            #  return(recList)
        return (recList)
Beispiel #2
0
 def getTimeSeriesRow(self, xeniaDB, platformRec, rowEntryDate):
   recList = []
   #try:
   if(self.getObsData):
     dataRow = self.getObsData.next()
     if(self.lineNum > 0):        
       for xeniaKey in self.difObsMap:
         xeniaOb = self.difObsMap[xeniaKey] 
         if(len(xeniaOb)):
           dataRec = multi_obs()             
           sOrder = 1
           #The units are encoded into the column name, for example:
           #sea_water_temperature (C)
           obsParts = re.findall("^(\w*)\s\((.{1,})\)", xeniaKey)
           #Get the xenia units. If we get None back, then we'll assume we're in the correct units.
           uom = self.uomConverter.getXeniaUOMName(obsParts[0][1].lower())
           if(uom == None):
             uom = obsParts[0][1].lower()
           
           mTypeId = self.xeniaToDifMapping.getMtypeFromXenia(xeniaOb) 
           for rec in platformRec.sensors:
             if(mTypeId == rec.m_type_id):
               dataRec.m_type_id = rec.m_type_id
               dataRec.sensor_id = rec.row_id
               break
           if(dataRec.m_type_id and dataRec.sensor_id):
             dataRec.m_date = self.getDateTime(dataRow)
             dataRec.row_entry_date = rowEntryDate
             dataRec.platform_handle = platformRec.platform_handle            
             dataRec.m_lon,dataRec.m_lat = self.getFixedLonLatValue(dataRow)    
             dataRec.m_value = self.getDataValue(xeniaKey, dataRow)
             if(dataRec.m_value == None and self.logger):
               self.logger.error("None data value returned.")                
             dataRec.m_z = self.getDepth(dataRow)
             recList.append(dataRec)
           else:
             if(self.logger):
               self.logger.error("No m_type_id or sensor_id found for observation: %s" %(xeniaOb))
       self.lineNum += 1
     #No more rows to pull, so we return the empty list.
     #except StopIteration:
     #  return(recList)      
   return(recList)
Beispiel #3
0
  def saveData(self, recordList):
    for obs in recordList['multi_obs']:
      if(self.logger):
        """
        self.logger.debug('Sensor: %s(%d) Datetime: %s Value: %s SOrder: %d' %
                          (obs['obs_standard_name'],
                           self.sensorMappings[obs['obs_standard_name']][obs['uom']][obs['s_order']]['sensor_id'],
                          recordList['m_date'],
                          obs['m_value'],
                          obs['s_order']))
        """
      multiObsRec = multi_obs(row_entry_date=self.rowDate,
                              platform_handle=recordList['platform_handle'],
                              sensor_id=(self.sensorMappings[obs['obs_standard_name']][obs['uom']][obs['s_order']]['sensor_id']),
                              m_type_id=(self.sensorMappings[obs['obs_standard_name']][obs['uom']][obs['s_order']]['m_type_id']),
                              m_date=recordList['m_date'],
                              m_lon=recordList['m_lon'],
                              m_lat=recordList['m_lat'],
                              m_value=obs['m_value']
                              )
      self.dataQueue.put(multiObsRec)

    return
Beispiel #4
0
                     "Platform: %s Obs: %s value error val: %s"
                     % (platRec.short_name, xeniaObs,
                        recVal))
         else:
             #Use the m_type_id of the observation to find the sensor record and then the sensor_id.
             sensorId = None
             for rec in platRec.sensors:
                 if (mTypeId == rec.m_type_id):
                     sensorId = rec.row_id
                     break
             if (sensorId):
                 multiObsRec = multi_obs(
                     row_entry_date=self.rowEntryDate,
                     m_date=mDate,
                     platform_handle=platRec.
                     platform_handle,
                     sensor_id=sensorId,
                     m_type_id=mTypeId,
                     m_lon=lon,
                     m_lat=lat,
                     m_value=val)
                 dataRecs.append(multiObsRec)
             else:
                 if (self.logger):
                     self.logger.error(
                         "Platform: %s Xenia obs: %s is not present on platform: %s"
                         %
                         (platRec.short_name, xeniaObs,
                          platRec.short_name))
 else:
     if (self.logger):
         self.logger.error(
Beispiel #5
0
       except Exception,e:
         if(self.logger):
           self.logger.error("Platform: %s Obs: %s value error val: %s" % (platRec.short_name, xeniaObs, recVal))
       else:
         #Use the m_type_id of the observation to find the sensor record and then the sensor_id.
         sensorId = None
         for rec in platRec.sensors:
           if(mTypeId == rec.m_type_id):
             sensorId = rec.row_id
             break
         if(sensorId):  
           multiObsRec = multi_obs(row_entry_date=self.rowEntryDate,
                                   m_date=mDate,
                                   platform_handle=platRec.platform_handle,
                                   sensor_id=sensorId,
                                   m_type_id=mTypeId,
                                   m_lon=lon,
                                   m_lat=lat,
                                   m_value=val
                                   )
           dataRecs.append(multiObsRec)
         else:
           if(self.logger):
             self.logger.error("Platform: %s Xenia obs: %s is not present on platform: %s" % (platRec.short_name, xeniaObs,platRec.short_name))
   else:
     if(self.logger):
       self.logger.error("Platform: %s data is older than 24 hours: %s" % (platRec.short_name, mDate))                
 else:
   if(self.logger):
     self.logger.error("Platform: %s date value is null, not adding record." % (platRec.short_name))