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

spedas / pyspedas / 25223758709

01 May 2026 04:46PM UTC coverage: 56.446% (-34.1%) from 90.54%
25223758709

push

github

jameswilburlewis
Temporarily disabling Cluster tests due to problems at CSA

27633 of 48955 relevant lines covered (56.45%)

0.56 hits per line

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

33.33
/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
):
20

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

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

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

36
    Returns
37
    -------
38
        None
39

40
    Examples
41
    --------
42
        >>> 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]]})
43
        >>> pyspedas.spec_mult('h')
44

45
    """
46

47
    if newname is None:
×
48
        newname = tvar+'_specmult'
×
49
    if 'spec_bins' not in pyspedas.tplot_tools.data_quants[tvar].coords:
×
50
        logging.error("Specified variable must have spec bins stored.  Returning...")
×
51
        return
×
52
    d, s = convert_tplotxarray_to_pandas_dataframe(tvar)
×
53
    dataframe = d.values
×
54
    specframe = s.values
×
55
    new_df = pd.DataFrame(dataframe*specframe, columns=d.columns, index=d.index)
×
56
    store_data(newname,data={'x': new_df.index,'y': new_df.values})
×
57
    pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
58
    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