Exemplo n.º 1
0
def Regrid_PS(PS1, Corners):
    dim1, dim2 = Corners.shape[1:]
    dim1 -= 1
    dim2 -= 1
    global px, py
    px, py = np.where(PS1)
    global squares
    squares = np.array(Make_squares(Corners))
    square_num = np.arange(0, len(squares))

    points = np.zeros((len(px), 2))
    points[:, 0] = px
    points[:, 1] = py

    global pspixels
    pspixels = Footprint_square(Corners, points)

    global psimage
    psimage = PS1.copy()

    pool = MultiPool()
    values = list(pool.map(Pix_sum, square_num))
    pool.close()

    PS_scene = np.array(values)
    PS_scene = np.nansum(PS_scene, axis=0)
    PS_scene = PS_scene.astype('float')
    PS_scene = PS_scene.reshape(dim1, dim2)
    return PS_scene
Exemplo n.º 2
0
    print("loading pair indices...")
    pairs_start = time.time()
    pairs_file = '../data/matched-pairs-dustin.fits'
    pairs = read_from_fits(pairs_file)  # pairs is a global variable
    print("loading pairs array took {0} s".format(time.time() - pairs_start))

    print("calculating chisquared...")
    with h5py.File('chisqs.hdf5', 'w') as f:
        dset = f.create_dataset('chisqs', data=np.zeros_like(pairs) - 1)

    #tasks = list(zip(range(len(table)), table.iterrows()))
    tasks = list(zip(range(10000), pairs[:10000, :]))

    pool = MultiPool()
    map_start = time.time()
    results = pool.map(worker, tasks, callback=callback)
    map_end = time.time()
    print("mapping took {0} s".format(map_end - map_start))
    pool.close()

    with h5py.File('chisqs.hdf5', 'r+') as f:
        chisqs = np.copy(f['chisqs'])

    chisqs2 = calc_chisqs_for_table(table, pairs[:10000, :])

    if False:  # basic diagnostics
        print("chisqareds calculated, checking on matches...")
        plt.hist(chisqs[(chisqs > 0.) & (chisqs < 50.)], bins=500)
        plt.xlabel('$\chi^2$', fontsize=16)
        plt.ylabel('# Pairs', fontsize=16)
        plt.yscale('log')