Beispiel #1
0
def test_omni_default():
    start_time = datetime(1970, 1, 1, 0, 0, 0)
    end_time = datetime(1970, 1, 3, 0, 0, 0)
    xr_omni = load_data(mission='omni',
                        start_time=start_time,
                        end_time=end_time)
    try:
        xr_omni['all1']
    except:
        raise ValueError
Beispiel #2
0
def test_cluster():
    start_time = datetime(2004, 6, 18, 11, 35, 0)
    end_time = datetime(2004, 6, 18, 11, 36, 0)
    settings = {'probes': ['3'], 'prod': ['dc_mag']}
    xr_cluster = load_data('cluster', start_time, end_time, **settings)
    cluster_b_x = xr_cluster['dc_mag3'].sel(
        B_vec_xyz_gse__C3_CP_FGM_SPIN='x').values
    cluster_b_x_units = cluster_b_x * u.Unit(
        xr_cluster['dc_mag3'].attrs['Units']['B_vec_xyz_gse__C3_CP_FGM_SPIN'])
    target = np.array([
        26.827, 27.212, 27.296, 27.799, 28.264, 28.686, 28.911, 29.206, 29.473,
        29.483, 29.597, 29.73, 29.896, 30.127
    ]) * u.nT
    assert u.allclose(target, cluster_b_x_units)
Beispiel #3
0
 def _init_rotations_matrices(self, time_par, start_time, end_time):
     """ Returns rotations matrices interpolated at time_par.
     """
     probe_ID = self.settings['probes'][0]
     key_str = 'sc_att{}'.format(probe_ID)
     quat_eci_to_gse = self._obj[key_str].values
     time_quat = self._obj[key_str].coords[self._get_time_key(
         key_str)].values
     ####################
     settings = {
         'prod': ['sc_att'],
         'probes': [probe_ID],
         'coords': 'gse',
         'mode': 'high_res',
         'frame': 'dbcs'
     }
     from aidapy import load_data
     xr_mms_tmp = load_data(mission='mms',
                            start_time=start_time,
                            end_time=end_time,
                            **settings)
     quat_eci_to_dbcs = xr_mms_tmp['sc_att{}'.format(probe_ID)].values
     # time_quat2 = self._obj['sc_att1'].coords['time1'].values
     #####################
     f = interp1d(mpl.dates.date2num(time_quat),
                  quat_eci_to_gse.T,
                  bounds_error=False,
                  fill_value=np.nan)
     quat_interp = f(mpl.dates.date2num(time_par))
     itk = np.isnan(quat_interp[0])
     quat_interp[:, itk] = 1.
     r = R.from_quat(quat_interp.T)
     self.R_eci_to_gse = r.as_matrix()
     self.R_gse_to_eci = np.transpose(self.R_eci_to_gse, axes=(0, 2, 1))
     self.R_eci_to_gse[itk] *= np.nan
     self.R_gse_to_eci[itk] *= np.nan
     #
     f = interp1d(mpl.dates.date2num(time_quat),
                  quat_eci_to_dbcs.T,
                  bounds_error=False,
                  fill_value=np.nan)
     quat_interp = f(mpl.dates.date2num(time_par))
     itk = np.isnan(quat_interp[0])
     quat_interp[:, itk] = 1.
     r = R.from_quat(quat_interp.T)
     self.R_eci_to_dbcs = r.as_matrix()
     R_dbcs_to_eci = np.transpose(self.R_eci_to_dbcs, axes=(0, 2, 1))
     self.R_eci_to_dbcs[itk] *= np.nan
     R_dbcs_to_eci[itk] *= np.nan
