def cluster_cells(cells, lookups, min_age=0): """ Cluster cells by area. """ now = util.utcnow() today = now.date() # Create a dict of cell ids mapped to their age and signal strength. obs_data = {} for lookup in lookups: obs_data[decode_cellid(lookup.cellid)] = ( max(abs(lookup.age or min_age), 1000), lookup.signalStrength or MIN_CELL_SIGNAL[lookup.radioType]) areas = defaultdict(list) for cell in cells: areas[area_id(cell)].append(cell) clusters = [] for area_cells in areas.values(): clusters.append(numpy.array([( cell.lat, cell.lon, cell.radius, obs_data[cell.cellid][0], obs_data[cell.cellid][1], station_score(cell, now), encode_cellid(*cell.cellid), bool(cell.last_seen >= today)) for cell in area_cells], dtype=NETWORK_DTYPE)) return clusters
def cluster_cells(cells, lookups, min_age=0): """ Cluster cells by area. """ now = util.utcnow() today = now.date() # Create a dict of cell ids mapped to their age and signal strength. obs_data = {} for lookup in lookups: obs_data[decode_cellid(lookup.cellid)] = (max( abs(lookup.age or min_age), 1000), lookup.signalStrength or MIN_CELL_SIGNAL[lookup.radioType]) areas = defaultdict(list) for cell in cells: areas[area_id(cell)].append(cell) clusters = [] for area_cells in areas.values(): clusters.append( numpy.array( [(cell.lat, cell.lon, cell.radius, obs_data[cell.cellid][0], obs_data[cell.cellid][1], station_score(cell, now), encode_cellid(*cell.cellid), bool(cell.last_seen >= today)) for cell in area_cells], dtype=NETWORK_DTYPE)) return clusters
def base_key(self): radio, mcc, mnc, lac, cid = decode_cellid(self.station_key) return { 'cellid': self.station_key, 'radio': radio, 'mcc': mcc, 'mnc': mnc, 'lac': lac, 'cid': cid, }
def base_key(self): radio, mcc, mnc, lac, cid = decode_cellid(self.station_key) return { "cellid": self.station_key, "radio": radio, "mcc": mcc, "mnc": mnc, "lac": lac, "cid": cid, }
def _base_station_values(self, station_key, observations): radio, mcc, mnc, lac, cid = decode_cellid(station_key) if observations: psc = observations[-1].psc return { 'cellid': station_key, 'radio': radio, 'mcc': mcc, 'mnc': mnc, 'lac': lac, 'cid': cid, 'psc': psc, 'modified': self.utcnow, }
def add_area_update(self, key): self.updated_areas.add(encode_cellarea(*decode_cellid(key)[:4]))
def check_areas(self, celery, obs): queue = celery.data_queues["update_cellarea"] queued = set(queue.dequeue()) cellids = [decode_cellid(ob.unique_key) for ob in obs] areaids = set([encode_cellarea(*cellid[:4]) for cellid in cellids]) assert queued == areaids
def check_areas(self, celery, obs): queue = celery.data_queues['update_cellarea'] queued = set(queue.dequeue()) cellids = [decode_cellid(ob.unique_key) for ob in obs] areaids = set([encode_cellarea(*cellid[:4]) for cellid in cellids]) assert queued == areaids
def add_area_update(self, updated_areas, key): updated_areas.add(encode_cellarea(*decode_cellid(key)[:4]))