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

spedas / pyspedas / 18362798857

09 Oct 2025 01:33AM UTC coverage: 89.477% (-0.01%) from 89.491%
18362798857

push

github

jameswilburlewis
Added test for FEEPS get_err switch

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

35 existing lines in 3 files now uncovered.

40739 of 45530 relevant lines covered (89.48%)

0.89 hits per line

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

96.55
/pyspedas/projects/mms/feeps_tools/feeps.py
1
from pyspedas.projects.mms.mms_load_data import mms_load_data
1✔
2
from pyspedas.projects.mms.feeps_tools.mms_feeps_correct_energies import mms_feeps_correct_energies
1✔
3
from pyspedas.projects.mms.feeps_tools.mms_feeps_flat_field_corrections import mms_feeps_flat_field_corrections
1✔
4
from pyspedas.projects.mms.feeps_tools.mms_feeps_active_eyes import mms_feeps_active_eyes
1✔
5
from pyspedas.projects.mms.feeps_tools.mms_feeps_split_integral_ch import mms_feeps_split_integral_ch
1✔
6
from pyspedas.projects.mms.feeps_tools.mms_feeps_remove_bad_data import mms_feeps_remove_bad_data
1✔
7
from pyspedas.projects.mms.feeps_tools.mms_feeps_remove_sun import mms_feeps_remove_sun
1✔
8
from pyspedas.projects.mms.feeps_tools.mms_feeps_omni import mms_feeps_omni
1✔
9
from pyspedas.projects.mms.feeps_tools.mms_feeps_spin_avg import mms_feeps_spin_avg
1✔
10
from pyspedas.projects.mms.mms_config import CONFIG
1✔
11
from pyspedas.tplot_tools import time_clip as tclip
1✔
12

13
def recvary_log_filter(log):
1✔
14
    if 'record-varying' in log.msg:
1✔
15
        return False
1✔
16
    else:
17
        return True
1✔
18

19
def mms_load_feeps(trange=['2015-10-16', '2015-10-17'],
1✔
20
                   probe='1',
21
                   data_rate='srvy',
22
                   level='l2',
23
                   datatype='electron',
24
                   varformat=None,
25
                   varnames=[],
26
                   get_support_data=True,
27
                   suffix='',
28
                   time_clip=False,
29
                   no_update=False,
30
                   available=False,
31
                   notplot=False,
32
                   no_flatfield_corrections=False,
33
                   data_units=['count_rate', 'intensity'],
34
                   latest_version=False,
35
                   major_version=False,
36
                   min_version=None,
37
                   cdf_version=None,
38
                   spdf=False,
39
                   always_prompt=False,
40
                   filter_recvary_warnings=True,
41
                   quality_flag=3,
42
                   get_err=False,
43
                   ):
