Skip to content

jelli.utils.par_helpers

get_par_monomial_indices(keys_pars, keys_coeff)

Computes sorted indices mapping linear parameters to bilinear ones that exist in the provided coefficient list.

Parameters:

Name Type Description Default
keys_pars list

List of linear parameter keys, each element is a tuple (w, c), where w is the parameter name and c is R for real or I for imaginary.

required
keys_coeff list

List of bilinear coefficient keys. Each element is a tuple (w1, w2, c), where w1 and w2 are the parameter names and c is RR, RI, IR, or II, denoting all possible interferences.

required

Returns:

Type Description
`np.ndarray`

Sorted indices of bilinear coefficients that match keys_coeff.

Source code in jelli/utils/par_helpers.py
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
def get_par_monomial_indices(keys_pars, keys_coeff):
    """
    Computes sorted indices mapping linear parameters
    to bilinear ones that exist in the provided coefficient list.

    Parameters
    ----------
    keys_pars : list
        List of linear parameter keys, each element is a tuple `(w, c)`,
        where `w` is the parameter name and `c` is `R` for real or `I` for imaginary.
    keys_coeff : list
        List of bilinear coefficient keys. Each element is a tuple `(w1, w2, c)`,
        where `w1` and `w2` are the parameter names and `c` is `RR`, `RI`, `IR`, or `II`,
        denoting all possible interferences.

    Returns
    -------
    `np.ndarray`
        Sorted indices of bilinear coefficients that match `keys_coeff`.
    """
    # Generate all possible bilinear combinations of keys_pars
    keys_pars_bilinears = keys_array(keys_product(
        keys_pars, keys_pars
    ))
    bilin_bools = keys_isin(keys_pars_bilinears, keys_coeff)
    # Take elements of keys_pars_bilinears that exist in keys_coeff and obtain indices that sort them
    sort_indices = np.argsort(keys_pars_bilinears[bilin_bools])
    bilin_indices = np.where(bilin_bools)[0]
    bilin_sort_indices = bilin_indices[sort_indices]
    return bilin_sort_indices

get_sector_indices_from_wcxf(eft, basis, sectors)

Get indices of Wilson coefficients from the full basis corresponding to specified sectors.

Parameters:

Name Type Description Default
eft str

The effective field theory (EFT) name, e.g., SMEFT or WET.

required
basis str

The Wilson coefficient basis name, e.g., Warsaw or JMS.

required
sectors list

A list of sector names to extract indices for.

required

Returns:

Type Description
ndarray

An array of indices corresponding to the Wilson coefficients in the specified sectors.

Source code in jelli/utils/par_helpers.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def get_sector_indices_from_wcxf(eft, basis, sectors):
    '''
    Get indices of Wilson coefficients from the full basis corresponding to specified sectors.

    Parameters
    ----------
    eft : str
        The effective field theory (EFT) name, e.g., `SMEFT` or `WET`.
    basis : str
        The Wilson coefficient basis name, e.g., `Warsaw` or `JMS`.
    sectors : list
        A list of sector names to extract indices for.

    Returns
    -------
    np.ndarray
        An array of indices corresponding to the Wilson coefficients in the specified sectors.
    '''
    basis_full = get_wc_basis_from_wcxf(eft, basis)
    return np.concatenate([
        [basis_full.index(wc) for wc in get_wc_basis_from_wcxf(eft, basis, sector)]
        for sector in sectors
    ])

get_wc_basis_from_wcxf(eft, basis, sector=None, split_re_im=True)

Retrieve the Wilson coefficient basis from WCxf.

Parameters:

Name Type Description Default
eft str

The effective field theory (EFT) name, e.g., SMEFT or WET.

required
basis str

The Wilson coefficient basis name, e.g., Warsaw or JMS.

required
sector str

The RGE sector of interest. If None, all sectors are included.

None
split_re_im bool

If True, split complex Wilson coefficients into their real and imaginary parts. If False, keep them as complex parameters. Default is True.

True

Returns:

Type Description
list

A sorted list of Wilson coefficient names. If split_re_im is True, complex coefficients are represented as tuples (name, 'R') and (name, 'I') for their real and imaginary parts, respectively.

