• 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

82.61
/pyspedas/tplot_tools/convert_tplotxarray_to_pandas_dataframe.py
1
# Copyright 2018 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 datetime
1✔
7
import numpy as np
1✔
8
from dateutil.parser import parse
1✔
9
import pyspedas
1✔
10
import copy
1✔
11

12

13
def convert_tplotxarray_to_pandas_dataframe(name, no_spec_bins=False):
1✔
14
    import pandas as pd
1✔
15
    # This function is not final, and will presumably change in the future
16
    # This function sums over all dimensions except for the second non-time one.
17
    # This collapses many dimensions into just a single "energy bin" dimensions
18

19
    matrix = pyspedas.tplot_tools.data_quants[name].values
1✔
20
    while len(matrix.shape) > 3:
1✔
NEW
21
        matrix = np.nansum(matrix, 3)
×
22
    if len(matrix.shape) == 3:
1✔
NEW
23
        matrix = np.nansum(matrix, 1)
×
24
    return_data = pd.DataFrame(matrix)
1✔
25
    return_data = return_data.set_index(pd.Index(pyspedas.tplot_tools.data_quants[name].coords['time'].values))
1✔
26

27
    if no_spec_bins:
1✔
28
        return return_data
1✔
29

30
    if 'spec_bins' in pyspedas.tplot_tools.data_quants[name].coords:
1✔
31
        spec_bins = pd.DataFrame(pyspedas.tplot_tools.data_quants[name].coords['spec_bins'].values)
1✔
32
        if len(pyspedas.tplot_tools.data_quants[name].coords['spec_bins'].shape) == 1:
1✔
NEW
33
            spec_bins = spec_bins.transpose()
×
34
        else:
35
            spec_bins = spec_bins.set_index(pd.Index(pyspedas.tplot_tools.data_quants[name].coords['time'].values))
1✔
36

37
        return return_data, spec_bins
1✔
38

NEW
39
    return return_data
×
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