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

spedas / pyspedas / 23096825121

14 Mar 2026 09:34PM UTC coverage: 10.65% (-79.8%) from 90.486%
23096825121

push

github

jameswilburlewis
Allow uploading of hidden files

5208 of 48900 relevant lines covered (10.65%)

0.11 hits per line

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

33.33
/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):
1✔
13
    """
14
    Takes the derivative of the tplot variable.
15

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

23
    Returns
24
    -------
25
        None
26

27
    Examples
28
    --------
29

30
        >>> 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]]})
31
        >>> pyspedas.derive('b','dbdt')
32

33
    """
34

35
    a = pyspedas.tplot_tools.data_quants[tvar].differentiate('time')
×
36
    if newname is None:
×
37
        a.name = tvar
×
38
        a.attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
39
        pyspedas.tplot_tools.data_quants[tvar] = a
×
40
    else:
41
        data = {'x':a.coords['time'], 'y':a.values * 1e09}  # Internal time in units of nanoseconds
×
42
        for coord in a.coords:
×
43
            if coord != 'time' and coord != 'spec_bins':
×
44
                data[coord] = a.coords[coord].values
×
45

46
        store_data(newname, data=data)
×
47
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
48

49
    return
×
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