Esempio n. 1
0
def spatial_scan(tag):
    """The main method loads the data from the disk (or compute them) and
    calls appropriate methods to find top discrepancy regions for `tag`."""
    print(tag)
    grid_size = GRID_SIZE
    background_name = u'mfreq/freq_{}_{}.mat'.format(grid_size, '_background')
    measured_name = u'mfreq/freq_{}_{}.mat'.format(grid_size, tag)
    res = []
    for tag, filename in [(None, background_name), (tag, measured_name)]:
        try:
            res.append(sio.loadmat(filename)['c'])
        except IOError:
            conn, client = get_connection()
            compute_frequency(conn,
                              tag,
                              BBOX,
                              FIRST_TIME,
                              LAST_TIME,
                              grid_size,
                              plot=False)
            client.close()
            res.append(sio.loadmat(filename)['c'])
    background, measured = res

    total_b = np.sum(background)
    total_m = np.sum(measured)
    if not total_m > 0:  # photos taken before 2008
        return
    if 0 < total_m <= 500:
        support = 20
    if 500 < total_m <= 2000:
        support = 40
    if 2000 < total_m:
        support = MAX_SUPPORT
    discrepancy = get_discrepancy_function(total_m, total_b, support)
    grid_dim = (grid_size, grid_size)
    top_loc = exact_grid(np.reshape(measured, grid_dim),
                         np.reshape(background, grid_dim), discrepancy, TOP_K,
                         GRID_SIZE / MAX_SIZE)
    info = u'\n{}: g={}, s={}, k={}, w={}, h={}, max={}'
    print(
        info.format(tag, GRID_SIZE, support, TOP_K, MIN_WIDTH, MIN_HEIGHT,
                    MAX_SIZE))
    # persistent.save_var(u'disc/top_{}'.format(tag), top_loc)
    # print('\n')
    # for v in top_loc:
    #     print('{:.4f}'.format(v[0]))
    #     print(top_loc[0][1].intersects(v[1]))
    plot_regions(merge_regions(top_loc), BBOX, tag)
Esempio n. 2
0
def spatial_scan(tag):
    """The main method loads the data from the disk (or compute them) and
    calls appropriate methods to find top discrepancy regions for `tag`."""
    print(tag)
    grid_size = GRID_SIZE
    background_name = u'mfreq/freq_{}_{}.mat'.format(grid_size, '_background')
    measured_name = u'mfreq/freq_{}_{}.mat'.format(grid_size, tag)
    res = []
    for tag, filename in [(None, background_name), (tag, measured_name)]:
        try:
            res.append(sio.loadmat(filename)['c'])
        except IOError:
            conn, client = get_connection()
            compute_frequency(conn, tag, BBOX, FIRST_TIME,
                              LAST_TIME, grid_size, plot=False)
            client.close()
            res.append(sio.loadmat(filename)['c'])
    background, measured = res

    total_b = np.sum(background)
    total_m = np.sum(measured)
    if not total_m > 0:  # photos taken before 2008
        return
    if 0 < total_m <= 500:
        support = 20
    if 500 < total_m <= 2000:
        support = 40
    if 2000 < total_m:
        support = MAX_SUPPORT
    discrepancy = get_discrepancy_function(total_m, total_b, support)
    grid_dim = (grid_size, grid_size)
    top_loc = exact_grid(np.reshape(measured, grid_dim),
                         np.reshape(background, grid_dim),
                         discrepancy, TOP_K, GRID_SIZE/MAX_SIZE)
    info = u'\n{}: g={}, s={}, k={}, w={}, h={}, max={}'
    print(info.format(tag, GRID_SIZE, support, TOP_K, MIN_WIDTH, MIN_HEIGHT,
                      MAX_SIZE))
    # persistent.save_var(u'disc/top_{}'.format(tag), top_loc)
    # print('\n')
    # for v in top_loc:
    #     print('{:.4f}'.format(v[0]))
    #     print(top_loc[0][1].intersects(v[1]))
    plot_regions(merge_regions(top_loc), BBOX, tag)
Esempio n. 3
0
def get_freq(tag):
    print(tag)
    mq.compute_frequency(DB.photos, tag, mq.SF_BBOX, sot, now, plot=False)
Esempio n. 4
0
def get_freq(tag):
    print(tag)
    mq.compute_frequency(DB.photos, tag, mq.SF_BBOX, sot, now, plot=False)