Example #1
0
def build_map(inmap,
              output,
              i,
              ntot,
              ns=1,
              g=0,
              sml=5.,
              lmax=3 * 2048,
              prefix=''):
    ch_mkdir(dest)
    dont = 1
    npatch = 12 * ns**2
    for j in range(npatch):
        if not os.path.exists(output + prefix + str(i * npatch + j) + '.npy'):
            dont = 0
    if dont:
        return

    if sml != 0:
        s = hp.read_map(inmap, nest=0, verbose=0)
        if g:
            s = kelvin_check(s)
        s = hp.smoothing(s, np.radians(sml / 60.), lmax=lmax, verbose=0)
        s = hp.reorder(s, r2n=1)
    else:
        s = hp.read_map(inmap, nest=1, verbose=0)
    patches = sky2patch(s, ns)
    for j in range(npatch):
        pop_percent(i * npatch + j, ntot * npatch)
        np.save(output + prefix + str(i * npatch + j), patches[j])
        plt.imshow(patches[j], cmap=cmap)
        plt.savefig(output + prefix + str(i * npatch + j) + '.jpg')
        plt.close()
Example #2
0
for i in range(n_test):
    nsp = np.random.normal(0, gstd / s2n, nshape)
    ptch = gp[j] + gm * sp[j] + nsp
    np.save(tadd + dir_name + '/' + str(i * 48 + j), ptch)
    plt.imshow(ptch, cmap=cmap)
    plt.savefig(tadd + dir_name + '/' + str(i * 48 + j) + '.jpg')
    plt.close()
print('d!')

print('Buiding classical method results:')
for j, gmu in enumerate(gmulist):
    dir_name = '{:3.2e}'.format(gmu)
    add = tadd + dir_name + '/'
    stds = []
    for i in range(480):
        ccg.pop_percent(j * 480 + i, 480 * ngmu)
        m = np.load(add + str(i) + '.npy')
        m = ccg.curvelet(m, r_scale=7)
        m = ccg.filters(m, edd_method='sch')
        std = np.std(m)
        stds.append(std)
    np.save(res_add + dir_name, stds)

lst1 = []
for gmu in gmulist:
    dir_name = '{:3.2e}'.format(gmu)
    var_file = res_add + dir_name + '.npy'
    lst1.append(np.load(var_file))
lst1 = np.array(lst1)

result = p_value(lst1)