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

spedas / pyspedas / 17001196665

15 Aug 2025 11:12PM UTC coverage: 89.516% (+0.7%) from 88.849%
17001196665

push

github

web-flow
Merge branch 'pyspedas_2_0_dev' into master

5072 of 6199 new or added lines in 413 files covered. (81.82%)

8 existing lines in 2 files now uncovered.

40061 of 44753 relevant lines covered (89.52%)

0.9 hits per line

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

71.43
/pyspedas/tplot_tools/tplot_math/derive.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
1✔
7
from pyspedas.tplot_tools import store_data
1✔
8
import numpy as np
1✔
9
import copy
1✔
10
import logging
1✔
11

12
def derive(tvar,newname=None, new_tvar=None):
1✔
13
    """
14
    Takes the derivative of the tplot variable.
15

16
    Parameters
17
    ----------
18
        tvar : str
19
            Name of tplot variable.
20
        new_tvar : str (Deprecated)
21
            Name of new tplot variable.  If not set, then the data in tvar is replaced.
22
        newname : str
23
            Name of new tplot variable.  If not set, then the data in tvar is replaced.
24

25
    Returns
26
    -------
27
        None
28

29
    Examples
30
    --------
31

32
        >>> pyspedas.store_data('b', data={'x':[2,5,8,11,14,17,20], 'y':[[1,1,1,1,1,1],[2,2,5,4,1,1],[100,100,3,50,1,1],[4,4,8,58,1,1],[5,5,9,21,1,1],[6,6,2,2,1,1],[7,7,1,6,1,1]]})
33
        >>> pyspedas.derive('b','dbdt')
34

35
    """
36
    # new_tvar is deprecated in favor of newname
37
    if new_tvar is not None:
1✔
NEW
38
        logging.info("derive: The new_tvar parameter is deprecated. Please use newname instead.")
×
NEW
39
        newname = new_tvar
×
40

41
    a = pyspedas.tplot_tools.data_quants[tvar].differentiate('time')
1✔
42
    if newname is None:
1✔
NEW
43
        a.name = tvar
×
NEW
44
        a.attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
NEW
45
        pyspedas.tplot_tools.data_quants[tvar] = a
×
46
    else:
47
        data = {'x':a.coords['time'], 'y':a.values * 1e09}  # Internal time in units of nanoseconds
1✔
48
        for coord in a.coords:
1✔
49
            if coord != 'time' and coord != 'spec_bins':
1✔
NEW
50
                data[coord] = a.coords[coord].values
×
51

52
        store_data(newname, data=data)
1✔
53
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
1✔
54

55
    return
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