def get_bpwf(exp='bicep1', root=''):
    # This assumes you have the files
    # windows/B1_3yr_bpwf_bin[1-9]_20131003.txt in the root directory
    # windows/B2_3yr_bpwf_bin[1-9]_date.txt in the working directory if exp = 'bicep2'

    if exp == 'bicep1':
        # Load up BICEP1 bandpower window functions
        file_in = os.path.join("windows", "B1_3yr_bpwf_bin?_20131003.txt")
        print "### Reading the BICEP1 BPWF from  file: %s" % file_in
        ncol = 580
    elif exp == 'bicep2':
        # Load up BICEP2 bandpower window functions
        file_in = os.path.join("windows", "B2_3yr_bpwf_bin?_20140314.txt")
        print "### Reading the BICEP2 BPWF from  file: %s" % file_in
        ncol = 599
    else:
        print 'exp must be "bicep1" or "bicep2" to load the proper window functions'
        print 'window functions must be in the root_directory/windows/'
        print 'bicep2 window functions available at http://bicepkeck.org/bicep2_2014_release'
        print 'bicep1 window functions available at bicep.rc.fas.harvard.edu/bicep1_3yr'
        raise IOError()

    # Initialize array so it's just like our Matlab version
    bpwf_Cs_l = np.zeros([ncol, 9, 6])

    for i in xrange(9):
        window_file = file_in.replace('?', str(i+1))

        try:
            data = np.loadtxt(
                os.path.join(root, window_file))
        except IOError:
            print ("Error reading  %s." % window_file +
                   "Make sure it is in root directory")
            raise IOError()
        bpwf_Cs_l[:, i, 0] = data[:, 1]   # TT -> TT
        bpwf_Cs_l[:, i, 1] = data[:, 2]   # TE -> TE
        bpwf_Cs_l[:, i, 2] = data[:, 3]   # EE -> EE
        bpwf_Cs_l[:, i, 3] = data[:, 4]   # BB -> BB

    bpwf_l = data[:, 0]

    return (bpwf_l, bpwf_Cs_l)

#####################################################################
dataset/ETHPy150Open baudren/montepython_public/montepython/likelihoods/bicep2/bicep_util.py/get_bpwf/original