예제 #1
0
    def test_dsl2gse(self):
        time_range = ['2017-03-23 00:00:00', '2017-03-23 23:59:59']
        pyspedas.themis.state(probe='a',
                              trange=time_range,
                              get_support_data=True,
                              varnames=['tha_spinras', 'tha_spindec'])
        pyspedas.themis.fgm(probe='a',
                            trange=time_range,
                            varnames=['tha_fgl_dsl'])

        dsl2gse('tha_fgl_dsl', 'tha_spinras', 'tha_spindec', 'tha_fgl_gse')

        t, d = get_data('tha_fgl_gse')

        self.assertTrue(d[0].tolist()[0] - 15.905078404701147 <= 1e-6)
        self.assertTrue(d[0].tolist()[1] - -13.962618931740064 <= 1e-6)
        self.assertTrue(d[0].tolist()[2] - 16.392516225582813 <= 1e-6)

        self.assertTrue(d[50000].tolist()[0] - 16.079111468932435 <= 1e-6)
        self.assertTrue(d[50000].tolist()[1] - -18.858874541698583 <= 1e-6)
        self.assertTrue(d[50000].tolist()[2] - 14.75796300561617 <= 1e-6)
예제 #2
0
    def test_dsl2gse(self):
        """Test themis.cotrans.dsl2gse."""
        del_data()
        # Try with missing variables. It should exit without problems.
        dsl2gse('tha_fgl_dsl', 'tha_spinras', 'tha_spindec', 'tha_fgl_gse')
        # Now load the needed variables.
        time_range = ['2017-03-23 00:00:00', '2017-03-23 23:59:59']
        pyspedas.themis.state(probe='a',
                              trange=time_range,
                              get_support_data=True,
                              varnames=['tha_spinras', 'tha_spindec'])
        pyspedas.themis.fgm(probe='a',
                            trange=time_range,
                            varnames=['tha_fgl_dsl'])

        dsl2gse('tha_fgl_dsl', 'tha_spinras', 'tha_spindec', 'tha_fgl_gse')

        t, d = get_data('tha_fgl_gse')
        # Now test the inverse.
        dsl2gse('tha_fgl_dsl',
                'tha_spinras',
                'tha_spindec',
                'tha_fgl_gse',
                isgsetodsl=1)

        self.assertTrue(abs(d[0].tolist()[0] - 15.905078404701147) <= 1e-6)
        self.assertTrue(abs(d[0].tolist()[1] - -13.962618931740064) <= 1e-6)
        self.assertTrue(abs(d[0].tolist()[2] - 16.392516225582813) <= 1e-6)

        self.assertTrue(abs(d[50000].tolist()[0] - 16.079111468932435) <= 1e-6)
        self.assertTrue(
            abs(d[50000].tolist()[1] - -18.858874541698583) <= 1e-6)
        self.assertTrue(abs(d[50000].tolist()[2] - 14.75796300561617) <= 1e-6)
예제 #3
0
def ex_dsl2gse(plot=True):
    """Run dsl2gse."""
    time_range = ['2017-03-23 00:00:00', '2017-03-23 23:59:59']
    pyspedas.themis.state(probe='a',
                          trange=time_range,
                          get_support_data=True,
                          varnames=['tha_spinras', 'tha_spindec'])
    pyspedas.themis.fgm(probe='a', trange=time_range, varnames=['tha_fgl_dsl'])

    dsl2gse('tha_fgl_dsl', 'tha_spinras', 'tha_spindec', 'tha_fgl_gse')

    # Get the third component only
    d_in = pytplot.get_data('tha_fgl_dsl')
    pytplot.store_data('z_dsl', data={'x': d_in[0], 'y': d_in[1][:, 2]})
    d_out = pytplot.get_data('tha_fgl_gse')
    pytplot.store_data('z_gse', data={'x': d_out[0], 'y': d_out[1][:, 2]})

    # Plot
    pytplot.tplot_options('title', 'tha_fgl DSL and GSE, 2017-03-23')
    if plot:
        pytplot.tplot(['tha_fgl_dsl', 'tha_fgl_gse', 'z_dsl', 'z_gse'])

    # Return 1 as indication that the example finished without problems.
    return 1
예제 #4
0
'''

This script prints several FGM data points in GSE coordinates after cotransing from DSL.

This is meant to be called from the IDL test suite for comparison with the data loaded via IDL SPEDAS

'''

import pyspedas
from pytplot import get_data
from pyspedas.themis.cotrans.dsl2gse import dsl2gse

thm_vars = pyspedas.themis.fgm(probe='a', level='l2')
thm_vars = pyspedas.themis.state(probe='a',
                                 get_support_data=True,
                                 varnames=['tha_spinras', 'tha_spindec'])

dsl2gse('tha_fgs_dsl', 'tha_spinras', 'tha_spindec', 'tha_fgs_gse_cotrans')

data = get_data('tha_fgs_gse_cotrans')

print(data[0][0:10].round(6).tolist())

print(data[1][1000].tolist())

print(data[1][5000].tolist())

print(data[1][10000].tolist())

print(data[1][20000].tolist())