def test_prep_irbem_too_many_PA(self): """Call prep_irbem with too many pitch angles""" with self.assertRaises(ValueError) as cm: ib.prep_irbem(self.ticks, self.loci, numpy.arange(5, 180, 5), omnivals=self.omnivals) self.assertEqual('Too many pitch angles requested; 25 is maximum.', str(cm.exception))
def test_prep_irbem_sysaxesnone(self): """prep_irbem should handle 'car' and 'sph' version of systems identically""" locc = spacepy.coordinates.Coords([[3,0,0],[2,0,0]], 'GSM', 'car') out1 = ib.prep_irbem(ticks=self.ticks, loci=locc, extMag='0', options=[1, 0, 0, 0, 1]) pos = ib.car2sph(locc.data) locs = spacepy.coordinates.Coords(pos, 'GSM', 'sph') out2 = ib.prep_irbem(ticks=self.ticks, loci=locs, extMag='0', options=[1, 0, 0, 0, 1]) self.assertEqual(out1['sysaxes'], out2['sysaxes']) numpy.testing.assert_almost_equal(out1['xin1'], out2['xin1']) numpy.testing.assert_almost_equal(out1['xin2'], out2['xin2']) numpy.testing.assert_almost_equal(out1['xin3'], out2['xin3'])
def test_prep_irbem(self): expected = { 'badval': -1e31, 'degalpha': [0.0] * 25, 'idoysat': [33.0] * 2 + [0.0] * 99998, 'ntime_max': 100000, 'nalp_max': 25, 'magin': np.zeros((25, 100000)), 'sysaxes': 1, 'kext': 10, 'iyearsat': [2001.] * 2 + [0.0] * 99998, 'xin3': 0.0 * 100000, 'xin2': 0.0 * 100000, 'xin1': [3., 2.] + [0.0] * 99998, 'utsat': [43200., 43800.] + [0.0] * 99998, 'options': [1, 0, 0, 0, 0], } expected['magin'][:, :2] = array( [[ 3.00000012e+00, 3.00000012e+00], [ -9.00000000e+00, -9.00000000e+00], [ 3.20000005e+00, 3.15000006e+00], [ 3.96000000e+02, 3.96000000e+02], [ 1.07000005e+00, 1.05500005e+00], [ 2.00000003e-01, -4.99999917e-02], [ -1.00000001e-01, 1.33333326e-01], [ 9.99999978e-03, 9.99999978e-03], [ 2.99999993e-02, 2.49999994e-02], [ 9.99999978e-03, 8.33333313e-03], [ 2.60000005e-02, 2.46666670e-02], [ 1.70000009e-02, 1.56666674e-02], [ 3.16000015e-01, 3.14333344e-01], [ 6.00000005e-03, 5.50000004e-03], [ 1.70000009e-02, 1.50000007e-02], [ 2.19999999e-02, 1.98333332e-02], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00], [ 0.00000000e+00, 0.00000000e+00]]) actual = ib.prep_irbem(self.ticks, self.loci, omnivals=self.omnivals) for key in expected: numpy.testing.assert_almost_equal(expected[key], actual[key], decimal=5)