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

spedas / pyspedas / 25194239086

26 Apr 2026 08:07PM UTC coverage: 61.697% (-28.8%) from 90.54%
25194239086

push

github

jameswilburlewis
Added test for loading Cluster CODIF differential energy flux

0 of 7 new or added lines in 1 file covered. (0.0%)

19460 existing lines in 418 files now uncovered.

30204 of 48955 relevant lines covered (61.7%)

1.44 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
3✔
11
from pyspedas.tplot_tools import store_data, convert_tplotxarray_to_pandas_dataframe
3✔
12
import pandas as pd
3✔
13
import copy
3✔
14
import logging
3✔
15

16
def spec_mult(
3✔
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

UNCOV
47
    if newname is None:
×
UNCOV
48
        newname = tvar+'_specmult'
×
UNCOV
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
×
UNCOV
52
    d, s = convert_tplotxarray_to_pandas_dataframe(tvar)
×
UNCOV
53
    dataframe = d.values
×
UNCOV
54
    specframe = s.values
×
UNCOV
55
    new_df = pd.DataFrame(dataframe*specframe, columns=d.columns, index=d.index)
×
UNCOV
56
    store_data(newname,data={'x': new_df.index,'y': new_df.values})
×
UNCOV
57
    pyspedas.tplot_tools.data_quants[newname].attrs = copy.deepcopy(pyspedas.tplot_tools.data_quants[tvar].attrs)
×
UNCOV
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