make_plots=False) # We can use this information to construct the linear model # c**2 + (1 + 2 * m + m**2) * <map_E_ref> = a + b * <map_E_ref> # ...and fit it to the submissions # 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.)
import cPickle # Dicts containing arrays for storing Q_c values versus m and c, for ground and space qc = {"ground": np.empty((NTEST, len(CVALS))), "space": np.empty((NTEST, len(CVALS)))} qm = {"ground": np.empty((NTEST, len(MVALS))), "space": np.empty((NTEST, len(MVALS)))} coutfile = os.path.join("results", "tabulated_variable_Q_v_versus_c_norm2.pkl") moutfile = os.path.join("results", "tabulated_variable_Q_v_versus_m_norm2.pkl") if not os.path.isfile(coutfile): for obs_type in ("ground", "space",): print "Calculating Q_v values versus c 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) 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,
"tabulated_variable_Q_v_versus_c_norm2.pkl") moutfile = os.path.join("results", "tabulated_variable_Q_v_versus_m_norm2.pkl") if not os.path.isfile(coutfile): for obs_type in ( "ground", "space", ): print "Calculating Q_v values versus c 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) 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,
suffixes=("_intrinsic", ""), make_plots=False) # We can use this information to construct the linear model # c**2 + (1 + 2 * m + m**2) * <map_E_ref> = a + b * <map_E_ref> # ...and fit it to the submissions # 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]