def set_object_testing(cls): # print("BField.set_object_testing", flush=True) data = cls.data.b.xs("", axis=1, level="S") # b = vector.Vector(data) b = vector.BField(data) cls.object_testing = b cls.data = data
def test_cos_theta(self): # b = base.TestData() # b.setUpClass() # b = ( # b.data.b.loc[:, ["x", "y", "z"]] # .xs("", axis=1, level="S") # .xs("", axis=1, level="N") # ) b = ( base.TestData() .plasma_data.xs("b", axis=1, level="M") .xs("", axis=1, level="S") .loc[:, ["x", "y", "z"]] ) bmag = b.pow(2).sum(axis=1).pipe(np.sqrt) buv = b.divide(bmag, axis=0) v = self.data.loc[:, ["x", "y", "z"]] vmag = v.pow(2).sum(axis=1).pipe(np.sqrt) vuv = v.divide(vmag, axis=0) cos_theta = vuv.multiply(buv, axis=1).sum(axis=1) # print("", # "<Test>", # "<buv>", type(buv), buv, # "<v>", type(v), v, # "<vmag>", type(vmag), vmag, # "<vuv>", type(vuv), vuv, # "<cos_theta>", type(cos_theta), cos_theta, # "", # sep="\n") b = vector.BField(b) pdt.assert_series_equal(cos_theta, self.object_testing.cos_theta(b)) # Projecting a thing onto itself should return 1 for parallel # and 0 for perp. v = vector.Vector(v) vuv = vector.Vector(vuv) par = pd.Series(1.0, index=vmag.index) pdt.assert_series_equal(par, self.object_testing.cos_theta(v)) pdt.assert_series_equal(par, self.object_testing.cos_theta(vuv)) msg = "`project` method needs" with self.assertRaisesRegex(NotImplementedError, msg): self.object_testing.project(b.data)
def test_b_gse(self): b = vector.BField(self.data.b.xs("", axis=1, level="S")) gse = vector.Vector(self.data.gse.xs("", axis=1, level="S")) self.assertNotEqual(b, gse)
def test_b_w(self): b = vector.BField(self.data.b.xs("", axis=1, level="S")) w = tensor.Tensor(self.data.w.xs("a", axis=1, level="S")) self.assertNotEqual(b, w)
def test_b_v(self): b = vector.BField(self.data.b.xs("", axis=1, level="S")) v = vector.Vector(self.data.v.xs("p2", axis=1, level="S")) self.assertNotEqual(b, v)
def test_b(self): data = self.data.b.xs("", axis=1, level="S") b0 = vector.BField(data) b1 = vector.BField(data) self.assertEqual(b0, b0) self.assertEqual(b0, b1)