• 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

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

12
def clip(tvar,ymin,ymax,newname=None):
3✔
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)
3✔
43
    if len(tn) == 0:
3✔
44
        return
×
45
    elif len(tn) > 1:
3✔
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))
3✔
52
    a = copy.deepcopy(a.where(a <= ymax))
3✔
53

54
    if newname is None:
3✔
55
        a.name = tvar
3✔
56
        pyspedas.tplot_tools.data_quants[tvar] = a
3✔
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
3✔
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