コード例 #1
0
ファイル: test_xi_vs_snr.py プロジェクト: WhiteSymmetry/DESWL
def get_weights():

    import homogenise_nz

    res = load_data()

    list_snr_bins_cats = []

    for isb,snr_bin in enumerate(config['snr_bins']):

        select = (res['SNR'] > snr_bin[0]) & (res['SNR'] < snr_bin[1]) 
        res_bin = res[select]
        res_bin_z = (res_bin['photoz'], res_bin['w'])

        list_snr_bins_cats.append(res_bin_z)

    label = 'snr.%s' % config['method']
    list_weights = homogenise_nz.get_weights(list_snr_bins_cats,target_nz_index=0,label=label,photoz_min=0.3,photoz_max=1.3,plots=True)


    import cPickle as pickle
    filename_pickle = 'weights.%s.pp2' % (config['method'])
    pickle.dump(list_weights,open(filename_pickle,'w'))
    print 'saved ', filename_pickle

    import pdb; pdb.set_trace()
    pl.show()
コード例 #2
0
def get_weights():

    import homogenise_nz

    res = load_data()

    list_snr_bins_cats = []

    for isb, snr_bin in enumerate(config['snr_bins']):

        select = (res['SNR'] > snr_bin[0]) & (res['SNR'] < snr_bin[1])
        res_bin = res[select]
        res_bin_z = (res_bin['photoz'], res_bin['w'])

        list_snr_bins_cats.append(res_bin_z)

    label = 'snr.%s' % config['method']
    list_weights = homogenise_nz.get_weights(list_snr_bins_cats,
                                             target_nz_index=0,
                                             label=label,
                                             photoz_min=0.3,
                                             photoz_max=1.3,
                                             plots=True)

    import cPickle as pickle
    filename_pickle = 'weights.%s.pp2' % (config['method'])
    pickle.dump(list_weights, open(filename_pickle, 'w'))
    print 'saved ', filename_pickle

    import pdb
    pdb.set_trace()
    pl.show()
ra_modest_errorflag_infoflag_spte_zcut_airmass_upper = ra_modest_errorflag_infoflag_spte_zcut[include_upper]
dec_modest_errorflag_infoflag_spte_zcut_airmass_upper = dec_modest_errorflag_infoflag_spte_zcut[include_upper]
e1_modest_errorflag_infoflag_spte_zcut_airmass_upper = e1_modest_errorflag_infoflag_spte_zcut[include_upper]
e2_modest_errorflag_infoflag_spte_zcut_airmass_upper = e2_modest_errorflag_infoflag_spte_zcut[include_upper]
c1_modest_errorflag_infoflag_spte_zcut_airmass_upper = c1_modest_errorflag_infoflag_spte_zcut[include_upper]
c2_modest_errorflag_infoflag_spte_zcut_airmass_upper = c2_modest_errorflag_infoflag_spte_zcut[include_upper]
m_modest_errorflag_infoflag_spte_zcut_airmass_upper  = m_modest_errorflag_infoflag_spte_zcut[include_upper]
w_modest_errorflag_infoflag_spte_zcut_airmass_upper  = w_modest_errorflag_infoflag_spte_zcut[include_upper]
z_modest_errorflag_infoflag_spte_zcut_airmass_upper  = z_modest_errorflag_infoflag_spte_zcut[include_upper]

a = plt.hist(z_modest_errorflag_infoflag_spte_zcut_airmass_lower,200); X = np.zeros([200,2]); binsx = a[1]; bins = (binsx[0:-1]+binsx[1:])/2.0; X[:,0] = bins; X[:,1] = a[0]/np.sum(a[0]); np.savetxt('/Users/drgk/DES/data/systematics/nz_v7_r_airmass_lower_zmin03_zmax13.dat',X,delimiter =' ')
a = plt.hist(z_modest_errorflag_infoflag_spte_zcut_airmass_upper,200); X = np.zeros([200,2]); binsx = a[1]; bins = (binsx[0:-1]+binsx[1:])/2.0; X[:,0] = bins; X[:,1] = a[0]/np.sum(a[0]); np.savetxt('/Users/drgk/DES/data/systematics/nz_v7_r_airmass_upper_zmin03_zmax13.dat',X,delimiter =' ')

list_split = [ (z_modest_errorflag_infoflag_spte_zcut,w_modest_errorflag_infoflag_spte_zcut), (z_modest_errorflag_infoflag_spte_zcut_airmass_upper,w_modest_errorflag_infoflag_spte_zcut_airmass_upper) , (z_modest_errorflag_infoflag_spte_zcut_airmass_lower,w_modest_errorflag_infoflag_spte_zcut_airmass_lower) ]

list_nz_weights = homogenise_nz.get_weights(list_split,target_nz_index=0,photoz_min=0.3,photoz_max=1.3,photoz_nbins=50)
nz_weight_bin0 = list_nz_weights[0] # these should be all one (or very close) as we used this bin as a target n(z)
nz_weight_bin1 = list_nz_weights[1]
nz_weight_bin2 = list_nz_weights[2]

# ## Upper Airmass Catalogue
f = open('/Users/drgk/DES/SV_tests/athena_cats/im3shape_v7_r_shears_airmass_r_upper.dat','w')
g = open('/Users/drgk/DES/SV_tests/athena_cats/im3shape_v7_r_m_airmass_r_upper.dat','w')

for i in range(0,len(ra_modest_errorflag_infoflag_spte_zcut_airmass_upper)):
	print str(100*(i+1)/float(len(ra_modest_errorflag_infoflag_spte_zcut_airmass_upper)))+' percent complete: shear Airmass Upper'

	ra = ra_modest_errorflag_infoflag_spte_zcut_airmass_upper[i]
	dec = dec_modest_errorflag_infoflag_spte_zcut_airmass_upper[i]
	e1 = e1_modest_errorflag_infoflag_spte_zcut_airmass_upper[i] - c1_modest_errorflag_infoflag_spte_zcut_airmass_upper[i]
	e2 = e2_modest_errorflag_infoflag_spte_zcut_airmass_upper[i] - c2_modest_errorflag_infoflag_spte_zcut_airmass_upper[i]