• 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

80.95
/pyspedas/tplot_tools/tplot_math/spec_mult.py
1
"""
2
Multiplies data by stored spectrogram bins, creates new tplot variable
3

4
Notes
5
-----
6
Similar to spec_mult.pro in IDL SPEDAS.
7

8
"""
9

10
import pyspedas
1✔
11
from pyspedas.tplot_tools import store_data, convert_tplotxarray_to_pandas_dataframe
1✔
12
import pandas as pd
1✔
13
import copy
1✔
14
import logging
1✔
15

16
def spec_mult(
1✔
17
        tvar,
18
        newname=None,
19
        new_tvar=None
20
):
21

22
    """
23
    Multiplies the data by the stored spectrogram bins and created a new tplot variable
24

25
    Note::
26
        This analysis routine assumes the data is no more than 2 dimensions.
27
        If there are more, they may become flattened!
28

29
    Parameters
30
    ----------
31
        tvar : str
32
            Name of tplot variable
33
        newname : str
34
            Name of new tvar in which to store interpolated data.
35
            Default: If none is specified, a name will be created of the form tvar_specmult.
36
        new_tvar : str (Deprecated)
37
            Name of new tvar in which to store interpolated data.  If none is specified, a name will be created.
38

39
    Returns
40
    -------
41
        None
42

43
    Examples
44
    --------
45
        >>> pyspedas.store_data('h', data={'x':[0,4,8,12,16,19,21], 'y':[[8,1,1],[100,2,3],[4,2,47],[4,39,5],[5,5,99],[6,6,25],[7,-2,-5]],'v':[[1,1,50],[2,2,3],[100,4,47],[4,90,5],[5,5,99],[6,6,25],[7,7,-5]]})
46
        >>> pyspedas.spec_mult('h')
47

48
    """
49

50
    # new_tvar is deprecated in favor of newname
51
    if new_tvar is not None:
1✔
NEW
52
        logging.info("spec_mult: The new_tvar parameter is deprecated. Please use newname instead.")
×
NEW
53
        newname = new_tvar
×
54

55
    if newname is None:
1✔
56
        newname = tvar+'_specmult'
1✔
57
    if 'spec_bins' not in pyspedas.tplot_tools.data_quants[tvar].coords:
1✔
NEW
58
        logging.error("Specified variable must have spec bins stored.  Returning...")
×
NEW
59
        return
×
60
    d, s = convert_tplotxarray_to_pandas_dataframe(tvar)
1✔
61
    dataframe = d.values
1✔
62
    specframe = s.values
1✔
63
    new_df = pd.DataFrame(dataframe*specframe, columns=d.columns, index=d.index)
1✔
64
    store_data(newname,data={'x': new_df.index,'y': new_df.values})
1✔
65
    pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
1✔
66
    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