def init(experiment, field, root=""):
    """
    Initialize all quantities for likelihood computation

    KeyWord Arguments
    -----------------
    root: str
        specify the working directory to explore

    """

    # load the bandpower window functions
    (bpwf_l,bpwf_Cs_l) = get_bpwf(exp=experiment, root=root)

    # load the  bandpower products
    bp = read_data_products_bandpowers(exp=experiment, root=root)
    bp = np.array(bp)

    # initialize bandpower arrays
    nf = len(field)
    dim = nf*(nf+1)/2
    C_l_hat = np.zeros((9, nf, nf))
    C_fl = np.zeros((9, nf, nf))
    N_l = np.zeros((9, nf, nf))
    C_l = np.zeros((9, nf, nf))

    #Selects parts of the necessary matrices for a given instance of the field
    if field == "T":
        C_l_hat[:, 0, 0] = bp[1, :, 0, 0]
        C_fl[:, 0, 0] = bp[0, :, 0, 0]
        N_l[:, 0, 0] = bp[2, :, 0, 0]
    elif field == "E":
        C_l_hat[:, 0, 0] = bp[1, :, 1, 1]
        C_fl[:, 0, 0] = bp[0, :, 1, 1]
        N_l[:, 0, 0] = bp[2, :, 1, 1]
    elif field == "B":
        C_l_hat[:, 0, 0] = bp[1, :, 2, 2]
        C_fl[:, 0, 0] = bp[0, :, 2, 2]
        N_l[:, 0, 0] = bp[2, :, 2, 2]
    elif field == "EB":
        C_l_hat[:, 0, 0] = bp[1, :, 1, 1]  # EE
        C_l_hat[:, 0, 1] = bp[1, :, 1, 2]  # EB
        C_l_hat[:, 1, 0] = bp[1, :, 2, 1]  # BE
        C_l_hat[:, 1, 1] = bp[1, :, 2, 2]  # BB
        C_fl[:, 0, 0] = bp[0, :, 1, 1]
        C_fl[:, 0, 1] = bp[0, :, 1, 2]
        C_fl[:, 1, 0] = bp[0, :, 2, 1]
        C_fl[:, 1, 1] = bp[0, :, 2, 2]
        N_l[:, 0, 0] = bp[2, :, 1, 1]
        N_l[:, 0, 1] = bp[2, :, 1, 2]
        N_l[:, 1, 0] = bp[2, :, 2, 1]
        N_l[:, 1, 1] = bp[2, :, 2, 2]
    elif field == "TB":
        C_l_hat[:, 0, 0] = bp[1, :, 0, 0]  # TT
        C_l_hat[:, 0, 1] = bp[1, :, 0, 2]  # TB
        C_l_hat[:, 1, 0] = bp[1, :, 2, 0]  # BT
        C_l_hat[:, 1, 1] = bp[1, :, 2, 2]  # BB
        C_fl[:, 0, 0] = bp[0, :, 0, 0]
        C_fl[:, 0, 1] = bp[0, :, 0, 2]
        C_fl[:, 1, 0] = bp[0, :, 2, 0]
        C_fl[:, 1, 1] = bp[0, :, 2, 2]
        N_l[:, 0, 0] = bp[2, :, 0, 0]
        N_l[:, 0, 1] = bp[2, :, 0, 2]
        N_l[:, 1, 0] = bp[2, :, 2, 0]
        N_l[:, 1, 1] = bp[2, :, 2, 2]
    elif field == "TE":
        C_l_hat[:, 0, 0] = bp[1, :, 0, 0]  # TT
        C_l_hat[:, 0, 1] = bp[1, :, 0, 1]  # TE
        C_l_hat[:, 1, 0] = bp[1, :, 1, 0]  # ET
        C_l_hat[:, 1, 1] = bp[1, :, 1, 1]  # EE
        C_fl[:, 0, 0] = bp[0, :, 0, 0]
        C_fl[:, 0, 1] = bp[0, :, 0, 1]
        C_fl[:, 1, 0] = bp[0, :, 1, 0]
        C_fl[:, 1, 1] = bp[0, :, 1, 1]
        N_l[:, 0, 0] = bp[2, :, 0, 0]
        N_l[:, 0, 1] = bp[2, :, 0, 1]
        N_l[:, 1, 0] = bp[2, :, 1, 0]
        N_l[:, 1, 1] = bp[2, :, 1, 1]
    elif field == "TEB":
        C_l_hat = bp[1, :, :, :]
        C_fl = bp[0, :, :, :]
        N_l = bp[2, :, :, :]

    # load the covariance matrix
    M_raw = read_M(exp=experiment, root=root)
    M = np.zeros((9*dim, 9*dim))
    M_inv = np.zeros((9, 9, dim, dim))

    # select the relevant part of the cov matrix
    if field == 'T':
        M[:, :] = M_raw[0::6, 0::6]
    elif field == 'E':
        M[:, :] = M_raw[1::6, 1::6]
    elif field == 'B':
        M[:, :] = M_raw[2::6, 2::6]
    elif field == 'EB':
        M[0::3, 0::3] = M_raw[1::6, 1::6]
        M[1::3, 1::3] = M_raw[2::6, 2::6]
        M[2::3, 2::3] = M_raw[4::6, 4::6]
        M[0::3, 1::3] = M_raw[1::6, 2::6]
        M[1::3, 0::3] = M_raw[2::6, 1::6]
        M[0::3, 2::3] = M_raw[1::6, 4::6]
        M[2::3, 0::3] = M_raw[4::6, 1::6]
        M[1::3, 2::3] = M_raw[2::6, 4::6]
        M[2::3, 1::3] = M_raw[4::6, 2::6]
    elif field == 'TE':
        M[0::3, 0::3] = M_raw[0::6, 0::6]
        M[1::3, 1::3] = M_raw[1::6, 1::6]
        M[2::3, 2::3] = M_raw[3::6, 3::6]
        M[0::3, 1::3] = M_raw[0::6, 1::6]
        M[1::3, 0::3] = M_raw[1::6, 0::6]
        M[0::3, 2::3] = M_raw[0::6, 3::6]
        M[2::3, 0::3] = M_raw[3::6, 0::6]
        M[1::3, 2::3] = M_raw[1::6, 3::6]
        M[2::3, 1::3] = M_raw[3::6, 1::6]
    elif field == 'TB':
        M[0::3, 0::3] = M_raw[0::6, 0::6]
        M[1::3, 1::3] = M_raw[2::6, 2::6]
        M[2::3, 2::3] = M_raw[5::6, 5::6]
        M[0::3, 1::3] = M_raw[0::6, 2::6]
        M[1::3, 0::3] = M_raw[2::6, 0::6]
        M[0::3, 2::3] = M_raw[0::6, 5::6]
        M[2::3, 0::3] = M_raw[5::6, 0::6]
        M[1::3, 2::3] = M_raw[2::6, 5::6]
        M[2::3, 1::3] = M_raw[5::6, 2::6]
    elif field == 'TEB':
        M = M_raw

    # Evaluate inverse of covariance matrix
    M_invp = LA.inv(M)

    # re-organize elements
    for ell in xrange(9):
        for ellp in xrange(9):
            M_inv[ell,ellp,:,:] = M_invp[ell*dim:(ell+1)*dim,ellp*dim:(ellp+1)*dim]

    return C_l, C_l_hat, N_l, C_fl, M_inv, bpwf_l, bpwf_Cs_l
dataset/ETHPy150Open baudren/montepython_public/montepython/likelihoods/bicep2/bicep_util.py/init/original