• 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

75.0
/pyspedas/tplot_tools/tplot_math/clip.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
from pyspedas.tplot_tools import store_data, tnames
2✔
8
import numpy as np
2✔
9
import copy
2✔
10
import logging
2✔
11

12
def clip(tvar,ymin,ymax,newname=None):
2✔
13
    """
14
    Change out-of-bounds data to NaN.
15

16
    Parameters
17
    ----------
18
        tvar : str or list[str]
19
            tplot variable names to clip (wildcards accepted)
20
        ymin : int/float
21
            Minimum value to keep (inclusive)
22
        ymax : int/float
23
            Maximum value to keep (inclusive)
24
        newname : str
25
            Name of new tvar for clipped data storage.  If not specified, tvar will be replaced
26
            THIS is not an option for multiple variable input, for multiple or pseudo variables, the data is overwritten.
27

28
    Returns
29
    -------
30
        None
31

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

35
        >>> Make any values below 2 and above 6 equal to NaN.
36
        >>> pyspedas.store_data('d', data={'x':[2,5,8,11,14,17,21], 'y':[[1,1],[2,2],[100,100],[4,4],[5,5],[6,6],[7,7]]})
37
        >>> pyspedas.clip('d',2,6,'e')
38

39
    """
40

41
    #check for globbed or array input, and call recursively
42
    tn = tnames(tvar)
2✔
43
    if len(tn) == 0:
2✔
44
        return
×
45
    elif len(tn) > 1:
2✔
46
        for j in range(len(tn)):
×
47
            clip(tn[j],ymin,ymax)
×
48
        return
×
49

50

51
    a = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].where(pyspedas.tplot_tools.data_quants[tvar] >= ymin))
2✔
52
    a = copy.deepcopy(a.where(a <= ymax))
2✔
53

54
    if newname is None:
2✔
55
        a.name = tvar
2✔
56
        pyspedas.tplot_tools.data_quants[tvar] = a
2✔
57
    else:
UNCOV
58
        if 'spec_bins' in a.coords:
1✔
59
            store_data(newname, data={'x': a.coords['time'], 'y': a.values, 'v': a.coords['spec_bins']})
×
60
            pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
61
        else:
UNCOV
62
            store_data(newname, data={'x': a.coords['time'], 'y': a.values})
1✔
UNCOV
63
            pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
1✔
64

65
    return
2✔
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