コード例 #1
0
 def test_fromRecArrayNames(self):
     '''given a known rec array, should get known keys in SpaceData'''
     names = ['x', 'y', 'value']
     recarr = np.zeros(3, dtype=[(names[0],'f4'),(names[1],np.float32),(names[2],'f4',(2,2))])
     sd = dm.fromRecArray(recarr)
     for kk in sd.keys():
         self.assertTrue(kk in names)
コード例 #2
0
 def test_fromRecArrayShapesValues(self):
     '''given a known rec array, should get known shapes and values in SpaceData'''
     names = ['x', 'y', 'value']
     recarr = np.zeros(3, dtype=[(names[0],'f4'),(names[1],np.float32),(names[2],'f4',(2,2))])
     sd = dm.fromRecArray(recarr)
     np.testing.assert_array_equal((3,2,2), sd[names[2]].shape)
     np.testing.assert_array_equal(np.zeros(3), sd[names[0]])
コード例 #3
0
def load_SC_OMNI(bird, year, outdata=None, **kwargs):
    '''Load satellite specific OMNI data into dict'''
    fname = get_SC_OMNI(year=year, bird=bird, **kwargs)
    dum = np.genfromtxt(fname,
                        usecols=(0, 1, 2, 3, 15, 16, 23, 26, 28, 29, 30),
                        names=('year', 'day', 'hour', 'minute', 'By_GSM',
                               'Bz_GSM', 'Vx_GSE', 'Den_P', 'X_GSE', 'Y_GSE',
                               'Z_GSE'),
                        converters={
                            0: int,
                            1: int,
                            2: int,
                            3: int
                        })
    data = dm.fromRecArray(dum)
    dates = spt.doy2date(data['year'], data['day'], dtobj=True)
    times = [
        dt.timedelta(hours=x, minutes=y)
        for x, y in zip(data['hour'], data['minute'])
    ]
    data['DateTime'] = dates + times
    for key in ['year', 'day', 'hour', 'minute']:
        del data[key]
    data['Bz_GSM'][np.abs(data['Bz_GSM']) > 20] = np.nan
    data['By_GSM'][np.abs(data['By_GSM']) > 20] = np.nan
    data['Vx_GSE'][np.abs(data['Vx_GSE']) > 900] = np.nan
    data['X_GSE'][np.abs(data['X_GSE']) > 9000] = np.nan
    data['Y_GSE'][np.abs(data['Y_GSE']) > 9000] = np.nan
    data['Z_GSE'][np.abs(data['Z_GSE']) > 9000] = np.nan
    if outdata:
        for key in [
                'By_GSM', 'Bz_GSM', 'Vx_GSE', 'DateTime', 'Den_P', 'X_GSE',
                'Y_GSE', 'Z_GSE'
        ]:
            outdata[key] = np.concatenate([outdata[key], data[key]])
        return outdata
    return data