Ejemplo n.º 1
0
 # Load up relevant data
 i3data = np.loadtxt(I3FILE)
 rgdata = np.loadtxt(RGFILE)
 # Extract the salient parts of the submissions from data
 field_i3 = i3data[:, 0].astype(int)
 theta_i3 = i3data[:, 1]
 map_E_i3 = i3data[:, 2]
 field_rg = rgdata[:, 0].astype(int)
 theta_rg = rgdata[:, 1]
 map_E_rg = rgdata[:, 2]
 # Load/generate the truth shear signal
 field_shear, theta_shear, map_E_shear, _, maperr_shear = evaluate.get_generate_variable_truth(
     EXPERIMENT,
     OBS_TYPE,
     truth_dir=TRUTH_DIR,
     logger=None,
     corr2_exec=CORR2_EXEC,
     mape_file_prefix=MAPESHEAR_FILE_PREFIX,
     suffixes=("", ),
     make_plots=False)
 # Then generate the intrinsic only map_E, useful for examinging plots, including the maperr
 # (a good estimate of the relative Poisson errors per bin) which we will use to provide a weight
 field_int, theta_int, map_E_int, _, maperr_int = evaluate.get_generate_variable_truth(
     EXPERIMENT,
     OBS_TYPE,
     truth_dir=TRUTH_DIR,
     logger=None,
     corr2_exec=CORR2_EXEC,
     mape_file_prefix=MAPEINT_FILE_PREFIX,
     suffixes=("_intrinsic", ),
     make_plots=False)
Ejemplo n.º 2
0
        np.testing.assert_array_equal(
            (70. * x_offset_truth).astype(int), np.asarray(x_offset_presub),
            err_msg="Truth x_offsets do not match those in public-scripts.branch_id")
        np.testing.assert_array_equal(
            (70. * y_offset_truth).astype(int), np.asarray(y_offset_presub),
            err_msg="Truth x_offsets do not match those in public-scripts.branch_id")

        # Then try testing the whole x-y using the (no longer) hacked presubmission
        pipelines.build_submission(
            "im3shape-1", experiment, obs_type, "variable",
            submission_dir=os.path.join("..", "submissions"),
            presubmission_exec=os.path.join("..", "..", "public-scripts", "presubmission.py"))

        # Then build the truth catalogues saving the x and y
        field_index, theta, map_E, map_B, maperr = evaluate.get_generate_variable_truth(
            experiment, obs_type, truth_dir=TRUTH_DIR,
            corr2_params=os.path.join("..", "..", "server", "great3", "corr2.params"),
            make_plots=False, output_xy_prefix="./cats/truth_xy_"+experiment+"-"+obs_type)

        try:
            xysubfile = "./cats/test_xy_"+experiment+"-"+obs_type+"-variable"+(
                "-sub%03d" % 0)+".asc"
            np.loadtxt(xysubfile)
        except IOError as err:
            # Now the hacked presubmission has moved all of these cataloges to ".", and we want to
            # move them to ./cats, so do this
            print "Moving cats to ./cats"
            import subprocess
            import glob
            call_list = (["mv",]+glob.glob("test*.asc")+["./cats"])
            print call_list
            retcode = subprocess.call(["mv",]+glob.glob("truth*.asc")+["./cats"])
Ejemplo n.º 3
0
if __name__ == "__main__":

    #run_variable_tests()
    import glob
    import subprocess
    import logging

    # Setup the logger
    logging.basicConfig(stream=sys.stderr)
    logger = logging.getLogger("test")
    logger.setLevel(logging.DEBUG)

    # First get the mapEtruth version
    fieldt, thetat, map_Et, map_Bt, maperrt = evaluate.get_generate_variable_truth(
        "control", "space", truth_dir="/Users/browe/great3/beta/truth",
        file_prefixes=("galaxy_catalog",), suffixes=("",), make_plots=False, logger=logger)

    # Then get the submission truth
    idt, xt, yt, g1t, g2t = get_variable_gsuffix(
        "control", "space", suffix="", file_prefix="galaxy_catalog",
        test_dir="/Users/browe/great3/beta/truth") # True = g1/g2 only
    ret = make_fits_cats(idt, g1t, g2t, prefix="gtrue_comparison")
    gtruesubfile = "./submissions/gtrue_comparison_csv.asc"
    call_list = [
        "./presubmission_alpha-2", "-b", "control-space-variable",
        "-o", gtruesubfile, ]+glob.glob("./cats/gtrue_comparison-*")
    subprocess.check_call(call_list)
    subdata = np.loadtxt(gtruesubfile)
    fields, thetas, map_Es, map_Bs, maperrs = (
        subdata[:, 0], subdata[:, 1], subdata[:, 2], subdata[:, 3], subdata[:, 4])
