def ex_analysis(): # Print the installed version of pyspedas pyspedas.version() # Delete any existing pytplot variables pytplot.del_data() # Download THEMIS state data for 2015-12-31 pyspedas.load_data('themis', '2015-12-31', ['tha'], 'state', 'l1') # Use some analysis functions on tplot variables pyspedas.subtract_average('tha_pos') pyspedas.subtract_median('tha_pos') # Plot pytplot.tplot(["tha_pos", "tha_pos-d", "tha_pos-m"])
def ex_analysis(): # Delete any existing pytplot variables pytplot.del_data() # Download THEMIS state data for 2015-12-31 time_range = ['2015-12-31 00:00:00', '2015-12-31 23:59:59'] pyspedas.themis.state(probe='a', trange=time_range) # Use some analysis functions on tplot variables pyspedas.subtract_average('tha_pos') pyspedas.subtract_median('tha_pos') # Plot pytplot.tplot(["tha_pos", "tha_pos-d", "tha_pos-m"]) # Return 1 as indication that the example finished without problems. return 1
Analysis Tools ========================================================================== ''' # subtract_average from pyspedas import subtract_average subtract_average('mms4_fgm_b_gsm_brst_l2') tplot(['mms4_fgm_b_gsm_brst_l2', 'mms4_fgm_b_gsm_brst_l2-d']) # subtract_median from pyspedas import subtract_median subtract_median('mms4_fgm_b_gsm_brst_l2') tplot([ 'mms4_fgm_b_gsm_brst_l2', 'mms4_fgm_b_gsm_brst_l2-d', 'mms4_fgm_b_gsm_brst_l2-m' ]) # time clip from pyspedas import time_clip time_clip([ 'mms4_fgm_b_gsm_brst_l2', 'mms4_fgm_b_gsm_brst_l2-d', 'mms4_fgm_b_gsm_brst_l2-m' ], '2015-10-16/13:06:45', '2015-10-16/13:07',
def test_subtract_median(self): subtract_median('test') d = get_data('test-m') self.assertTrue(d[1].tolist() == [-3.5, -1.5, 1.5, 8.5, 13.5, -5.5])
def test_subtract_median(self): """Test subtract_median.""" subtract_median('aaabbbccc') # Test non-existent name subtract_median('test') d = get_data('test-m') self.assertTrue(d[1].tolist() == [-3.5, -1.5, 1.5, 8.5, 13.5, -5.5]) dn = [[3., 5., 8.], [15., 20., 1.], [3., 5., 8.], [15., 20., 1.], [23., 15., 28.], [15., 20., float('nan')]] store_data('test1', data={'x': [1., 2., 3., 4., 5., 6.], 'y': dn}) subtract_median('aaabbbcc') subtract_median('test1', new_names='aabb') d = get_data('aabb') subtract_median(['test', 'aabb'], new_names='aaabbb') subtract_median('test1', overwrite=1) subtract_average('test', new_names="testtest") subtract_average(['test-m', 'test'], new_names="testtest2") self.assertTrue(len(d[1]) == 6)