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

spedas / pyspedas / 23099976064

15 Mar 2026 12:47AM UTC coverage: 23.685% (-4.9%) from 28.587%
23099976064

push

github

jameswilburlewis
Tweaking the ACE test_data_dir test to see why it's failing in parallel tests

2 of 2 new or added lines in 1 file covered. (100.0%)

4936 existing lines in 87 files now uncovered.

11582 of 48901 relevant lines covered (23.68%)

0.24 hits per line

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

27.78
/pyspedas/tplot_tools/tplot_math/subtract.py
1
# Copyright 2020 Regents of the University of Colorado. All Rights Reserved.
2
# Released under the MIT license.
3
# This software was developed at the University of Colorado's Laboratory for Atmospheric and Space Physics.
4
# Verify current version before use at: https://github.com/MAVENSDC/Pytplot
5

6
import pyspedas
1✔
7
from pyspedas.tplot_tools import store_data, tinterp
1✔
8
import copy
1✔
9
import logging
1✔
10

11
def subtract(
1✔
12
        tvar1,
13
        tvar2,
14
        newname=None,
15
):
16
    """
17
    Subtracts two tplot variables.  Will interpolate if the two are not on the same time cadence.
18

19
    Parameters
20
    ----------
21
        tvar1 : str
22
            Name of first tplot variable.
23
        tvar2 : int/float
24
            Name of second tplot variable
25
        newname : str
26
            Name of new tvar for added data.
27
            Default: None. If not set, then the data in tvar1 is replaced.
28

29
    Returns
30
    -------
31
        None
32

33
    Examples
34
    --------
35
        >>> pyspedas.store_data('a', data={'x':[0,4,8,12,16], 'y':[1,2,3,4,5]})
36
        >>> pyspedas.store_data('c', data={'x':[0,4,8,12,16,19,21], 'y':[1,4,1,7,1,9,1]})
37
        >>> pyspedas.subtract('a','c',newname='a-c')
38

39
    """
40

41
    #interpolate tvars
UNCOV
42
    tv2 = tinterp(tvar1,tvar2)
×
43

44
    #separate and subtract data
UNCOV
45
    data1 = pyspedas.tplot_tools.data_quants[tvar1].values
×
UNCOV
46
    data2 = pyspedas.tplot_tools.data_quants[tv2].values
×
UNCOV
47
    data = data1 - data2
×
48

49
    #store subtracted data
UNCOV
50
    if newname is None:
×
51
        pyspedas.tplot_tools.data_quants[tvar1].values = data
×
52
        return tvar1
×
53

UNCOV
54
    if 'spec_bins' in pyspedas.tplot_tools.data_quants[tvar1].coords:
×
UNCOV
55
        store_data(newname, data={'x': pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data, 'v':pyspedas.tplot_tools.data_quants[tvar1].coords['spec_bins'].values})
×
UNCOV
56
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
×
57
    else:
UNCOV
58
        store_data(newname,data={'x': pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data})
×
UNCOV
59
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
×
60

UNCOV
61
    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