• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spedas / pyspedas / 25194239086

26 Apr 2026 08:07PM UTC coverage: 61.697% (-28.8%) from 90.54%
25194239086

push

github

jameswilburlewis
Added test for loading Cluster CODIF differential energy flux

0 of 7 new or added lines in 1 file covered. (0.0%)

19460 existing lines in 418 files now uncovered.

30204 of 48955 relevant lines covered (61.7%)

1.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/pyspedas/tplot_tools/tplot_math/tcrossp.py
1
import numpy as np
3✔
2
from pyspedas.tplot_tools import get_data, store_data
3✔
3

4

5
def tcrossp(
3✔
6
        v1,
7
        v2,
8
        newname=None,
9
        return_data=False
10
):
11
    """
12
    Calculates the cross product of two tplot variables
13

14
    Parameters
15
    ----------
16
    v1: str
17
        First tplot variable
18
    v2: str
19
        Second tplot variable
20
    newname: str, optional
21
        Name of the output variable
22
        Default: v1_cross_v2
23
    return_data: bool
24
        Returns the data as an ndarray instead of creating a tplot variable
25
        Default: False
26

27
    Returns
28
    --------
29
    str
30
        Name of the tplot variable created
31

32
    Examples
33
    --------
34

35
        >>> # Compute the cross product of two time series
36
        >>> import pyspedas
37
        >>> x1 = [0, 4, 8]
38
        >>> x2 = [0, 4, 8]
39
        >>> time1 = [pyspedas.time_float("2020-01-01") + i for i in x1]
40
        >>> time2 = [pyspedas.time_float("2020-01-01") + i for i in x2]
41
        >>> pyspedas.store_data("a", data={"x": time1, "y": [[1, 2, 3],[2, 3, 4],[3, 4, 5]]})
42
        >>> pyspedas.store_data("c", data={"x": time2, "y": [[1, 4, 1],[2, 5, 2],[3, 5, 3]]})
43
        >>> n = pyspedas.tcrossp("a", "c", newname="a_cross_c")
44
        >>> print('new tplot variable:', n)
45
        >>> ac = pyspedas.get_data(n)
46
        >>> print(ac)
47

48
    """
49

50
    v1_data = None
3✔
51
    v2_data = None
3✔
52

53
    if not isinstance(v1, np.ndarray) and isinstance(v1, str):
3✔
54
        v1_data = get_data(v1)
3✔
55
        v1_name = v1
3✔
56

57
        if v1_data is not None:
3✔
58
            data1 = v1_data[1]
3✔
59
    else:
60
        v1_name = 'var1'
3✔
61
        data1 = v1
3✔
62

63
    if not isinstance(v2, np.ndarray) and isinstance(v2, str):
3✔
64
        v2_data = get_data(v2)
3✔
65
        v2_name = v2
3✔
66

67
        if v2_data is not None:
3✔
68
            data2 = v2_data[1]
3✔
69
    else:
70
        v2_name = 'var2'
3✔
71
        data2 = v2
3✔
72

73
    if newname is None:
3✔
74
        newname = v1_name + '_cross_' + v2_name
3✔
75

76
    cp = np.cross(data1, data2)
3✔
77

78
    if return_data:
3✔
79
        return cp
3✔
80
    else:
UNCOV
81
        out = cp
1✔
UNCOV
82
        if v2_data is None:
1✔
UNCOV
83
            if len(cp.shape) == 1:
1✔
UNCOV
84
                out = np.atleast_2d(cp)
1✔
UNCOV
85
            times = np.zeros(out.shape[0])
1✔
86
        else:
UNCOV
87
            times = v2_data[0]
1✔
UNCOV
88
        store_data(newname, data={'x': times, 'y': out})
1✔
UNCOV
89
        return newname
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc