Exemple #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()
Exemple #2
0
def download_simulation(i, typ, com_s):
    name_out = './maps/dx12_v3_{}_{}_mc_{:05d}_raw.fits'.format(com_s, typ, i)

    if os.path.exists(name_out):
        x = os.path.getsize(name_out)
        if x != 603987840:
            print(name_out, 'is corrupted!')
            os.remove(name_out)

    if not os.path.exists(name_out):
        ch_mkdir('maps')
        global TOTALSIZE
        TOTALSIZE = 100 / (589836 * 1024)
        name_in = 'http://pla.esac.esa.int/pla/aio/product-action?SIMULATED_MAP.FILE_ID=dx12_v3_{}_{}_mc_{:05d}_raw.fits'.format(
            com_s, typ, i)
        download(name_in, name_out, report=report)
    else:
        print(name_out, 'exist!')
    return name_out
Exemple #3
0
#                dl1.append(ll[j]*(ll[j]+1)*cl[j]/(2*np.pi))
#                dl2.append(ll[j]*(ll[j]+1)*cl_map[j]/(2*np.pi))

#        plt.plot(ll,dl2,'r--',label='Simulation')
#        plt.plot(ll,dl1,'b--',lw=2,label='Orginal')
#        plt.xscale('log')
#        plt.yscale('log')
#        plt.tick_params(labelsize=15)
#        plt.xlabel(r'$\ell$',fontsize=25)
#        plt.ylabel(r'$D_{\ell}$',fontsize=25)

#        plt.legend(loc='best',fontsize=20)
#        plt.savefig('../data/healpix/power_'+str(nside)+'_'+str(i)+'.jpg')
#        plt.close()

ch_mkdir('../data/string/')

for i in range(n_string):
    strnum = str(i + 1)
    if nside == 4096:
        strnum = strnum + 'b'
    if not os.path.exists('../data/string/map1n_allz_rtaapixlw_' + str(nside) +
                          '_' + str(i + 1) + '.fits.' + ex):
        print('Downloading string: ' + str(i))
        download(
            'http://cp3.irmp.ucl.ac.be/~ringeval/upload/data/' + str(nside) +
            '/map1n_allz_rtaapixlw_' + str(nside) + '_' + strnum + '.fits.' +
            ex, '../data/string/map1n_allz_rtaapixlw_' + str(nside) + '_' +
            str(i + 1) + '.fits.' + ex)

    load_status = 0
Exemple #4
0
import os
import sys
import glob
from time import time
import numpy as np
import pylab as plt
import ccgpack as ccg
from scipy import stats

cmap = plt.cm.jet
cmap.set_under('w')
cmap.set_bad('gray', 0.)

add = 'processed_images/'
ccg.ch_mkdir(add)

gmulist = [0] + list(5 * 10**np.linspace(-8, -5, 10))
ngmu = len(gmulist)
s2n = 10.

i_map = int(sys.argv[1])
i_srg = int(sys.argv[2])
i_gmup = int(sys.argv[3])


def blocker(arr, nrows, ncols):
    h, w = arr.shape
    return (arr.reshape(h // nrows, nrows, -1,
                        ncols).swapaxes(1, 2).reshape(-1, nrows, ncols))
Exemple #5
0
 def init_dirs(self):
     ch_mkdir(self.prefix)
     ch_mkdir(self.prefix + 'model')
     ch_mkdir(self.prefix + 'images')
Exemple #6
0
    def filtf(x):
        return ccg.filters(x, edd_method='sch')


dp = DataProvider(x_files,
                  y_files,
                  alpha,
                  nx=nx,
                  ny=ny,
                  n_buffer=2,
                  reload_rate=10000,
                  filt=filtf)

model_add = './models/' + str(n_layers) + '_layers_f' + filt + '/'
res_dir = './results/' + str(n_layers) + '_layers_f' + filt + '/'
ccg.ch_mkdir(res_dir + 'plots')
model = ng.Model(dp, restore=0, model_add=model_add + str(0), arch=arch)

print('# of variables:', model.n_variables)

if os.path.exists(res_dir + 'info.npy'):
    i, dp.alpha, dalpha, learning_rate = np.load(res_dir + 'info.npy')
    i = int(i)
    model.model_add = model_add + str(i)
    print('Loading model ' + str(i) + ' ...')
    model.restore()
else:
    i = 0

for _ in range(ntry):
def p_value(lst):
    p_valu = []
    num = len(lst)
    for i in range(num):
        class1 = lst[i]
	pvs = []
	for j in range(num):
	    if i!=j:
	        class2 = lst[j]
                t , p = stats.ttest_ind(class1 , class2)
	        pvs.append(p)
        p_valu.append(np.max(pvs))
    return np.array(p_valu)

ccg.ch_mkdir('../classic')  

gmulist = [0]+list(10**np.linspace(-8 , -5 , 10))
# IN CASE YOU WANT TO RUN IT parallel
#igmu = int(sys.argv[1])
#gmulist = gmulist[igmu:igmu+1]
ngmu = len(gmulist)

tadd = '../data/test_set/healpix_p/'
sim_name = tadd.split('/')[3]
res_add = '../classic/'+sim_name+'/'
ccg.ch_mkdir(res_add)

print('Buiding classical method results:')
for j,gmu in enumerate(gmulist):
    dir_name = '{:3.2e}'.format(gmu)
import os
import sys
from glob import glob
from time import time
import numpy as np
import pylab as plt
import ccgpack as ccg
from scipy import stats

cmap = plt.cm.jet
cmap.set_under('w')
cmap.set_bad('gray', 0.)

add = 'processed_images/'
ccg.ch_mkdir(add)

add = 'processed_images/curveleted/'
if os.path.exists(add + 'observations.npy'):
    exit()
ccg.ch_mkdir(add)


def blocker(arr, nrows, ncols):
    h, w = arr.shape
    return (arr.reshape(h // nrows, nrows, -1,
                        ncols).swapaxes(1, 2).reshape(-1, nrows, ncols))


res = {}