Beispiel #4
0
def test_omni():
    start_time = datetime(1970, 1, 1, 0, 0, 0)
    end_time = datetime(1970, 1, 3, 0, 0, 0)
    settings = {'prod': ['dc_mag']}
    xr_omni = load_data(mission='omni',
                        start_time=start_time,
                        end_time=end_time,
                        **settings)
    omni_b_x = xr_omni['dc_mag1'].sel(products='BX_GSE').values
    omni_b_x_units = omni_b_x * u.Unit(
        xr_omni['dc_mag1'].attrs['Units']['BX_GSE'])
    target = np.array([
        -1.4, -0.3, -2.5, -1.2, -3.5, -2.5, -0.5, -1.6, -2.4, -2.4, -1.7, -1.5,
        -0.8, -4.4, -4.8, -3.6, -6.3, -6.7, -1.4, -2.7, 0.8, 0.8, -0.4, -4.4,
        -5.4, -6.2, -6.3, -4.2, -8.1, -7., -2.2, -5.2, -2.6, -8.4, -5.7, -2.1,
        -2.7, -1.1, 0., -3.8, -4.7, -1.5, -0.9, -1.3, -2.9, -2., -3.2
    ]) * u.nT
    assert u.allclose(target, omni_b_x_units)
Beispiel #5
0
def test_vdf_mms():
    '''Integration test on a complete interpolation.'''
    start_time = datetime(2019, 3, 8, 13, 54, 53)
    end_time = datetime(2019, 3, 8, 13, 57, 00)
    settings = {
        'prod': ['i_dist', 'dc_mag', 'sc_att', 'i_bulkv'],
        'probes': ['1'],
        'coords': 'gse',
        'mode': 'high_res',
        'frame': 'gse'
    }
    xr_mms = load_data(mission='mms',
                       start_time=start_time,
                       end_time=end_time,
                       **settings)
    species = 'ion'
    frame = 'B'
    grid_geom = 'spher'
    v_max = 8.e5
    resolution = 60
    interp_schem = 'lin'
    start_time_sub = datetime(start_time.year, start_time.month,
                              start_time.day, 13, 56, 23, 160000)
    end_time_sub = datetime(start_time.year, start_time.month, start_time.day,
                            13, 56, 24, 225000)
    xr_mms = xr_mms.vdf.interpolate(start_time,
                                    end_time,
                                    start_time_sub,
                                    end_time_sub,
                                    species=species,
                                    frame=frame,
                                    grid_geom=grid_geom,
                                    v_max=v_max,
                                    resolution=resolution,
                                    interp_schem=interp_schem,
                                    verbose=False)
    target = np.array([
        1.7031225e-10, 1.5537861e-10, 1.4097469e-10, 1.4718438e-10,
        3.0006439e-10, 1.6751817e-10, 1.2765614e-10
    ]).astype(np.float32)
    result = np.nanmean(xr_mms['vdf_interp_time'].values,
                        axis=(1, 2)).astype(np.float32)
    # This test will potentially fail if MMS data are updated...
    assert np.allclose(target, result, atol=1.e-24)
Beispiel #6
0
def test_mms():
    start_time = datetime(2018, 4, 8, 0, 0, 0)
    end_time = datetime(2018, 4, 8, 0, 0, 10)
    settings = {'probes': ['1'], 'prod': ['dc_mag']}
    xr_mms = load_data('mms', start_time, end_time, **settings)
    mms_b_x = xr_mms['dc_mag1'].sel(mms1_fgm_b_gse_srvy_l2='x').values
    mms_b_x_units = mms_b_x * u.Unit(
        xr_mms['dc_mag1'].attrs['Units']['mms1_fgm_b_gse_srvy_l2'])
    target = np.array([
        1.712529, 1.7148426, 1.7108021, 1.7265971, 1.7372726, 1.7345928,
        1.7192012, 1.7152323, 1.7145348, 1.718118, 1.7249706, 1.7225785,
        1.7281982, 1.7349572, 1.7244626, 1.7399646, 1.7466872, 1.7412337,
        1.762651, 1.7680929, 1.7699757, 1.7411137, 1.7634461, 1.7464956,
        1.7357976, 1.7537696, 1.7317536, 1.7466614, 1.7381922, 1.7112942,
        1.717961, 1.7125505, 1.7319726, 1.7341373, 1.7375633, 1.7236018,
        1.7285287, 1.7272918, 1.7329324, 1.7352072, 1.7432857, 1.7374923,
        1.7280098, 1.7234732, 1.734949, 1.7194895, 1.7201461, 1.7266002,
        1.6997541
    ]) * u.nT
    assert u.allclose(target, mms_b_x_units)
