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

spedas / pyspedas / 23096825121

14 Mar 2026 09:34PM UTC coverage: 10.65% (-79.8%) from 90.486%
23096825121

push

github

jameswilburlewis
Allow uploading of hidden files

5208 of 48900 relevant lines covered (10.65%)

0.11 hits per line

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

26.09
/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
×
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
×
20
    while len(matrix.shape) > 3:
×
21
        matrix = np.nansum(matrix, 3)
×
22
    if len(matrix.shape) == 3:
×
23
        matrix = np.nansum(matrix, 1)
×
24
    return_data = pd.DataFrame(matrix)
×
25
    return_data = return_data.set_index(pd.Index(pyspedas.tplot_tools.data_quants[name].coords['time'].values))
×
26

27
    if no_spec_bins:
×
28
        return return_data
×
29

30
    if 'spec_bins' in pyspedas.tplot_tools.data_quants[name].coords:
×
31
        spec_bins = pd.DataFrame(pyspedas.tplot_tools.data_quants[name].coords['spec_bins'].values)
×
32
        if len(pyspedas.tplot_tools.data_quants[name].coords['spec_bins'].shape) == 1:
×
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))
×
36

37
        return return_data, spec_bins
×
38

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