Ejemplo n.º 1
0
try:
    params = numpy.loadtxt(optfolder + '/params.txt')
    kerror, perror = numpy.loadtxt(optfolder + '/error_ps.txt', unpack=True)
except Exception as e:
    mock_model_setup = map.MockModel(dynamic_model,
                                     rsdpos=rsdpos,
                                     rsdfac=rsdfac)
    fpos, linear, linearsq, shear = mock_model_setup.get_code().compute(
        ['xp', 'linear', 'linearsq', 'shear'], init={'parameters': s_truth})
    grid = truth_pm.generate_uniform_particle_grid(shift=0.0, dtype='f4')
    params, bmod = getbias(truth_pm, hmesh, [linear, linearsq, shear], fpos,
                           grid)
    title = ['%0.3f' % i for i in params]
    kerror, perror = eval_bfit(hmesh,
                               bmod,
                               optfolder,
                               noise=noise,
                               title=title,
                               fsize=15)
    if rank == 0:
        numpy.savetxt(optfolder + '/params.txt', params, header='b1, b2, bsq')
        numpy.savetxt(optfolder + '/error_ps.txt',
                      numpy.array([kerror, perror]).T,
                      header='kerror, perror')
##mock_model_setup = map.MockModel(dynamic_model, rsdpos=rsdpos, rsdfac=rsdfac)
##fpos, linear, linearsq, shear = mock_model_setup.get_code().compute(['xp', 'linear', 'linearsq', 'shear'], init={'parameters': s_truth})
##grid = truth_pm.generate_uniform_particle_grid(shift=0.0, dtype='f4')
##params, bmod = getbias(truth_pm, hmesh, [linear, linearsq, shear], fpos, grid)
##title = ['%0.3f'%i for i in params]
##kerror, perror = eval_bfit(hmesh, bmod, optfolder, noise=noise, title=title, fsize=15)

ipkerror = interp1d(kerror,
Ejemplo n.º 2
0
except Exception as e:
    mock_model_setup = map.MockModel(dynamic_model,
                                     rsdpos=rsdpos,
                                     rsdfac=rsdfac)
    fpos, linear, linearsq, shear = mock_model_setup.get_code().compute(
        ['xp', 'linear', 'linearsq', 'shear'], init={'parameters': s_truth})
    grid = truth_pm.generate_uniform_particle_grid(shift=0.0, dtype='f8')
    params, bmod = getbias(truth_pm, hmesh, [linear, linearsq, shear], fpos,
                           grid)
    if rank == 0:
        numpy.savetxt(optfolder + '/params.txt', params, header='b1, b2, bsq')
    title = ['%0.3f' % i for i in params]
    kerror, perror = eval_bfit(hmesh,
                               bmod,
                               optfolder,
                               noise=noise,
                               title=title,
                               fsize=15)
    if rank == 0:
        numpy.savetxt(optfolder + '/error_ps.txt',
                      numpy.array([kerror, perror]).T,
                      header='kerror, perror')

    if stage2:
        ipkmodel = interp1d(kerror,
                            perror,
                            bounds_error=False,
                            fill_value=(perror[0], perror[-1]))
        ivarmesh = truth_noise_model.get_ivarmesh(data_p, ipkmodel)
        FieldMesh(ivarmesh).save(optfolder + 'ivarmesh',
                                 dataset='ivar',
Ejemplo n.º 3
0

try: fit_p = map.Observable.load(optfolder+'/fitp_up')
except:
    fit_p = mock_model.make_observable(s_truth)
    fit_p.save(optfolder+'fitp_up/')


title = None
if stage2 is not None: 
    try:
        kerror, perror = numpy.loadtxt(optfolder + '/error_psnup.txt', unpack=True)
        ivarmesh = BigFileMesh(optfolder + 'ivarmesh_up', 'ivar').paint()
        ipkerror = interp1d(kerror, perror, bounds_error=False, fill_value=(perror[0], perror[-1]))
    except:
        kerror, perror = eval_bfit(data_n.mapp, fit_p.mapp, optfolder, noise=noise, title=title, fsize=15, suff='-noiseup')        
        ipkerror = interp1d(kerror, perror, bounds_error=False, fill_value=(perror[0], perror[-1]))
        if rank ==0: numpy.savetxt(optfolder + '/error_psnup.txt', numpy.array([kerror, perror]).T, header='kerror, perror')

        kerror, perror = eval_bfit(data_p.mapp, fit_p.mapp, optfolder, noise=noise, title=title, fsize=15, suff='-up')        
        ipkmodel = interp1d(kerror, perror, bounds_error=False, fill_value=(perror[0], perror[-1]))
        ivarmesh = truth_noise_model.get_ivarmesh(data_p, ipkmodel)
        FieldMesh(ivarmesh).save(optfolder+'ivarmesh_up', dataset='ivar', mode='real')
else: 
    ivarmesh = None
    try:
        kerror, perror = numpy.loadtxt(optfolder + '/error_psup.txt', unpack=True)
        ipkerror = interp1d(kerror, perror, bounds_error=False, fill_value=(perror[0], perror[-1]))
    except:
        pkerror = FFTPower(data_p.mapp, second=-1* fit_p.mapp, mode='1d').power
        kerror, perror = pkerror['k'], pkerror['power']