44
    """
45
    Load data from the MMS Fly's Eye Energetic Particle Sensor (FEEPS)
46
    
47
    Parameters
48
    ----------
49
        trange : list of str
50
            time range of interest [start time, end time] with the format
51
            'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day 
52
            ['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss']
53
            Default: ['2015-10-16','2015-10-17']
54

55
        probe : str or list of str
56
            list of probes, valid values for MMS probes are ['1','2','3','4'].
57
            Default: '1'
58

59
        data_rate : str or list of str
60
            instrument data rates for FEEPS include ['brst', 'srvy'].
61
            Default: 'srvy'
62

63
        level : str
64
            indicates level of data processing. the default if no level is specified is 'l2'
65
            Default: 'l2'
66

67
        datatype : str or list of str
68
            Valid datatypes for FEEPS are::
69

70
                       L2, L1b: ['electron', 'ion']
71
                       L1a: ['electron-bottom', 'electron-top', 'ion-bottom', 'ion-top']
72

73
            Default: 'electron'
74

75
        data_units : str or list of str
76
            Unit types to be loaded, options are 'count_rate', 'intensity'
77
            Default: ['count_rate', 'intensity']
78

79
        no_flatfield_corrections: bool
80
            If True, no flatfield corrections are performed.
81
            Default: False
82

83
        get_support_data: bool
84
            Data with an attribute "VAR_TYPE" with a value of "support_data"
85
            will be loaded into tplot.
86
            Default: True
87

88
        time_clip: bool
89
            Data will be clipped to the exact trange specified by the trange keyword.
90
            Default: False
91
            
92
        varformat: str
93
            The file variable formats to load into tplot.  Wildcard character
94
            "*" is accepted.
95
            Default: None (all variables are loaded)
96

97
        varnames: list of str
98
            List of variable names to load. If list is empty or not specified,
99
            all data variables are loaded.
100
            Default: []
101

102
        suffix: str
103
            The tplot variable names will be given this suffix.  By default, 
104
            no suffix is added.
105
            Default: None
106

107
        notplot: bool
108
            If True, then data are returned in a hash table instead of 
109
            being stored in tplot variables (useful for debugging, and
110
            access to multidimensional data products)
111
            Default: False
112

113
        available: bool
114
            If True, simply return the available data files (without downloading)
115
            for the requested parameters
116
            Default: False
117

118
        no_update: bool
119
            Set this flag to preserve the original data. if not set and newer 
120
            data is found the existing data will be overwritten
121
            Default: False
122

123
        cdf_version: str
124
            Specify a specific CDF version # to load (e.g., cdf_version='4.3.0')
125
            Default: None
126

127
        min_version: str
128
            Specify a minimum CDF version # to load
129
            Default: None
130

131
        latest_version: bool
132
            Only grab the latest CDF version in the requested time interval
133

134
        major_version: bool
135
            Only open the latest major CDF version (e.g., X in vX.Y.Z) in the requested time interval
136

137
        always_prompt: bool
138
            Set this keyword to always prompt for the user's username and password;
139
            useful if you accidentally save an incorrect password, or if your SDC password has changed
140

141
        spdf: bool
142
            If True, download the data from the SPDF instead of the SDC
143

144
        filter_recvary_warnings: bool
145
            If True, capture warnings from cdf_to_tplot and filter out the ones complaining about non-record-varying support data with timestamps
146

147
        quality_flag: int
148
            Value can range from 2-4. Determines which eyes to use to calculate omnidirectional flux at a given time
149
            based on how many sectors were masked for sunlight. For BRST or RAW::
150

151
                Green (Quality Indicator = 0): No contaminated or masked spin sectors (best data quality)
152
                Red (Quality Indicator = 3): Contaminated spin sector is associated with BURST and RAW data
153
                    (this data is not recommended for scientific use)
154
                Grey (Quality Indicator = 4): FEEPS calibration data (this data is generated by the instrument itself
155
                    and is not recommended for scientific use)
156

157
            For data in SURVEY mode, there are 5 possible quality indicators::
158

159
                Green (Quality Indicator = 0): No contaminated or masked spin sectors (best data quality)
160
                Yellow (Quality Indicator = 1): Among the spin sectors used to create a SURVEY aggregate
161
                     spin sector, onboard masking is successfully applied to a minimum of 1 and a maximum of 7
162
                     spin sectors and there is no contamination in any of the individual spin sectors. Note that
163
                     since this indicator applies only when onboard masking is applied, some sectors are not
164
                     observed.
165
                Orange (Quality Indicator = 2): There is contamination of between 0 and 50% of the notmasked sectors. Warning: this data contains contamination.
166
                Red (Quality Indicator = 3): Same as orange except that there is contamination of 50% or
167
                     more of the not-masked sectors. IN ADDITION, this indicator applies to the case where
168
                     onboard masking is applied to all 8 spin sectors in the aggregate sector.
169
                Grey (Quality Indicator = 4): FEEPS calibration data (this data is generated by the instrument
170
                     itself and is not recommended for scientific use)
171

172
        get_err: bool
173
            Gets the error in the omnidirectional l2 intensity.  Default: False. User MUST run mms_load_feeps for the
174
            l1b counts data FIRST to use this function. (Note: the FEEPS l1b data needed for this switch is restricted
175
            to MMS team members at present.)
176

177

178
    Returns
179
    --------
180
        list of str
181
            List of tplot variables created.
182

183
    Example
184
    -------
185

186
    >>> import pyspedas
187
    >>> from pyspedas import tplot
188
    >>> feeps_data = pyspedas.projects.mms.mms_load_feeps(trange=['2015-10-16', '2015-10-17'], probe='1', datatype='electron')
189
    >>> tplot(['mms1_epd_feeps_srvy_l2_electron_intensity_omni_spin', 'mms1_epd_feeps_srvy_l2_electron_intensity_omni'])
190

191

192

193
    """
