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

spedas / pyspedas / 26171438601

20 May 2026 02:07AM UTC coverage: 90.571% (+0.01%) from 90.557%
26171438601

push

github

jameswilburlewis
Fix crash when a spectrogram is plotted with Y axis interpolation is enabled and Y scaling is linear.
Add regression test for y_interp bug.

0 of 4 new or added lines in 2 files covered. (0.0%)

17831 existing lines in 383 files now uncovered.

44379 of 48999 relevant lines covered (90.57%)

1.43 hits per line

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

77.78
/pyspedas/tplot_tools/tplot_math/add.py
1
# Copyright 2018 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
2✔
7
import copy
2✔
8
import logging
2✔
9
from pyspedas.tplot_tools import store_data, tinterp
2✔
10

11
def add(tvar1,tvar2,newname=None):
2✔
12
    """
13
    Adds two tplot variables together.  Will interpolate if the two are not on the same time cadence.
14

15
    Parameters:
16
        tvar1 : str
17
            Name of first tplot variable.
18
        tvar2 : int/float
19
            Name of second tplot variable
20
        newname : str
21
            Name of new tvar for added data.  If not set, then the data in tvar1 is replaced.
22

23
    Returns:
24
        None
25

26
    Examples
27
    --------
28

29
        >>> pyspedas.store_data('a', data={'x':[0,4,8,12,16], 'y':[1,2,3,4,5]})
30
        >>> pyspedas.store_data('c', data={'x':[0,4,8,12,16,19,21], 'y':[1,4,1,7,1,9,1]})
31
        >>> pyspedas.add('a','c',newname='a+c')
32
        >>> pyspedas.get_data('a+c')
33
    """
34

35
    # interpolate tvars
UNCOV
36
    tv2 = tinterp(tvar1, tvar2)
1✔
37

38
    # separate and subtract data
UNCOV
39
    data1 = pyspedas.tplot_tools.data_quants[tvar1].values
1✔
UNCOV
40
    data2 = pyspedas.tplot_tools.data_quants[tv2].values
1✔
UNCOV
41
    data = data1 + data2
1✔
42

43
    # store subtracted data
UNCOV
44
    if newname is None:
1✔
45
        pyspedas.tplot_tools.data_quants[tvar1].values = data
×
46
        return tvar1
×
47

UNCOV
48
    if 'spec_bins' in pyspedas.tplot_tools.data_quants[tvar1].coords:
1✔
49
        store_data(newname, data={'x': pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data,
×
50
                                           'v': pyspedas.tplot_tools.data_quants[tvar1].coords['spec_bins'].values})
51
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
×
52
    else:
UNCOV
53
       store_data(newname, data={'x': pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data})
1✔
UNCOV
54
       pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
1✔
55

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