コード例 #1
0
ファイル: cell.py プロジェクト: crankycoder/ichnaea
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
コード例 #2
0
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
コード例 #3
0
ファイル: station.py プロジェクト: crankycoder/ichnaea
 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,
     }
コード例 #4
0
 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,
     }
コード例 #6
0
ファイル: station.py プロジェクト: ingle/ichnaea
 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,
     }
コード例 #7
0
ファイル: station.py プロジェクト: amolk4games/ichnaea
 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,
     }
コード例 #8
0
ファイル: station.py プロジェクト: ingle/ichnaea
 def add_area_update(self, key):
     self.updated_areas.add(encode_cellarea(*decode_cellid(key)[:4]))
コード例 #9
0
ファイル: test_station.py プロジェクト: uvinduperera/ichnaea
 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
コード例 #10
0
ファイル: test_station.py プロジェクト: crankycoder/ichnaea
 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
コード例 #11
0
ファイル: station.py プロジェクト: amolk4games/ichnaea
 def add_area_update(self, updated_areas, key):
     updated_areas.add(encode_cellarea(*decode_cellid(key)[:4]))