예제 #1
0
def gather_batch_data_run():
    datapath_db = data_paths.DataPath()

    outpath = datapath_db.fetch("quadratic_batch_data")
    print "reading from to: " + outpath

    funcname = "correlate.batch_quadratic.call_xspec_run"
    caller = batch_handler.MemoizeBatch(funcname, outpath,
                                        verbose=True)

    for mode_num in range(0,55,5):
        map1_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        map2_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        noise1_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        noise2_key = "GBT_15hr_map_cleaned_%dmode" % mode_num

        (pairlist, pairdict) = \
                data_paths.cross_maps(map1_key, map2_key,
                              noise1_key, noise2_key,
                              map_suffix=";map",
                              noise_inv_suffix=";noise_inv",
                              cross_sym="_x_",
                              pair_former="GBTauto_cross_pairs",
                              ignore=['param'],
                              tag1prefix=map1_key + "_",
                              tag2prefix=map2_key + "_",
                              verbose=False)

        pwr_1d = []
        pwr_2d = []
        for item in pairdict.keys():
            pairrun = pairdict[item]
            print pairrun['tag1']
            print pairrun['map1']
            print pairrun['noise_inv1']
            print pairdict[item].keys()

            pwr2d_run, pwr1d_run = caller.execute(pairrun['map1'],
                                                  pairrun['map2'],
                                                  pairrun['noise_inv1'],
                                                  pairrun['noise_inv2'])
            pwr_2d.append(pwr2d_run)
            pwr_1d.append(pwr1d_run)

        pe.summarize_1d_agg_pwrspec(pwr_1d,
                                    "pwr_data_%dmodes_1d.dat" % mode_num)
        pe.summarize_2d_agg_pwrspec(pwr_2d,
                                    "pwr_data_%dmodes_2d.dat" % mode_num)
예제 #2
0
def gather_batch_data_run():
    datapath_db = data_paths.DataPath()

    outpath = datapath_db.fetch("quadratic_batch_data")
    print "reading from to: " + outpath

    funcname = "correlate.batch_quadratic.call_xspec_run"
    caller = batch_handler.MemoizeBatch(funcname, outpath, verbose=True)

    for mode_num in range(0, 55, 5):
        map1_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        map2_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        noise1_key = "GBT_15hr_map_cleaned_%dmode" % mode_num
        noise2_key = "GBT_15hr_map_cleaned_%dmode" % mode_num

        (pairlist, pairdict) = \
                data_paths.cross_maps(map1_key, map2_key,
                              noise1_key, noise2_key,
                              map_suffix=";map",
                              noise_inv_suffix=";noise_inv",
                              cross_sym="_x_",
                              pair_former="GBTauto_cross_pairs",
                              ignore=['param'],
                              tag1prefix=map1_key + "_",
                              tag2prefix=map2_key + "_",
                              verbose=False)

        pwr_1d = []
        pwr_2d = []
        for item in pairdict.keys():
            pairrun = pairdict[item]
            print pairrun['tag1']
            print pairrun['map1']
            print pairrun['noise_inv1']
            print pairdict[item].keys()

            pwr2d_run, pwr1d_run = caller.execute(pairrun['map1'],
                                                  pairrun['map2'],
                                                  pairrun['noise_inv1'],
                                                  pairrun['noise_inv2'])
            pwr_2d.append(pwr2d_run)
            pwr_1d.append(pwr1d_run)

        pe.summarize_1d_agg_pwrspec(pwr_1d,
                                    "pwr_data_%dmodes_1d.dat" % mode_num)
        pe.summarize_2d_agg_pwrspec(pwr_2d,
                                    "pwr_data_%dmodes_2d.dat" % mode_num)