194

195
    # For log filtering
196
    from pyspedas import logger
1✔
197
    # as of 3 July 2023, there's a mixture of v7.x.x and v6.x.x files at the SDC
198
    # these files aren't compatible, so we need to only load the latest major version
199
    # to avoid crashes (unless otherwise specified)
200
    if not latest_version and not major_version and min_version is None and cdf_version is None:
1✔
201
        major_version = True
1✔
202

203
    if filter_recvary_warnings:
1✔
204
        logger.addFilter(recvary_log_filter)
1✔
205

206
    tvars = mms_load_data(trange=trange, notplot=notplot, probe=probe, data_rate=data_rate, level=level, instrument='feeps',
1✔
207
            datatype=datatype, varformat=varformat, varnames=varnames, get_support_data=get_support_data, suffix=suffix,
208
            no_update=no_update, available=available, latest_version=latest_version,
209
            major_version=major_version, min_version=min_version, cdf_version=cdf_version, spdf=spdf, always_prompt=always_prompt)
210

211
    if filter_recvary_warnings:
1✔
212
        logger.removeFilter(recvary_log_filter)
1✔
213

214
    if tvars == [] or available or notplot or CONFIG['download_only'] or tvars is None:
1✔
UNCOV
215
        return tvars
×
216

217
    probes = probe if isinstance(probe, list) else [probe]
1✔
218
    data_rates = data_rate if isinstance(data_rate, list) else [data_rate]
1✔
219
    levels = level if isinstance(level, list) else [level]
1✔
220
    datatypes = datatype if isinstance(datatype, list) else [datatype]
1✔
221
    data_units = data_units if isinstance(data_units, list) else [data_units]
1✔
222

223
    probes = [str(p) for p in probes]
1✔
224

225
    mms_feeps_correct_energies(probes, data_rate, level=level, suffix=suffix)
1✔
226

227
    if not no_flatfield_corrections:
1✔
228
        mms_feeps_flat_field_corrections(probes=probes, data_rate=data_rate, suffix=suffix)
1✔
229

230
    for probe in probes:
1✔
231
        for lvl in levels:
1✔
232
            for drate in data_rates:
1✔
233
                for datatype in datatypes:
1✔
234
                    mms_feeps_remove_bad_data(trange=trange, probe=probe, data_rate=drate, datatype =datatype, level=lvl, suffix=suffix)
1✔
235

236
                    for data_unit in data_units:
1✔
237
                        eyes = mms_feeps_active_eyes(trange, probe, drate, datatype, lvl)
1✔
238

239
                        split_vars = mms_feeps_split_integral_ch(data_unit, datatype, probe, suffix=suffix, data_rate=drate, level=lvl, sensor_eyes=eyes)
1✔
240

241
                        sun_removed_vars = mms_feeps_remove_sun(eyes, trange, probe=probe, datatype=datatype, data_units=data_unit, data_rate=drate, level=lvl, suffix=suffix)
1✔
242

243
                        omni_vars = mms_feeps_omni(eyes, probe=probe, datatype=datatype, data_units=data_unit, data_rate=drate, level=lvl, suffix=suffix, quality_flag=quality_flag, get_err=get_err)
1✔
244

245
                        if split_vars is not None:
1✔
246
                            tvars = tvars + split_vars
1✔
247

248
                        if sun_removed_vars is not None:
1✔
249
                            tvars = tvars + sun_removed_vars
1✔
250

251
                        if omni_vars is not None:
1✔
UNCOV
252
                            tvars = tvars + omni_vars
×
253

254
                        spin_avg_vars = mms_feeps_spin_avg(probe=probe, data_units=data_unit, datatype=datatype, data_rate=drate, level=lvl, suffix=suffix)
1✔
255

256
                        if spin_avg_vars is not None:
1✔
257
                            tvars.append(spin_avg_vars)
1✔
258

259
    if time_clip:
1✔
260
        for new_var in tvars:
1✔
261
            tclip(new_var, trange[0], trange[1], suffix='')
1✔
262

263
    return tvars
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