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

spedas / pyspedas / 26171438601

20 May 2026 02:07AM UTC coverage: 90.571% (+0.01%) from 90.557%
26171438601

push

github

jameswilburlewis
Fix crash when a spectrogram is plotted with Y axis interpolation is enabled and Y scaling is linear.
Add regression test for y_interp bug.

0 of 4 new or added lines in 2 files covered. (0.0%)

17831 existing lines in 383 files now uncovered.

44379 of 48999 relevant lines covered (90.57%)

1.43 hits per line

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

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

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