예제 #3
0
def calculate_2d_transfer_function(pwr_stack1,
                                   pwr_stack2,
                                   tag,
                                   outdir="./plot_data"):
    n_runs = len(pwr_stack1)
    if n_runs != len(pwr_stack2):
        print "These runs are incompatible (different number)."
        sys.exit()

    (mean1_2d, std1_2d) = pe.agg_stat_2d_pwrspec(pwr_stack1)
    (mean2_2d, std2_2d) = pe.agg_stat_2d_pwrspec(pwr_stack2)

    trans_stack = []
    for index in range(n_runs):
        entry = copy.deepcopy(pwr_stack1[index])  # TODO: copy needed?

        binavg1 = pwr_stack1[index]['binavg']
        binavg2 = pwr_stack2[index]['binavg']
        entry['binavg'] = binavg1 / binavg2
        trans_stack.append(entry)

    fileout = outdir + "/" + tag + ".dat"
    trans_mean, trans_std = pe.summarize_2d_agg_pwrspec(trans_stack, fileout)

    # now derive the alternative transfer function by taking the ratio of
    # averages
    trans_alt = mean1_2d / mean2_2d
    trans_alt[np.isnan(trans_alt)] = 0.

    bin_x_left = np.log10(entry['bin_x_left'])
    bin_y_left = np.log10(entry['bin_y_left'])
    bin_x_center = np.log10(entry['bin_x_center'])
    bin_y_center = np.log10(entry['bin_y_center'])
    bin_x_right = np.log10(entry['bin_x_right'])
    bin_y_right = np.log10(entry['bin_y_right'])
    fileout = outdir + "/" + tag + "_altavg.dat"
    outfile = open(fileout, "w")
    for xind in range(len(bin_x_center)):
        for yind in range(len(bin_y_center)):
            outstr = ("%10.15g " * 7 + "\n") % \
                    (bin_x_left[xind], bin_x_center[xind], bin_x_right[xind], \
                     bin_y_left[yind], bin_y_center[yind], bin_y_right[yind], \
                     trans_alt[xind, yind])
            outfile.write(outstr)

    outfile.close()

    # note that we are returning the alternate version of the transfer
    # function: <filt>/<orig> vs <filt/orig>
    return trans_alt
예제 #4
0
def calculate_2d_transfer_function(pwr_stack1, pwr_stack2, tag, outdir="./plot_data"):
    n_runs = len(pwr_stack1)
    if n_runs != len(pwr_stack2):
        print "These runs are incompatible (different number)."
        sys.exit()

    (mean1_2d, std1_2d) = pe.agg_stat_2d_pwrspec(pwr_stack1)
    (mean2_2d, std2_2d) = pe.agg_stat_2d_pwrspec(pwr_stack2)

    trans_stack = []
    for index in range(n_runs):
        entry = copy.deepcopy(pwr_stack1[index])  # TODO: copy needed?

        binavg1 = pwr_stack1[index]['binavg']
        binavg2 = pwr_stack2[index]['binavg']
        entry['binavg'] = binavg1/binavg2
        trans_stack.append(entry)

    fileout = outdir + "/" + tag + ".dat"
    trans_mean, trans_std = pe.summarize_2d_agg_pwrspec(trans_stack, fileout)

    # now derive the alternative transfer function by taking the ratio of
    # averages
    trans_alt = mean1_2d/mean2_2d
    trans_alt[np.isnan(trans_alt)] = 0.

    bin_x_left = np.log10(entry['bin_x_left'])
    bin_y_left = np.log10(entry['bin_y_left'])
    bin_x_center = np.log10(entry['bin_x_center'])
    bin_y_center = np.log10(entry['bin_y_center'])
    bin_x_right = np.log10(entry['bin_x_right'])
    bin_y_right = np.log10(entry['bin_y_right'])
    fileout = outdir + "/" + tag + "_altavg.dat"
    outfile = open(fileout, "w")
    for xind in range(len(bin_x_center)):
        for yind in range(len(bin_y_center)):
            outstr = ("%10.15g " * 7 + "\n") % \
                    (bin_x_left[xind], bin_x_center[xind], bin_x_right[xind], \
                     bin_y_left[yind], bin_y_center[yind], bin_y_right[yind], \
                     trans_alt[xind, yind])
            outfile.write(outstr)

    outfile.close()

    # note that we are returning the alternate version of the transfer
    # function: <filt>/<orig> vs <filt/orig>
    return trans_alt