# HACKY: Temporarily set evaluate.USEBINS to be all true to use *all* angular bins for # calculating the product moment correlation coeff evaluate.USEBINS = np.ones(evaluate.USEBINS.shape, dtype=bool) # Get truth as a full catalog _, x, y, g1true, g2true = test_evaluate.get_variable_gtrue( EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR) # Then make a variable submission to learn what pure c1 and c2 look like in map^2 import tempfile fdtmp, tmpfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission(x, y, np.zeros_like(g1true), np.zeros_like(g2true), np.zeros_like(g1true), np.zeros_like(g2true), 1., 0., 0., 0., outfile=tmpfile, noise_sigma=0.) os.close(fdtmp) map_E_c1 = np.loadtxt(tmpfile)[:, 2] os.remove(tmpfile) fdtmp, tmpfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission(x, y, np.zeros_like(g1true), np.zeros_like(g2true), np.zeros_like(g1true), np.zeros_like(g2true),
EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) _, _, _, g1int, g2int = test_evaluate.get_variable_gsuffix( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) for jc, cval in enumerate(CVALS): for itest in xrange(NTEST): # Build the submission fdsub, subfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, g1true, g2true, g1int, g2int, cval, cval, evaluate.MFID, evaluate.MFID, outfile=subfile, noise_sigma=NOISE_SIGMA[obs_type]) os.close(fdsub) # Then evaluate Q_v qc[obs_type][itest, jc] = evaluate.q_variable( subfile, EXPERIMENT, obs_type, usebins=evaluate.USEBINS, truth_dir=TRUTH_DIR) os.remove(subfile)
_, x, y, g1true, g2true = test_evaluate.get_variable_gtrue( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) _, _, _, g1int, g2int = test_evaluate.get_variable_gsuffix( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) # Then loop over specified number of tests for itest in xrange(NTEST): # Build the submission fdsub, subfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, g1true, g2true, g1int, g2int, 0., 0., 0., 0., outfile=subfile, noise_sigma=NOISE_SIGMA[obs_type]) os.close(fdsub) data = np.loadtxt(subfile) mapE[obs_type][:, itest] = data[:, 2] print "Completed test %4d / %4d" % (itest + 1, NTEST) os.remove(subfile) print "Saving pickled map_E tables to " + mapEoutfile with open(mapEoutfile, "wb") as fout: cPickle.dump(mapE, fout)
print "NOISE_SIGMA = "+str(NOISE_SIGMA[obs_type]) # First we build the truth table print "Building truth tables for control-"+obs_type+"-variable" # Get the x,y, true intrinsic ellips and shears for making fake submissions _, x, y, g1true, g2true = test_evaluate.get_variable_gtrue( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) _, _, _, g1int, g2int = test_evaluate.get_variable_gsuffix( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) for jc, cval in enumerate(CVALS): for itest in xrange(NTEST): # Build the submission fdsub, subfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, g1true, g2true, g1int, g2int, cval, cval, evaluate.MFID, evaluate.MFID, outfile=subfile, noise_sigma=NOISE_SIGMA[obs_type]) os.close(fdsub) # Then evaluate Q_v qc[obs_type][itest, jc] = evaluate.q_variable( subfile, EXPERIMENT, obs_type, usebins=evaluate.USEBINS, truth_dir=TRUTH_DIR) os.remove(subfile) print "Test %4d / %4d (c = %.3e) Q_v = %.4f" % ( itest+1, NTEST, cval, qc[obs_type][itest, jc]) print "Mean Q_v = "+str(qc[obs_type][:, jc].mean())+" for "+str(NTEST)+\ " sims (with c = "+str(cval)+", obs_type = "+str(obs_type)+")" print print "Saving pickled Q_v versus c dict to "+coutfile
print "Calculating map_E values for control-"+obs_type+"-variable data in GREAT3" print "NOISE_SIGMA = "+str(NOISE_SIGMA[obs_type]) # First we build the truth table print "Building truth tables for control-"+obs_type+"-variable" # Get the x,y, true intrinsic ellips and shears for making fake submissions _, x, y, g1true, g2true = test_evaluate.get_variable_gtrue( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) _, _, _, g1int, g2int = test_evaluate.get_variable_gsuffix( EXPERIMENT, obs_type, truth_dir=TRUTH_DIR) # Then loop over specified number of tests for itest in xrange(NTEST): # Build the submission fdsub, subfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, g1true, g2true, g1int, g2int, 0., 0., 0., 0., outfile=subfile, noise_sigma=NOISE_SIGMA[obs_type]) os.close(fdsub) data = np.loadtxt(subfile) mapE[obs_type][:, itest] = data[:, 2] print "Completed test %4d / %4d" % (itest+1, NTEST) os.remove(subfile) print "Saving pickled map_E tables to "+mapEoutfile with open(mapEoutfile, "wb") as fout: cPickle.dump(mapE, fout) print else: with open(mapEoutfile, "rb") as fin: mapE = cPickle.load(fin)
# Hmmm actually a linear model doesn't work because we do want to constrain c**2 to be # positive... Try using optimize instead if USE_ALL_BINS: # HACKY: Temporarily set evaluate.USEBINS to be all true to use *all* angular bins for # calculating the product moment correlation coeff evaluate.USEBINS = np.ones(evaluate.USEBINS.shape, dtype=bool) # Get truth as a full catalog _, x, y, g1true, g2true = test_evaluate.get_variable_gtrue( EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR) # Then make a variable submission to learn what pure c1 and c2 look like in map^2 import tempfile fdtmp, tmpfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, np.zeros_like(g1true), np.zeros_like(g2true), np.zeros_like(g1true), np.zeros_like(g2true), 1., 0., 0., 0., outfile=tmpfile, noise_sigma=0.) os.close(fdtmp) map_E_c1 = np.loadtxt(tmpfile)[:, 2] os.remove(tmpfile) fdtmp, tmpfile = tempfile.mkstemp(suffix=".dat") result = test_evaluate.make_variable_submission( x, y, np.zeros_like(g1true), np.zeros_like(g2true), np.zeros_like(g1true), np.zeros_like(g2true), 0., 1., 0., 0., outfile=tmpfile, noise_sigma=0.) os.close(fdtmp) map_E_c2 = np.loadtxt(tmpfile)[:, 2] os.remove(tmpfile) # Then average these (I checked they are very similar as you would expect) to get our "unit c" # term for the modelling. Note that previously I summed these, but I think this was an error as # that actually corresponds approximately to a shear field with g1 = g2 = 1, i.e. |g| = sqrt(2) map_E_unitc = .5 * (map_E_c1 + map_E_c2)