• 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

27.78
/pyspedas/tplot_tools/tplot_math/multiply.py
1
import pyspedas
3✔
2
from pyspedas.tplot_tools import store_data, tinterp
3✔
3
import copy
3✔
4
import logging
3✔
5

6

7
def multiply(tvar1, tvar2, newname=None):
3✔
8
    """
9
    Multiplies two tplot variables.  Will interpolate if the two are not on the same time cadence.
10

11
    Parameters
12
    ----------
13
        tvar1 : str
14
            Name of first tplot variable.
15
        tvar2 : int/float
16
            Name of second tplot variable.
17
        newname : str
18
            Name of new tplot variable.  If not set, then the data in tvar1 is replaced.
19

20
    Returns
21
    -------
22
        None
23

24
    Examples
25
    --------
26
        >>> x1 = [0, 4, 8, 12, 16]
27
        >>> x2 = [0, 4, 8, 12, 16, 19, 21]
28
        >>> time1 = [pyspedas.time_float("2020-01-01") + i for i in x1]
29
        >>> time2 = [pyspedas.time_float("2020-01-01") + i for i in x2]
30
        >>> pyspedas.store_data("a", data={"x": time1, "y": [1, 2, 3, 4, 5]})
31
        >>> pyspedas.store_data("c", data={"x": time2, "y": [1, 4, 1, 7, 1, 9, 1]})
32
        >>> n = pyspedas.multiply("a", "c", newname="a_x_c")
33
        >>> print('new tplot variable:', n)
34
        >>> ac = pyspedas.get_data(n)
35
        >>> print(ac)
36
    """
37

38
    # interpolate tvars
UNCOV
39
    tv2 = tinterp(tvar1, tvar2)
×
40
    # separate and multiply data
UNCOV
41
    data1 = pyspedas.tplot_tools.data_quants[tvar1].values
×
UNCOV
42
    data2 = pyspedas.tplot_tools.data_quants[tv2].values
×
UNCOV
43
    data = data1 * data2
×
44

UNCOV
45
    if newname is None:
×
46
        pyspedas.tplot_tools.data_quants[tvar1].values = data
×
47
        return tvar1
×
48

UNCOV
49
    if "spec_bins" in pyspedas.tplot_tools.data_quants[tvar1].coords:
×
50
        store_data(
×
51
            newname,
52
            data={
53
                "x": pyspedas.tplot_tools.data_quants[tvar1].coords["time"].values,
54
                "y": data,
55
                "v": pyspedas.tplot_tools.data_quants[tvar1].coords["spec_bins"].values,
56
            },
57
        )
58
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(
×
59
            pyspedas.tplot_tools.data_quants[tvar1].attrs
60
        )
61
    else:
UNCOV
62
       store_data(
×
63
            newname,
64
            data={"x": pyspedas.tplot_tools.data_quants[tvar1].coords["time"].values, "y": data},
65
        )
UNCOV
66
       pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(
×
67
            pyspedas.tplot_tools.data_quants[tvar1].attrs
68
        )
UNCOV
69
    return newname
×
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