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

spedas / pyspedas / 26655063443

29 May 2026 06:30PM UTC coverage: 89.5% (-0.7%) from 90.151%
26655063443

push

github

jameswilburlewis
Temporarily commenting out SECS tests (UCLA site is down)

43845 of 48989 relevant lines covered (89.5%)

1.58 hits per line

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

78.95
/pyspedas/tplot_tools/tplot_math/divide.py
1
# Copyright 2020 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, tinterp
2✔
8
import numpy as np
2✔
9
import copy
2✔
10
import logging
2✔
11

12
def divide(tvar1,tvar2,newname=None):
2✔
13
    """
14
    Divides two tplot variables.  Will interpolate if the two are not on the same time cadence.
15

16
    Parameters
17
    ----------
18
        tvar1 : str
19
            Name of first tplot variable.
20
        tvar2 : int/float
21
            Name of second tplot variable
22
        newname : str
23
            Name of new tvar for divided data.  If not set, then the data in tvar1 is replaced.
24

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

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

32
        >>> pyspedas.store_data('a', data={'x':[0,4,8,12,16], 'y':[1,2,3,4,5]})
33
        >>> pyspedas.store_data('c', data={'x':[0,4,8,12,16,19,21], 'y':[1,4,1,7,1,9,1]})
34
        >>> pyspedas.divide('a','c','a_over_c')
35
        """
36

37
    # interpolate tvars
38
    tv2 = tinterp(tvar1, tvar2)
1✔
39
    # separate and divide data
40
    data1 = pyspedas.tplot_tools.data_quants[tvar1].values
1✔
41
    data2 = pyspedas.tplot_tools.data_quants[tv2].values
1✔
42
    data = data1 / data2
1✔
43
    # store divided data
44
    if newname is None:
1✔
45
        pyspedas.tplot_tools.data_quants[tvar1].values = data
×
46
        return tvar1
×
47
    if 'spec_bins' in pyspedas.tplot_tools.data_quants[tvar1].coords:
1✔
48
        store_data(newname, data={'x': pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data,
×
49
                                           'v': pyspedas.tplot_tools.data_quants[tvar1].coords['spec_bins'].values})
50
        pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
×
51
    else:
52
       store_data(newname, data={'x':pyspedas.tplot_tools.data_quants[tvar1].coords['time'].values, 'y': data})
1✔
53
       pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar1].attrs)
1✔
54

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