Ejemplo n.º 4
0
        # Test to see if coutfile is already made, if not make it, if so load it
        if not os.path.isfile(coutfile):
            for obs_type in ("ground", "space"):

                print "Calculating Q_v values versus c for control-"+obs_type+\
                    "-constant data in GREAT3"
                print "Loading Cholesky decomposition matrix from "+\
                    calculate_variable_cholesky.CHOLESKY_OUTFILE[obs_type]
                cholesky = pyfits.getdata(calculate_variable_cholesky.CHOLESKY_OUTFILE[obs_type])
                print "RHO = "+str(RHO)
                # First we build the truth table
                print "Getting/generating truth tables for control-"+obs_type+"-constant"
                field_ref, theta_ref, map_E_ref, _, maperr_ref = \
                    evaluate.get_generate_variable_truth(
                        EXPERIMENT, obs_type, truth_dir=TRUTH_DIR,
                        mape_file_prefix=evaluate.MAPEOBS_FILE_PREFIX,
                        file_prefixes=("galaxy_catalog", "galaxy_catalog"),
                        suffixes=("_intrinsic", ""), make_plots=False)
                # Get the unitc term
                map_E_unitc = 2. * test_evaluate.make_unitc(
                    EXPERIMENT, obs_type, truth_dir=TRUTH_DIR)
                # Loop over c values
                for jc, cval in enumerate(CVALS):

                    # Build the submissions (includes inter-method and inter-bin correlations)
                    map_E_field_subs = make_multiple_variable_submissions(
                        NTEST, map_E_ref, map_E_unitc, cval, evaluate.MFID, cholesky)
                    # Loop over submissions evaluating metric
                    for itest in xrange(NTEST):

                        fdsub, subfile = tempfile.mkstemp(suffix=".dat")
Ejemplo n.º 5
0
        # Then try testing the whole x-y using the (no longer) hacked presubmission
        pipelines.build_submission(
            "im3shape-1",
            experiment,
            obs_type,
            "variable",
            submission_dir=os.path.join("..", "submissions"),
            presubmission_exec=os.path.join("..", "..", "public-scripts",
                                            "presubmission.py"))

        # Then build the truth catalogues saving the x and y
        field_index, theta, map_E, map_B, maperr = evaluate.get_generate_variable_truth(
            experiment,
            obs_type,
            truth_dir=TRUTH_DIR,
            corr2_params=os.path.join("..", "..", "server", "great3",
                                      "corr2.params"),
            make_plots=False,
            output_xy_prefix="./cats/truth_xy_" + experiment + "-" + obs_type)

        try:
            xysubfile = "./cats/test_xy_" + experiment + "-" + obs_type + "-variable" + (
                "-sub%03d" % 0) + ".asc"
            np.loadtxt(xysubfile)
        except IOError as err:
            # Now the hacked presubmission has moved all of these cataloges to ".", and we want to
            # move them to ./cats, so do this
            print "Moving cats to ./cats"
            import subprocess
            import glob
            call_list = ([
if __name__ == "__main__":

    # Load up relevant data
    i3data = np.loadtxt(I3FILE)
    rgdata = np.loadtxt(RGFILE)
    # Extract the salient parts of the submissions from data
    field_i3 = i3data[:, 0].astype(int)
    theta_i3 = i3data[:, 1]
    map_E_i3 = i3data[:, 2]
    field_rg = rgdata[:, 0].astype(int)
    theta_rg = rgdata[:, 1]
    map_E_rg = rgdata[:, 2]
    # Load/generate the truth shear signal
    field_shear, theta_shear, map_E_shear, _, maperr_shear = evaluate.get_generate_variable_truth(
        EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR, logger=None, corr2_exec=CORR2_EXEC,
        mape_file_prefix=MAPESHEAR_FILE_PREFIX, suffixes=("",), make_plots=False)
    # Then generate the intrinsic only map_E, useful for examinging plots, including the maperr
    # (a good estimate of the relative Poisson errors per bin) which we will use to provide a weight
    field_int, theta_int, map_E_int, _, maperr_int = evaluate.get_generate_variable_truth(
        EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR, logger=None, corr2_exec=CORR2_EXEC,
        mape_file_prefix=MAPEINT_FILE_PREFIX, suffixes=("_intrinsic",), make_plots=False)
    # Then generate the theory observed = int + shear combined map signals - these are our reference
    # Note this uses the new functionality of get_generate_variable_truth for adding shears
    field_ref, theta_ref, map_E_ref, _, maperr_ref = evaluate.get_generate_variable_truth(
        EXPERIMENT, OBS_TYPE, truth_dir=TRUTH_DIR, logger=None, corr2_exec=CORR2_EXEC,
        mape_file_prefix=MAPEOBS_FILE_PREFIX, file_prefixes=("galaxy_catalog", "galaxy_catalog"),
        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>