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_correlated_const_Q_c_versus_c_norm"+str(krun)+".pkl")
        moutfile = os.path.join(
            "results", "tabulated_correlated_const_Q_c_versus_m_norm"+str(krun)+".pkl")
        if not os.path.isfile(coutfile):
            for obs_type in ("ground", "space",):

                print "Calculating Q_c values versus c for control-"+obs_type+\
                    "-constant data in GREAT3"
                print "NOISE_SIGMA = "+str(NOISE_SIGMA[obs_type])
                print "RHO = "+str(RHO)
                # First we build the truth table
                print "Building truth tables for control-"+obs_type+"-constant"
                subfield_index, g1true, g2true = evaluate.get_generate_const_truth(
                    EXPERIMENT, obs_type, truth_dir=TRUTH_DIR)
                rotations = evaluate.get_generate_const_rotations(
                    EXPERIMENT, obs_type, truth_dir=TRUTH_DIR)
                for jc, cval in enumerate(CVALS):

                    # Build the submissions
                    g1sub, g2sub = g3metrics.make_multiple_submissions_const_shear(
                        cval, 0., evaluate.MFID, evaluate.MFID, g1true, g2true, NGALS_PER_IMAGE,
                        NOISE_SIGMA[obs_type], rotate_cs=rotations, nsubmissions=NTEST, rho=RHO)
                    # Loop over submissions evaluating metric
                    for itest in xrange(NTEST):

                        fdsub, subfile = tempfile.mkstemp(suffix=".dat")
                        with os.fdopen(fdsub, "wb") as fsub:
                            np.savetxt(
                                fsub, np.array((subfield_index, g1sub[:, itest],
        moutfile = os.path.join(
            "results", "tabulated_correlated_const_Q_c_versus_m_norm" +
            str(krun) + ".pkl")
        if not os.path.isfile(coutfile):
            for obs_type in (
                    "ground",
                    "space",
            ):

                print "Calculating Q_c values versus c for control-"+obs_type+\
                    "-constant data in GREAT3"
                print "NOISE_SIGMA = " + str(NOISE_SIGMA[obs_type])
                print "RHO = " + str(RHO)
                # First we build the truth table
                print "Building truth tables for control-" + obs_type + "-constant"
                subfield_index, g1true, g2true = evaluate.get_generate_const_truth(
                    EXPERIMENT, obs_type, truth_dir=TRUTH_DIR)
                rotations = evaluate.get_generate_const_rotations(
                    EXPERIMENT, obs_type, truth_dir=TRUTH_DIR)
                for jc, cval in enumerate(CVALS):

                    # Build the submissions
                    g1sub, g2sub = g3metrics.make_multiple_submissions_const_shear(
                        cval,
                        0.,
                        evaluate.MFID,
                        evaluate.MFID,
                        g1true,
                        g2true,
                        NGALS_PER_IMAGE,
                        NOISE_SIGMA[obs_type],
                        rotate_cs=rotations,
Exemplo n.º 3
0
# Paths to control-ground-constant filenames (im3shape score ~225, regauss score ~ 68), make sure
# these are present!
I3FILE = os.path.join(
    "results", "cogs-im3shape-im3shape-0-2013-10-18T15:46:28.199250+00:00.g3")
RGFILE = os.path.join(
    "results",
    "great3_ec-regauss-example-example_1-2013-12-27T15:24:57.472170+00:00.g3")

TRUTH_DIR = "/Users/browe/great3/beta/truth"  # Modify to wherever truth is unpacked

if __name__ == "__main__":

    # Load up relevant data
    i3data = np.loadtxt(I3FILE)
    rgdata = np.loadtxt(RGFILE)
    subfield_index, g1true, g2true = evaluate.get_generate_const_truth(
        EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    rotations = evaluate.get_generate_const_rotations(EXPERIMENT,
                                                      OBS_TYPE,
                                                      truth_dir=TRUTH_DIR)
    # Calculate m and c factors
    qi3, cpi3, mpi3, cxi3, mxi3, sigcpi3, sigmpi3, sigmxi3, sigcxi3 = evaluate.q_constant(
        I3FILE, EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    qrg, cprg, mprg, cxrg, mxrg, sigcprg, sigmprg, sigmxrg, sigcxrg = evaluate.q_constant(
        RGFILE, EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    # Rotate these c and m
    c1i3 = cpi3 * np.cos(2. * rotations) - cxi3 * np.sin(2. * rotations)
    c2i3 = cpi3 * np.sin(2. * rotations) + cxi3 * np.cos(2. * rotations)
    m1i3 = mpi3 * np.cos(2. * rotations) - mxi3 * np.sin(2. * rotations)
    m2i3 = mpi3 * np.sin(2. * rotations) + mxi3 * np.sin(2. * rotations)
    c1rg = cprg * np.cos(2. * rotations) - cxrg * np.sin(2. * rotations)
    c2rg = cprg * np.sin(2. * rotations) + cxrg * np.cos(2. * rotations)
# Paths to control-ground-constant filenames (im3shape score ~225, regauss score ~ 68), make sure
# these are present!
I3FILE = os.path.join("results", "cogs-im3shape-im3shape-0-2013-10-18T15:46:28.199250+00:00.g3")
RGFILE = os.path.join(
    "results", "great3_ec-regauss-example-example_1-2013-12-27T15:24:57.472170+00:00.g3")

TRUTH_DIR = "/Users/browe/great3/beta/truth" # Modify to wherever truth is unpacked


if __name__ == "__main__":

    # Load up relevant data
    i3data = np.loadtxt(I3FILE)
    rgdata = np.loadtxt(RGFILE)
    subfield_index, g1true, g2true = evaluate.get_generate_const_truth(
        EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    rotations = evaluate.get_generate_const_rotations(EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    # Calculate m and c factors
    qi3, cpi3, mpi3, cxi3, mxi3, sigcpi3, sigmpi3, sigmxi3, sigcxi3 = evaluate.q_constant(
        I3FILE, EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    qrg, cprg, mprg, cxrg, mxrg, sigcprg, sigmprg, sigmxrg, sigcxrg = evaluate.q_constant(
        RGFILE, EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR)
    # Rotate these c and m
    c1i3 = cpi3 * np.cos(2. * rotations) - cxi3 * np.sin(2. * rotations)
    c2i3 = cpi3 * np.sin(2. * rotations) + cxi3 * np.cos(2. * rotations)
    m1i3 = mpi3 * np.cos(2. * rotations) - mxi3 * np.sin(2. * rotations)
    m2i3 = mpi3 * np.sin(2. * rotations) + mxi3 * np.sin(2. * rotations)
    c1rg = cprg * np.cos(2. * rotations) - cxrg * np.sin(2. * rotations)
    c2rg = cprg * np.sin(2. * rotations) + cxrg * np.cos(2. * rotations)
    m1rg = mprg * np.cos(2. * rotations) - mxrg * np.sin(2. * rotations)
    m2rg = mprg * np.sin(2. * rotations) + mxrg * np.sin(2. * rotations)