def test_count_casts(self): castlikes = [ AbstractCast(), AbstractCast(), CastCollection([AbstractCast(), AbstractCast()]), AbstractCast() ] self.assertEqual(count_casts(castlikes), 5) return
def __init__(self): p = np.arange(1, 1001, 2) temp = 10. * np.exp(-.008 * p) - 15. * np.exp(-0.005 * (p + 100)) + 2. sal = -14. * np.exp(-.01 * p) + 34. self.p = p self.temp = temp self.sal = sal dt = datetime.datetime(1993, 8, 18, 14, 42, 36) self.cast = Cast(pres=self.p, temp=self.temp, sal=self.sal, date=dt) self.collection = CastCollection(self.cast, self.cast, self.cast) self.path = join(split(realpath(__file__))[0], "data") return
def test_add_to_castcollection(self): cc = CastCollection( Cast(P=np.arange(100), T=np.random.rand(100), S=np.random.rand(100), coordinates=(-17.42, 80.09)), Cast(P=np.arange(100), T=np.random.rand(100), S=np.random.rand(100), coordinates=(-17.426, 80.112)), Cast(P=np.arange(100), T=np.random.rand(100), S=np.random.rand(100), coordinates=(-17.45, 80.16))) cc.add_bathymetry(self.bathymetry) correctresult = np.array( [92.93171145156435, 123.1639348135739, 150.2982311721252]) depths = [c.properties["depth"] for c in cc] self.assertTrue(np.allclose(depths, correctresult)) return