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

spedas / pyspedas / 16972251084

14 Aug 2025 05:28PM UTC coverage: 89.527% (+0.01%) from 89.515%
16972251084

push

github

jameswilburlewis
Tweaked wording and formatting for readthedocs

40100 of 44791 relevant lines covered (89.53%)

0.9 hits per line

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

71.43
/pyspedas/pytplot/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.pytplot 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✔
38
        logging.info("derive: The new_tvar parameter is deprecated. Please use newname instead.")
×
39
        newname = new_tvar
×
40

41
    a = pyspedas.pytplot.data_quants[tvar].differentiate('time')
1✔
42
    if newname is None:
1✔
43
        a.name = tvar
×
44
        a.attrs = copy.deepcopy(pyspedas.pytplot.data_quants[tvar].attrs)
×
45
        pyspedas.pytplot.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✔
50
                data[coord] = a.coords[coord].values
×
51

52
        store_data(newname, data=data)
1✔
53
        pyspedas.pytplot.data_quants[newname].attrs = copy.deepcopy(pyspedas.pytplot.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