def DataLoad(trange=['2017-05-01', '2017-05-02/15:30:02'], data_rate='srvy', level='l2'): ''' Loads all data needed for calculating magnnetic field curvature from MMS FGM data. Uses pyspedas and pytplot.get_data for accessing the SDC API, file downloading, data file version control, and CDF unpacking. Parameters: trange: A list with two strings for the date range [tstart, tend] e.g. trange=['2017-05-01', '2017-05-02/15:30:02'] data_rate: The cadance of data which should be loaded. Options are 'srvy', 'brst' level: The data level which will be loaded. Use 'l2' unless you're sure otherwise. ''' logging.info('Start DataLoad.') # load data files from SDC/local storage into tplot variables pyspedas.mms_load_mec(trange=trange, probe=['1', '2', '3', '4'], data_rate='srvy', level=level, time_clip=True) pyspedas.mms_load_fgm(trange=trange, probe=['1', '2', '3', '4'], data_rate=data_rate, level=level, time_clip=True) # extract data from tplot variables to numpy arrays. NOTE: all done in GSM. postime1, pos1 = get_data('mms1_mec_r_gsm') postime2, pos2 = get_data('mms2_mec_r_gsm') postime3, pos3 = get_data('mms3_mec_r_gsm') postime4, pos4 = get_data('mms4_mec_r_gsm') magtime1, mag1 = get_data('mms1_fgm_b_gsm_'+data_rate+'_l2') magtime2, mag2 = get_data('mms2_fgm_b_gsm_'+data_rate+'_l2') magtime3, mag3 = get_data('mms3_fgm_b_gsm_'+data_rate+'_l2') magtime4, mag4 = get_data('mms4_fgm_b_gsm_'+data_rate+'_l2') # return all arrays logging.info('Returning from DataLoad.') return (postime1, pos1, magtime1, mag1, postime2, pos2, magtime2, mag2, postime3, pos3, magtime3, mag3, postime4, pos4, magtime4, mag4)
from pyspedas import mms_load_fgm mms_load_fgm(trange=['2015-10-16', '2015-10-17'], data_rate='srvy') from pyspedas import mms_load_fpi mms_load_fpi(probe=['3, 4'], trange=['2015-10-16/13:06', '2015-10-16/13:07'], data_rate='brst', datatype='des-moms') from pyspedas.mms import mms_load_mec mms_load_mec(probe=4) help(mms_load_mec) from pyspedas.mms import mms_load_fgm mms_load_fgm(probe'4', data_rate='brst', trange=['2015-10-16/13:06', '2015-10-16/13:07'], time_clip=True) from pytplot import tplot_names tplot_names() from pyspedas.mms import mms_load_edp mms_load_edp(probe='4', data_rate = 'brst', trange=['2015-10-16/13:06', '2015-10-16/13:07'], time_clip=True)
''' This crib sheet produces the MMS basic dayside figure ''' from pyspedas import mms_load_fgm, mms_load_mec, mms_load_edp, mms_load_dsp, mms_load_fpi, mms_load_hpca from pytplot import tplot, options, get_data, store_data import numpy as np probe = '1' trange = ['2015-10-16', '2015-10-17'] mms_load_fgm(probe=probe, data_rate='srvy', trange=trange) mms_load_mec(probe=probe, data_rate='srvy', trange=trange) mms_load_fpi(probe=probe, data_rate='fast', datatype=['des-moms', 'dis-moms'], trange=trange) mms_load_edp(probe=probe, datatype='scpot', trange=trange) mms_load_edp(probe=probe, data_rate='fast', datatype='dce', trange=trange) mms_load_edp(probe=probe, data_rate='srvy', datatype=['dce', 'hfesp'], trange=trange) mms_load_dsp(probe=probe, data_rate='fast', datatype='bpsd', trange=trange) mms_load_hpca(probe=probe, data_rate='srvy', datatype='ion', trange=trange) times, data = get_data('mms' + probe + '_fgm_b_gsm_srvy_l2') store_data('mms' + probe + '_b_gsm_vec', data={ 'x': times,
This crib sheet shows how to calculate plasma beta using FPI and FGM data ''' from pyspedas import tinterpol, mms_load_fpi, mms_load_fgm from pytplot import get_data, store_data, tplot import numpy as np mu0 = 1256.0 # nT-m/A Kb = 1.3807 * 10**(-16.) # cm^2-g-1/s^2-1/K probe = '1' trange = ['2015-10-16/11:00', '2015-10-16/14:00'] mms_load_fpi(datatype=['dis-moms', 'des-moms'], trange=trange, probe=probe) mms_load_fgm(trange=trange, probe=probe) temp_para_i = 'mms' + probe + '_dis_temppara_fast' temp_perp_i = 'mms' + probe + '_dis_tempperp_fast' temp_para_e = 'mms' + probe + '_des_temppara_fast' temp_perp_e = 'mms' + probe + '_des_tempperp_fast' number_density_i = 'mms' + probe + '_dis_numberdensity_fast' number_density_e = 'mms' + probe + '_des_numberdensity_fast' b_field = 'mms' + probe + '_fgm_b_gsm_srvy_l2' b_magnitude = 'mms' + probe + '_fgm_b_gsm_srvy_l2_mag' times, data = get_data(b_field) store_data(b_magnitude, data={'x': times, 'y': data[:, 3]}) ntimes, ndata = get_data(number_density_i)
''' This script loads and prints FGM data at several data points. This is meant to be called from the IDL test suite for comparison with the data loaded via IDL SPEDAS ''' from pyspedas import mms_load_fgm from pytplot import get_data mms_load_fgm() t, d = get_data('mms1_fgm_b_gse_srvy_l2') print(t[0:10].round(6).tolist()) print(d[10000].tolist()) print(d[50000].tolist()) print(d[100000].tolist()) print(d[200000].tolist()) print(d[300000].tolist()) print(d[400000].tolist()) print(d[500000].tolist())
def mms_feeps_pitch_angles(trange=None, probe='1', level='l2', data_rate='srvy', datatype='electron', suffix=''): """ Generates a tplot variable containing the FEEPS pitch angles for each telescope from magnetic field data. Parameters: trange : list of str time range of interest [starttime, endtime] with the format 'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day ['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] probe: str probe #, e.g., '4' for MMS4 level: str data level, e.g., 'l2' data_rate: str instrument data rate, e.g., 'srvy' or 'brst' datatype: str 'electron' or 'ion' suffix: str suffix of the loaded data Returns: Tuple: (tplot variable created, hash table used by PAD routine) """ # get the times from the currently loaded FEEPS data times, pa_data = get_data('mms' + probe + '_epd_feeps_' + data_rate + '_' + level + '_' + datatype + '_pitch_angle' + suffix) if times is not None: if trange is None: trange = [float(times.min()), float(times.max())] eyes = mms_feeps_active_eyes(trange, probe, data_rate, datatype, level) # need the B-field data mms_load_fgm(trange=trange, probe=probe, data_rate=data_rate, varformat='*_b_bcs_*') btimes, Bbcs = get_data('mms' + probe + '_fgm_b_bcs_' + data_rate + '_l2') idx_maps = None # Rotation matrices for FEEPS coord system (FCS) into body coordinate system (BCS): Ttop = [[1. / np.sqrt(2.), -1. / np.sqrt(2.), 0], [1. / np.sqrt(2.), 1. / np.sqrt(2.), 0], [0, 0, 1]] Tbot = [[-1. / np.sqrt(2.), -1. / np.sqrt(2.), 0], [-1. / np.sqrt(2.), 1. / np.sqrt(2.), 0], [0, 0, -1]] # Telescope vectors in FCS: V1fcs = [0.347, -0.837, 0.423] V2fcs = [0.347, -0.837, -0.423] V3fcs = [0.837, -0.347, 0.423] V4fcs = [0.837, -0.347, -0.423] V5fcs = [-0.087, 0.000, 0.996] V6fcs = [0.104, 0.180, 0.978] V7fcs = [0.654, -0.377, 0.656] V8fcs = [0.654, -0.377, -0.656] V9fcs = [0.837, 0.347, 0.423] V10fcs = [0.837, 0.347, -0.423] V11fcs = [0.347, 0.837, 0.423] V12fcs = [0.347, 0.837, -0.423] if datatype == 'electron': pas = np.empty([len(btimes), 18]) # pitch angles for each eye at eaceh time # Telescope vectors in Body Coordinate System: # Factors of -1 account for 180 deg shift between particle velocity and telescope normal direction: # Top: Vt1bcs = [ -1. * (Ttop[0][0] * V1fcs[0] + Ttop[0][1] * V1fcs[1] + Ttop[0][2] * V1fcs[2]), -1. * (Ttop[1][0] * V1fcs[0] + Ttop[1][1] * V1fcs[1] + Ttop[1][2] * V1fcs[2]), -1. * (Ttop[2][0] * V1fcs[0] + Ttop[2][1] * V1fcs[1] + Ttop[2][2] * V1fcs[2]) ] Vt2bcs = [ -1. * (Ttop[0][0] * V2fcs[0] + Ttop[0][1] * V2fcs[1] + Ttop[0][2] * V2fcs[2]), -1. * (Ttop[1][0] * V2fcs[0] + Ttop[1][1] * V2fcs[1] + Ttop[1][2] * V2fcs[2]), -1. * (Ttop[2][0] * V2fcs[0] + Ttop[2][1] * V2fcs[1] + Ttop[2][2] * V2fcs[2]) ] Vt3bcs = [ -1. * (Ttop[0][0] * V3fcs[0] + Ttop[0][1] * V3fcs[1] + Ttop[0][2] * V3fcs[2]), -1. * (Ttop[1][0] * V3fcs[0] + Ttop[1][1] * V3fcs[1] + Ttop[1][2] * V3fcs[2]), -1. * (Ttop[2][0] * V3fcs[0] + Ttop[2][1] * V3fcs[1] + Ttop[2][2] * V3fcs[2]) ] Vt4bcs = [ -1. * (Ttop[0][0] * V4fcs[0] + Ttop[0][1] * V4fcs[1] + Ttop[0][2] * V4fcs[2]), -1. * (Ttop[1][0] * V4fcs[0] + Ttop[1][1] * V4fcs[1] + Ttop[1][2] * V4fcs[2]), -1. * (Ttop[2][0] * V4fcs[0] + Ttop[2][1] * V4fcs[1] + Ttop[2][2] * V4fcs[2]) ] Vt5bcs = [ -1. * (Ttop[0][0] * V5fcs[0] + Ttop[0][1] * V5fcs[1] + Ttop[0][2] * V5fcs[2]), -1. * (Ttop[1][0] * V5fcs[0] + Ttop[1][1] * V5fcs[1] + Ttop[1][2] * V5fcs[2]), -1. * (Ttop[2][0] * V5fcs[0] + Ttop[2][1] * V5fcs[1] + Ttop[2][2] * V5fcs[2]) ] Vt9bcs = [ -1. * (Ttop[0][0] * V9fcs[0] + Ttop[0][1] * V9fcs[1] + Ttop[0][2] * V9fcs[2]), -1. * (Ttop[1][0] * V9fcs[0] + Ttop[1][1] * V9fcs[1] + Ttop[1][2] * V9fcs[2]), -1. * (Ttop[2][0] * V9fcs[0] + Ttop[2][1] * V9fcs[1] + Ttop[2][2] * V9fcs[2]) ] Vt10bcs = [ -1. * (Ttop[0][0] * V10fcs[0] + Ttop[0][1] * V10fcs[1] + Ttop[0][2] * V10fcs[2]), -1. * (Ttop[1][0] * V10fcs[0] + Ttop[1][1] * V10fcs[1] + Ttop[1][2] * V10fcs[2]), -1. * (Ttop[2][0] * V10fcs[0] + Ttop[2][1] * V10fcs[1] + Ttop[2][2] * V10fcs[2]) ] Vt11bcs = [ -1. * (Ttop[0][0] * V11fcs[0] + Ttop[0][1] * V11fcs[1] + Ttop[0][2] * V11fcs[2]), -1. * (Ttop[1][0] * V11fcs[0] + Ttop[1][1] * V11fcs[1] + Ttop[1][2] * V11fcs[2]), -1. * (Ttop[2][0] * V11fcs[0] + Ttop[2][1] * V11fcs[1] + Ttop[2][2] * V11fcs[2]) ] Vt12bcs = [ -1. * (Ttop[0][0] * V12fcs[0] + Ttop[0][1] * V12fcs[1] + Ttop[0][2] * V12fcs[2]), -1. * (Ttop[1][0] * V12fcs[0] + Ttop[1][1] * V12fcs[1] + Ttop[1][2] * V12fcs[2]), -1. * (Ttop[2][0] * V12fcs[0] + Ttop[2][1] * V12fcs[1] + Ttop[2][2] * V12fcs[2]) ] # Bottom: Vb1bcs = [ -1. * (Tbot[0][0] * V1fcs[0] + Tbot[0][1] * V1fcs[1] + Tbot[0][2] * V1fcs[2]), -1. * (Tbot[1][0] * V1fcs[0] + Tbot[1][1] * V1fcs[1] + Tbot[1][2] * V1fcs[2]), -1. * (Tbot[2][0] * V1fcs[0] + Tbot[2][1] * V1fcs[1] + Tbot[2][2] * V1fcs[2]) ] Vb2bcs = [ -1. * (Tbot[0][0] * V2fcs[0] + Tbot[0][1] * V2fcs[1] + Tbot[0][2] * V2fcs[2]), -1. * (Tbot[1][0] * V2fcs[0] + Tbot[1][1] * V2fcs[1] + Tbot[1][2] * V2fcs[2]), -1. * (Tbot[2][0] * V2fcs[0] + Tbot[2][1] * V2fcs[1] + Tbot[2][2] * V2fcs[2]) ] Vb3bcs = [ -1. * (Tbot[0][0] * V3fcs[0] + Tbot[0][1] * V3fcs[1] + Tbot[0][2] * V3fcs[2]), -1. * (Tbot[1][0] * V3fcs[0] + Tbot[1][1] * V3fcs[1] + Tbot[1][2] * V3fcs[2]), -1. * (Tbot[2][0] * V3fcs[0] + Tbot[2][1] * V3fcs[1] + Tbot[2][2] * V3fcs[2]) ] Vb4bcs = [ -1. * (Tbot[0][0] * V4fcs[0] + Tbot[0][1] * V4fcs[1] + Tbot[0][2] * V4fcs[2]), -1. * (Tbot[1][0] * V4fcs[0] + Tbot[1][1] * V4fcs[1] + Tbot[1][2] * V4fcs[2]), -1. * (Tbot[2][0] * V4fcs[0] + Tbot[2][1] * V4fcs[1] + Tbot[2][2] * V4fcs[2]) ] Vb5bcs = [ -1. * (Tbot[0][0] * V5fcs[0] + Tbot[0][1] * V5fcs[1] + Tbot[0][2] * V5fcs[2]), -1. * (Tbot[1][0] * V5fcs[0] + Tbot[1][1] * V5fcs[1] + Tbot[1][2] * V5fcs[2]), -1. * (Tbot[2][0] * V5fcs[0] + Tbot[2][1] * V5fcs[1] + Tbot[2][2] * V5fcs[2]) ] Vb9bcs = [ -1. * (Tbot[0][0] * V9fcs[0] + Tbot[0][1] * V9fcs[1] + Tbot[0][2] * V9fcs[2]), -1. * (Tbot[1][0] * V9fcs[0] + Tbot[1][1] * V9fcs[1] + Tbot[1][2] * V9fcs[2]), -1. * (Tbot[2][0] * V9fcs[0] + Tbot[2][1] * V9fcs[1] + Tbot[2][2] * V9fcs[2]) ] Vb10bcs = [ -1. * (Tbot[0][0] * V10fcs[0] + Tbot[0][1] * V10fcs[1] + Tbot[0][2] * V10fcs[2]), -1. * (Tbot[1][0] * V10fcs[0] + Tbot[1][1] * V10fcs[1] + Tbot[1][2] * V10fcs[2]), -1. * (Tbot[2][0] * V10fcs[0] + Tbot[2][1] * V10fcs[1] + Tbot[2][2] * V10fcs[2]) ] Vb11bcs = [ -1. * (Tbot[0][0] * V11fcs[0] + Tbot[0][1] * V11fcs[1] + Tbot[0][2] * V11fcs[2]), -1. * (Tbot[1][0] * V11fcs[0] + Tbot[1][1] * V11fcs[1] + Tbot[1][2] * V11fcs[2]), -1. * (Tbot[2][0] * V11fcs[0] + Tbot[2][1] * V11fcs[1] + Tbot[2][2] * V11fcs[2]) ] Vb12bcs = [ -1. * (Tbot[0][0] * V12fcs[0] + Tbot[0][1] * V12fcs[1] + Tbot[0][2] * V12fcs[2]), -1. * (Tbot[1][0] * V12fcs[0] + Tbot[1][1] * V12fcs[1] + Tbot[1][2] * V12fcs[2]), -1. * (Tbot[2][0] * V12fcs[0] + Tbot[2][1] * V12fcs[1] + Tbot[2][2] * V12fcs[2]) ] for i in range(0, 18): if i == 0: Vbcs = Vt1bcs if i == 1: Vbcs = Vt2bcs if i == 2: Vbcs = Vt3bcs if i == 3: Vbcs = Vt4bcs if i == 4: Vbcs = Vt5bcs if i == 5: Vbcs = Vt9bcs if i == 6: Vbcs = Vt10bcs if i == 7: Vbcs = Vt11bcs if i == 8: Vbcs = Vt12bcs if i == 9: Vbcs = Vb1bcs if i == 10: Vbcs = Vb2bcs if i == 11: Vbcs = Vb3bcs if i == 12: Vbcs = Vb4bcs if i == 13: Vbcs = Vb5bcs if i == 14: Vbcs = Vb9bcs if i == 15: Vbcs = Vb10bcs if i == 16: Vbcs = Vb11bcs if i == 17: Vbcs = Vb12bcs pas[:, i] = 180. / math.pi * np.arccos( (Vbcs[0] * Bbcs[:, 0] + Vbcs[1] * Bbcs[:, 1] + Vbcs[2] * Bbcs[:, 2]) / (np.sqrt(Vbcs[0]**2 + Vbcs[1]**2 + Vbcs[2]**2) * np.sqrt(Bbcs[:, 0]**2 + Bbcs[:, 1]**2 + Bbcs[:, 2]**2))) if data_rate == 'srvy': # the following 2 hash tables map TOP/BOTTOM telescope #s to index of the PA array created above top_tele_idx_map = {} bot_tele_idx_map = {} top_tele_idx_map[1] = 0 top_tele_idx_map[2] = 1 top_tele_idx_map[3] = 2 top_tele_idx_map[4] = 3 top_tele_idx_map[5] = 4 top_tele_idx_map[9] = 5 top_tele_idx_map[10] = 6 top_tele_idx_map[11] = 7 top_tele_idx_map[12] = 8 bot_tele_idx_map[1] = 9 bot_tele_idx_map[2] = 10 bot_tele_idx_map[3] = 11 bot_tele_idx_map[4] = 12 bot_tele_idx_map[5] = 13 bot_tele_idx_map[9] = 14 bot_tele_idx_map[10] = 15 bot_tele_idx_map[11] = 16 bot_tele_idx_map[12] = 17 top_idxs = [] bot_idxs = [] # PAs for only active eyes new_pas = np.empty([ len(btimes), len(eyes['top']) + len(eyes['bottom']) ]) # pitch angles for each eye at eaceh time for top_idx, top_eye in enumerate(eyes['top']): new_pas[:, top_idx] = pas[:, top_tele_idx_map[top_eye]] top_idxs.append(top_idx) for bot_idx, bot_eye in enumerate(eyes['bottom']): new_pas[:, bot_idx + len(eyes['top'])] = pas[:, bot_tele_idx_map[bot_eye]] bot_idxs.append(bot_idx + len(eyes['top'])) idx_maps = { 'electron-top': top_idxs, 'electron-bottom': bot_idxs } else: new_pas = pas elif datatype == 'ion': pas = np.empty([len(btimes), 6]) # pitch angles for each eye at each time # Telescope vectors in Body Coordinate System: # Factors of -1 account for 180 deg shift between particle velocity and telescope normal direction: # Top: Vt6bcs = [ -1. * (Ttop[0][0] * V6fcs[0] + Ttop[0][1] * V6fcs[1] + Ttop[0][2] * V6fcs[2]), -1. * (Ttop[1][0] * V6fcs[0] + Ttop[1][1] * V6fcs[1] + Ttop[1][2] * V6fcs[2]), -1. * (Ttop[2][0] * V6fcs[0] + Ttop[2][1] * V6fcs[1] + Ttop[2][2] * V6fcs[2]) ] Vt7bcs = [ -1. * (Ttop[0][0] * V7fcs[0] + Ttop[0][1] * V7fcs[1] + Ttop[0][2] * V7fcs[2]), -1. * (Ttop[1][0] * V7fcs[0] + Ttop[1][1] * V7fcs[1] + Ttop[1][2] * V7fcs[2]), -1. * (Ttop[2][0] * V7fcs[0] + Ttop[2][1] * V7fcs[1] + Ttop[2][2] * V7fcs[2]) ] Vt8bcs = [ -1. * (Ttop[0][0] * V8fcs[0] + Ttop[0][1] * V8fcs[1] + Ttop[0][2] * V8fcs[2]), -1. * (Ttop[1][0] * V8fcs[0] + Ttop[1][1] * V8fcs[1] + Ttop[1][2] * V8fcs[2]), -1. * (Ttop[2][0] * V8fcs[0] + Ttop[2][1] * V8fcs[1] + Ttop[2][2] * V8fcs[2]) ] # Bottom: Vb6bcs = [ -1. * (Tbot[0][0] * V6fcs[0] + Tbot[0][1] * V6fcs[1] + Tbot[0][2] * V6fcs[2]), -1. * (Tbot[1][0] * V6fcs[0] + Tbot[1][1] * V6fcs[1] + Tbot[1][2] * V6fcs[2]), -1. * (Tbot[2][0] * V6fcs[0] + Tbot[2][1] * V6fcs[1] + Tbot[2][2] * V6fcs[2]) ] Vb7bcs = [ -1. * (Tbot[0][0] * V7fcs[0] + Tbot[0][1] * V7fcs[1] + Tbot[0][2] * V7fcs[2]), -1. * (Tbot[1][0] * V7fcs[0] + Tbot[1][1] * V7fcs[1] + Tbot[1][2] * V7fcs[2]), -1. * (Tbot[2][0] * V7fcs[0] + Tbot[2][1] * V7fcs[1] + Tbot[2][2] * V7fcs[2]) ] Vb8bcs = [ -1. * (Tbot[0][0] * V8fcs[0] + Tbot[0][1] * V8fcs[1] + Tbot[0][2] * V8fcs[2]), -1. * (Tbot[1][0] * V8fcs[0] + Tbot[1][1] * V8fcs[1] + Tbot[1][2] * V8fcs[2]), -1. * (Tbot[2][0] * V8fcs[0] + Tbot[2][1] * V8fcs[1] + Tbot[2][2] * V8fcs[2]) ] for i in range(0, 6): if i == 0: Vbcs = Vt6bcs if i == 1: Vbcs = Vt7bcs if i == 2: Vbcs = Vt8bcs if i == 3: Vbcs = Vb6bcs if i == 4: Vbcs = Vb7bcs if i == 5: Vbcs = Vb8bcs pas[:, i] = 180. / math.pi * np.arccos( (Vbcs[0] * Bbcs[:, 0] + Vbcs[1] * Bbcs[:, 1] + Vbcs[2] * Bbcs[:, 2]) / (np.sqrt(Vbcs[0]**2 + Vbcs[1]**2 + Vbcs[2]**2) * np.sqrt(Bbcs[:, 0]**2 + Bbcs[:, 1]**2 + Bbcs[:, 2]**2))) # the following 2 hash tables map TOP/BOTTOM telescope #s to index of the PA array created above top_tele_idx_map = {} bot_tele_idx_map = {} top_tele_idx_map[6] = 0 top_tele_idx_map[7] = 1 top_tele_idx_map[8] = 2 bot_tele_idx_map[6] = 3 bot_tele_idx_map[7] = 4 bot_tele_idx_map[8] = 5 top_idxs = [] bot_idxs = [] # PAs for only active eyes new_pas = np.empty([ len(btimes), len(eyes['top']) + len(eyes['bottom']) ]) # pitch angles for each eye at eaceh time for top_idx, top_eye in enumerate(eyes['top']): new_pas[:, top_idx] = pas[:, top_tele_idx_map[top_eye]] top_idxs.append(top_idx) for bot_idx, bot_eye in enumerate(eyes['bottom']): new_pas[:, bot_idx + len(eyes['top'])] = pas[:, bot_tele_idx_map[bot_eye]] bot_idxs.append(bot_idx + len(eyes['top'])) idx_maps = {'ion-top': top_idxs, 'ion-bottom': bot_idxs} outvar = 'mms' + probe + '_epd_feeps_' + data_rate + '_' + level + '_' + datatype + '_pa' + suffix if data_exists( outvar): # kludge for bug when the PAs were previously calculated return (outvar, idx_maps) store_data(outvar, data={'x': btimes, 'y': new_pas}) # interpolate to the PA time stamps outdata = get_data(outvar, xarray=True) outdata_interpolated = outdata.interp({'time': times}) store_data(outvar, data={'x': times, 'y': outdata_interpolated.values}) return (outvar, idx_maps)
''' This crib sheet shows how to load MMS FGM data ''' from pyspedas import mms_load_fgm from pytplot import tplot, get_data, del_data # by default, 'srvy' mode data for MMS1 are loaded mms_load_fgm(trange=['2015-10-16', '2015-10-17']) tplot(['mms1_fgm_b_gse_srvy_l2', 'mms1_fgm_b_gsm_srvy_l2']) del_data('*') # to load burst mode data, change the data rate to 'brst' mms_load_fgm(data_rate='brst', trange=['2015-10-16/13:06', '2015-10-16/13:07']) tplot(['mms1_fgm_b_gse_brst_l2', 'mms1_fgm_b_gsm_brst_l2']) del_data('*') # to keep the data flagged by the 'flag' variable, use the keep_flagged keyword mms_load_fgm(keep_flagged=True, trange=['2015-10-16', '2015-10-17']) tplot(['mms1_fgm_b_gse_srvy_l2', 'mms1_fgm_b_gsm_srvy_l2']) # access the data values with get_data times, data = get_data('mms1_fgm_b_gse_srvy_l2') # print the first time print(times[0])