Beispiel #7
0
from aidapy import load_data
import aidapy.aidaxr

###############################################################################
# Define data parameters
###############################################################################
# Time Interval
start_time = datetime(2017, 1, 1, 0, 0, 0)
end_time = datetime(2018, 1, 1, 0, 0, 0)

# Dictionary of data settings: mission, product, probe, coordinates
# Currently available products: 'dc_mag', 'i_dens', and 'all'
settings = {'prod': ['i_bulkv'], 'probes': ['1'], 'coords': 'gse', "mode": "low_res"}

###############################################################################
# Download and load desired data as aidapy timeseries
###############################################################################
xr_mms = load_data(mission='mms', start_time=start_time, end_time=end_time, **settings)
print(xr_mms)
#print(xr_mms['dc_mag1'])
#print(xr_mms['dc_mag2'])
###############################################################################
# Plot the loaded aidapy timeseries
###############################################################################
#xr_mms.graphical.peek()

toto = xr_mms['i_bulkv1'].to_dataframe()


toto.to_pickle("df_mms1_ibulkv_2017.pkl")
Beispiel #8
0
@author: hbreuill
"""
from datetime import datetime

#AIDApy Modules
from aidapy import load_data
import aidapy.aidaxr

###############################################################################
# Define data parameters
###############################################################################
# Time Interval
start_time = datetime(2009, 4, 1, 0, 0, 0)
end_time = datetime(2009, 4, 2, 0, 0, 0)

# Dictionary of data settings: mission, product, probe, coordinates
# Currently available products: 'dc_mag', 'i_dens', and 'all'
cl_settings = {'prod': ['i_bulkv'], 'probes': ['1'], 'coords': 'gse'}

###############################################################################
# Download and load desired data as aidapy timeseries
###############################################################################
xr_cluster = load_data('cluster', start_time, end_time, **cl_settings)
print(xr_cluster)
print(xr_cluster['i_bulkv1'])

###############################################################################
# Plot the loaded aidapy timeseries
###############################################################################
xr_cluster['i_bulkv1'].graphical.peek()
Beispiel #9
0
- to plot mission data

@author: hbreuill
"""
from datetime import datetime

#AIDApy Modules
from aidapy import load_data
import aidapy.aidaxr


###############################################################################
# Define data parameters
###############################################################################
start_time = datetime(2018, 4, 8, 0, 0, 0)
end_time = datetime(2018, 4, 8, 0, 1, 0)

# Dictionary of data settings: mission, product, probe, coordinates
# Currently available products: 'dc_mag', 'i_dens', and 'all'
settings = {'prod': ['dc_mag'], 'probes': ['1', '2'], 'coords': 'gse'}

###############################################################################
# Download and load desired data as aidapy timeseries
###############################################################################
xr_mms = load_data(mission='mms', start_time=start_time, end_time=end_time, **settings)#, prod=['dc_mag'], probes=['1', '2'], coords='gse')
print(xr_mms['dc_mag1'])
###############################################################################
# Plot the loaded aidapy timeseries
###############################################################################
xr_mms['dc_mag1'].graphical.peek()
Beispiel #10
0
- to build the associated timeseries
- to plot mission data

@author: hbreuill
"""
from datetime import datetime

#AIDApy Modules
from aidapy import load_data
import aidapy.aidaxr

###############################################################################
# Define data parameters
###############################################################################
# Time Interval
start_time = datetime(2008, 5, 15, 0, 0, 0)
end_time = datetime(2008, 5, 16, 0, 0, 0)

###############################################################################
# Download and load desired data as aidapy timeseries
###############################################################################
#ts_data = TimeSeries(mission=settings['mission'], dl_settings=settings)
xr_omni = load_data(mission='omni', start_time=start_time, end_time=end_time)
print(xr_omni)
#print(xr_omni['all1'])

###############################################################################
# Plot the loaded aidapy timeseries
###############################################################################
#xr_omni['all1'].graphical.peek()