def checkAvailableObs(self, id, stationProperty, platformRecs, sourceToXeniaMap, uomConverter, rowEntryDate): try: missingObsRec = None for platRec in platformRecs: if (platRec.active < 3): lcShortName = platRec.short_name.lower() lcplatformId = id.lower() if (lcShortName == lcplatformId): stationObs = self.difCap.getStationObservations( stationProperty, self.db, platRec.active, sourceToXeniaMap, uomConverter, rowEntryDate, platRec.row_id) newObs = [] for obs in stationObs: sOrder = 1 sensorExists = False for platObs in platRec.sensors: if (obs.m_type_id == platObs.m_type_id and obs.s_order == platObs.s_order): sensorExists = True #Observation exists, so remove it from the list. #stationObs.remove(obs) break if (sensorExists == False): newObs.append(obs) #If we have obs left in the list, we'll create a record and attach those obs. if (len(newObs)): missingObsRec = platform() missingObsRec.short_name = platRec.short_name missingObsRec.platform_handle = platRec.platform_handle missingObsRec.fixed_latitude = platRec.fixed_latitude missingObsRec.fixed_longitude = platRec.fixed_longitude missingObsRec.organization_id = platRec.organization_id missingObsRec.description = desc = platRec.description for obs in newObs: missingObsRec.sensors.append(obs) if (self.logger): self.logger.debug( "Platform: %s does not currently contain sensor: %s" % (platRec.platform_handle, obs.short_name)) break except Exception, e: if (self.logger): self.logger.exception(e)
def processNewPlatform(self, stationProperty, rowEntryDate, platformRecs): newRec = None try: id, entryType = self.difCap.getStationId(stationProperty) platHandle = "%s.%s.%s" % (self.organizationID, id, self.platformType) desc = self.difCap.getStationDescription(stationProperty) lon, lat = self.difCap.getFixedLonLat(stationProperty) if (self.logger): self.logger.info( "New Platform found. Id: %s Lon: %s Lat: %s Desc: %s" % (id, lon, lat, desc)) if (id == '8736163'): i = 0 if (desc != 'Glider'): newRec = platform() newRec.short_name = id newRec.platform_handle = platHandle newRec.row_entry_date = rowEntryDate newRec.fixed_latitude = lat newRec.fixed_longitude = lon newRec.organization_id = platformRecs[0].organization_id newRec.description = desc #If there is an end date, then the station is not online, so we'll mark our record as such. timePeriod = self.difCap.getStationTimePeriod(stationProperty) if (timePeriod.endPosition.text): newRec.active = 4 #Otherwise we set the status to inactive for the time being. else: newRec.active = 3 if (newRec): newRec.sensors = self.difCap.getStationObservations( stationProperty, self.db, newRec.active, self.xeniaDataMappings, self.uomConverter, rowEntryDate, None) else: if (self.logger): self.logger.debug( "Description field indicates a glider, not adding.") except Exception, e: if (self.logger): self.logger.exception(e)
def checkAvailableObs(self, id, stationProperty, platformRecs, sourceToXeniaMap, uomConverter, rowEntryDate): try: missingObsRec = None for platRec in platformRecs: if(platRec.active < 3): lcShortName = platRec.short_name.lower() lcplatformId = id.lower() if(lcShortName == lcplatformId): stationObs = self.difCap.getStationObservations(stationProperty, self.db, platRec.active, sourceToXeniaMap, uomConverter, rowEntryDate, platRec.row_id) newObs = [] for obs in stationObs: sOrder = 1 sensorExists = False for platObs in platRec.sensors: if(obs.m_type_id == platObs.m_type_id and obs.s_order == platObs.s_order): sensorExists = True #Observation exists, so remove it from the list. #stationObs.remove(obs) break if(sensorExists == False): newObs.append(obs) #If we have obs left in the list, we'll create a record and attach those obs. if(len(newObs)): missingObsRec = platform() missingObsRec.short_name = platRec.short_name missingObsRec.platform_handle = platRec.platform_handle; missingObsRec.fixed_latitude = platRec.fixed_latitude missingObsRec.fixed_longitude = platRec.fixed_longitude missingObsRec.organization_id = platRec.organization_id missingObsRec.description = desc = platRec.description for obs in newObs: missingObsRec.sensors.append(obs) if(self.logger): self.logger.debug("Platform: %s does not currently contain sensor: %s" %(platRec.platform_handle,obs.short_name)) break except Exception, e: if(self.logger): self.logger.exception(e)
def processNewPlatform(self, stationProperty, rowEntryDate, platformRecs): newRec = None try: id,entryType = self.difCap.getStationId(stationProperty) platHandle = "%s.%s.%s" % (self.organizationID, id, self.platformType) desc = self.difCap.getStationDescription(stationProperty) lon,lat = self.difCap.getFixedLonLat(stationProperty) if(self.logger): self.logger.info("New Platform found. Id: %s Lon: %s Lat: %s Desc: %s" % (id, lon, lat, desc)) if(id == '8736163'): i=0 if(desc != 'Glider'): newRec = platform() newRec.short_name = id newRec.platform_handle = platHandle; newRec.row_entry_date = rowEntryDate newRec.fixed_latitude = lat newRec.fixed_longitude = lon newRec.organization_id = platformRecs[0].organization_id newRec.description = desc #If there is an end date, then the station is not online, so we'll mark our record as such. timePeriod = self.difCap.getStationTimePeriod(stationProperty) if(timePeriod.endPosition.text): newRec.active = 4 #Otherwise we set the status to inactive for the time being. else: newRec.active = 3 if(newRec): newRec.sensors = self.difCap.getStationObservations(stationProperty, self.db, newRec.active, self.xeniaDataMappings, self.uomConverter, rowEntryDate, None) else: if(self.logger): self.logger.debug("Description field indicates a glider, not adding.") except Exception, e: if(self.logger): self.logger.exception(e)