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

spedas / pyspedas / 23369877357

21 Mar 2026 02:13AM UTC coverage: 90.512% (+0.02%) from 90.497%
23369877357

push

github

web-flow
Merge pull request #1342 from spedas/t_1341

Adds support to load USGS Variometer data, adds test cases for loading variometer data.

13 of 48 new or added lines in 3 files covered. (27.08%)

10491 existing lines in 260 files now uncovered.

44303 of 48947 relevant lines covered (90.51%)

1.6 hits per line

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

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

6

7
def multiply(tvar1, tvar2, newname=None):
2✔
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)
1✔
40
    # separate and multiply data
UNCOV
41
    data1 = pyspedas.tplot_tools.data_quants[tvar1].values
1✔
UNCOV
42
    data2 = pyspedas.tplot_tools.data_quants[tv2].values
1✔
UNCOV
43
    data = data1 * data2
1✔
44

UNCOV
45
    if newname is None:
1✔
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:
1✔
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(
1✔
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(
1✔
67
            pyspedas.tplot_tools.data_quants[tvar1].attrs
68
        )
UNCOV
69
    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