Source code in jelli/utils/par_helpers.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def get_wc_basis_from_wcxf(eft, basis, sector=None, split_re_im=True):
    '''
    Retrieve the Wilson coefficient basis from WCxf.

    Parameters
    ----------
    eft : str
        The effective field theory (EFT) name, e.g., `SMEFT` or `WET`.
    basis : str
        The Wilson coefficient basis name, e.g., `Warsaw` or `JMS`.
    sector : str, optional
        The RGE sector of interest. If `None`, all sectors are included.
    split_re_im : bool, optional
        If `True`, split complex Wilson coefficients into their real and imaginary parts.
        If `False`, keep them as complex parameters. Default is `True`.

    Returns
    -------
    list
        A sorted list of Wilson coefficient names. If `split_re_im` is `True`,
        complex coefficients are represented as tuples `(name, 'R')` and `(name, 'I')`
        for their real and imaginary parts, respectively.
    '''
    from wilson import wcxf
    basis_obj = wcxf.Basis[eft, basis]
    wc_list = []

    if sector and sector not in basis_obj.sectors.keys():
        raise ValueError(f"Sector {sector} not found in basis {basis} of EFT {eft}")

    if split_re_im:
        for sec, s in basis_obj.sectors.items():
            if not sector or sec == sector:
                for name, d in s.items():
                    if not d or 'real' not in d or not d['real']:
                        wc_list.append((name, 'R'))
                        wc_list.append((name, 'I'))
                    else:
                        wc_list.append((name, 'R'))
    else:
        for sec, s in basis_obj.sectors.items():
            if not sector or sec == sector:
                for name, d in s.items():
                    wc_list.append(name)
    return sorted(wc_list)

keys_array(keys)

Converts a list of tuples into a numpy array.

Parameters:

Name Type Description Default
keys list

A list containing tuples.

required

Returns:

Type Description
`np.ndarray`

A numpy array with dtype=tuple containing the provided keys.

Source code in jelli/utils/par_helpers.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
def keys_array(keys):
    """
    Converts a list of tuples into a numpy array.

    Parameters
    ----------
    keys : list
        A list containing tuples.

    Returns
    -------
    `np.ndarray`
        A numpy array with dtype=tuple containing the provided keys.
    """
    array = np.empty(len(keys), dtype=tuple)
    array[:] = keys
    return array

keys_isin(keys_a, keys_b)

Checks if elements in keys_a exist in keys_b.

Parameters:

Name Type Description Default
keys_a list

List of keys to check.

required
keys_b list

List of reference keys.

required

Returns:

Type Description
`np.ndarray`

Boolean numpy array indicating presence of each key in keys_a within keys_b.

Source code in jelli/utils/par_helpers.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def keys_isin(keys_a, keys_b):
    """
    Checks if elements in `keys_a` exist in `keys_b`.

    Parameters
    ----------
    keys_a : list
        List of keys to check.
    keys_b : list
        List of reference keys.

    Returns
    -------
    `np.ndarray`
        Boolean numpy array indicating presence of each key in `keys_a` within `keys_b`.
    """
    set_b = set(keys_b)
    res = np.array([item in set_b for item in keys_a])
    return res if res.size > 0 else np.array([], dtype=bool)

keys_product(keys_a, keys_b)

Computes the Cartesian product of two sets of keys, producing bilinear combinations.

Parameters:

Name Type Description Default
keys_a

A list where each element is a tuple of the form (w, c).

required
keys_b

Another list with elements of the form (w, c).

required

Returns:

Type Description
list

A list of bilinear combinations in the form (w_a, w_b, c_a + c_b).

Source code in jelli/utils/par_helpers.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def keys_product(keys_a, keys_b):
    """
    Computes the Cartesian product of two sets of keys, producing bilinear combinations.

    Parameters
    ----------
    keys_a: list
        A list where each element is a tuple of the form (w, c).
    keys_b: list
        Another list with elements of the form (w, c).

    Returns
    -------
    list
        A list of bilinear combinations in the form (w_a, w_b, c_a + c_b).
    """
    if len(keys_a[0]) == 2:
        return [
            (w_a, w_b, c_a+c_b)
            for ((w_a, c_a), (w_b, c_b)) in product(keys_a, keys_b)
        ]
    else:
        raise ValueError("keys must be of the form (w,c)")