Skip to content

compute invariant K

el_paso.processing.compute_invariant_K

Functions:

el_paso.processing.compute_invariant_K.compute_invariant_K

compute_invariant_K

Computes the invariant K from mirror magnetic field and the second adiabatic invariant (I).

The invariant K is calculated as the square root of the mirror magnetic field (\(B_{mirr}\)) multiplied by the second adiabatic invariant (\(X_J\)). The unit of the resulting invariant K is \(R_E \cdot G^{0.5}\).

Parameters:

Name Type Description Default
bmirr Variable

A Variable object containing the mirror magnetic field data. The data is expected to be convertible to Gauss (u.G).

required
xj Variable

A Variable object containing the second adiabativ invariant (I).

required

Returns:

Type Description
Variable

ep.Variable: A new Variable object containing the computed invariant K data with unit \(R_E \cdot G^{0.5}\).

Source code in el_paso/processing/compute_invariant_K.py
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
def compute_invariant_K(
    bmirr: ep.Variable,
    xj: ep.Variable,
) -> ep.Variable:
    r"""Computes the invariant K from mirror magnetic field and the second adiabatic invariant (I).

    The invariant K is calculated as the square root of the mirror magnetic
    field ($B_{mirr}$) multiplied by the second adiabatic invariant ($X_J$).
    The unit of the resulting invariant K is $R_E \cdot G^{0.5}$.

    Args:
        bmirr (ep.Variable): A Variable object containing the mirror magnetic
            field data. The data is expected to be convertible to Gauss (u.G).
        xj (ep.Variable): A Variable object containing the second adiabativ invariant (I).

    Returns:
        ep.Variable: A new Variable object containing the computed invariant K
            data with unit $R_E \cdot G^{0.5}$.
    """
    bmirr_data = bmirr.get_data(u.G).astype(np.float64)

    xj_data = xj.get_data(ep.units.RE).astype(np.float64)

    inv_K_var = ep.Variable(
        data=np.sqrt(bmirr_data) * xj_data,
        original_unit=ep.units.RE * u.G**0.5,
    )

    inv_K_var.metadata.add_processing_note("Created with compute_invariant_K from B_mirr and XJ.")

    return inv_K_var