# Generate the truth tables for this realization g1true, g2true = g3metrics.make_const_truth_uniform_annular( NFIELDS, NIMS, range_min=TRUE_MIN, range_max=TRUE_MAX) # Loop over each c, m combination for i in range(NBINS): for j in range(NBINS): # Make the submissions g1sub, g2sub = g3metrics.make_submission_const_shear( cvals[i], cvals[i], mvals[j], mvals[j], g1true, g2true, ngals_per_im=NGALS_PER_IM, noise_sigma=NOISE_SIGMA) # Calculate the metrics and store Q08[i, j, krepeat] = g3metrics.metricQ08_const_shear( g1sub, g2sub, g1true, g2true, nfields=NFIELDS) QZ1[i, j, krepeat] = g3metrics.metricQZ1_const_shear( g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] QZ2[i, j, krepeat] = g3metrics.metricQZ2_const_shear( g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] print "Calculated const shear metrics for "+str(krepeat + 1)+"/"+\ str(NMONTE)+" realizations" # Save the results as a tuple of NumPy arrays cPickle.dump((Q08, QZ1, QZ2), open(OUTFILE, 'wb')) # Get basic statistics q08mean = np.mean(Q08, axis=2) qZ1mean = np.mean(QZ1, axis=2) qZ2mean = np.mean(QZ2, axis=2) q08stds = np.std(Q08, axis=2) qZ1stds = np.std(QZ1, axis=2) qZ2stds = np.std(QZ2, axis=2) q08errs = q08stds / np.sqrt(NMONTE)
# Make the submissions g1sub, g2sub = g3metrics.make_submission_const_shear( cvals[i], cvals[i], mvals[j], mvals[j], g1true, g2true, ngals_per_im=NGALS_PER_IM, noise_sigma=NOISE_SIGMA) # Calculate the metrics and store Q08[i, j, krepeat] = g3metrics.metricQ08_const_shear( g1sub, g2sub, g1true, g2true, nfields=NFIELDS) QZ1[i, j, krepeat] = g3metrics.metricQZ1_const_shear( g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] QZ2[i, j, krepeat] = g3metrics.metricQZ2_const_shear( g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] print "Calculated const shear metrics for "+str(krepeat + 1)+"/"+\ str(NMONTE)+" realizations" # Save the results as a tuple of NumPy arrays cPickle.dump((Q08, QZ1, QZ2), open(OUTFILE, 'wb')) # Get basic statistics q08mean = np.mean(Q08, axis=2) qZ1mean = np.mean(QZ1, axis=2) qZ2mean = np.mean(QZ2, axis=2) q08stds = np.std(Q08, axis=2) qZ1stds = np.std(QZ1, axis=2) qZ2stds = np.std(QZ2, axis=2) q08errs = q08stds / np.sqrt(NMONTE)
cgrid[i, j], mgrid[i, j], mgrid[i, j], g1true, g2true, ngals_per_im=NGALS_PER_IM, noise_sigma=NOISE_SIGMA) QZ1_mcboth[i, j] = g3metrics.metricQZ1_const_shear(g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] QZ2_mcboth[i, j] = g3metrics.metricQZ2_const_shear(g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt if not os.path.isdir('./plots'): os.mkdir('./plots') fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(np.log10(mgrid), np.log10(cgrid), np.log10(QZ1_mcboth), rstride=1,
QZ1_mcboth = np.empty((NBINS, NBINS)) QZ2_mcboth = np.empty((NBINS, NBINS)) # Loop over mvalues making independent submissions at each c, m combination for i in range(NBINS): for j in range(NBINS): g1sub, g2sub = g3metrics.make_submission_const_shear(cgrid[i, j], cgrid[i, j], mgrid[i, j], mgrid[i, j], g1true, g2true, ngals_per_im=NGALS_PER_IM, noise_sigma=NOISE_SIGMA) QZ1_mcboth[i, j] = g3metrics.metricQZ1_const_shear(g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] QZ2_mcboth[i, j] = g3metrics.metricQZ2_const_shear(g1sub, g2sub, g1true, g2true, cfid=CFID, mfid=MFID)[0] from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt if not os.path.isdir('./plots'): os.mkdir('./plots') fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(np.log10(mgrid), np.log10(cgrid), np.log10(QZ1_mcboth), rstride=1, cstride=1, alpha=0.3, color='r') ax.view_init(25, 60) plt.xlabel(r'log$_{10}$(m = m1 = m2)') plt.ylabel(r'log$_{10}$(c = c1 = c2)') plt.title('QZ1 metric')