Ejemplo n.º 1
0
class TestData():

    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(self.p, temp=self.temp, sal=self.sal, date=dt)
        self.ctd = CTDCast(self.p, temp=self.temp, sal=self.sal, date=dt)
        self.ctdz = CTDCast(self.p, temp=self.temp, sal=self.sal, date=dt)
        self.xbt = XBTCast(self.p, temp=self.temp, sal=self.sal, date=dt)
        self.collection = CastCollection(self.ctd, self.xbt, self.ctd)
        return

    def save_nwl(self):
        self.cast.save("data/reference_cast_test.nwl", binary=False)
        self.ctd.save("data/reference_ctd_test.nwl", binary=False)
        self.ctdz.save("data/reference_ctdz_test.nwl", binary=False)
        self.xbt.save("data/reference_xbt_test.nwl", binary=False)
        self.collection.save("data/reference_coll_test.nwl", binary=False)

    def save_nwz(self):
        self.cast.save("data/reference_cast_test.nwz")
        self.ctd.save("data/reference_ctd_test.nwz")
        self.ctdz.save("data/reference_ctdz_test.nwz")
        self.xbt.save("data/reference_xbt_test.nwz")
        self.collection.save("data/reference_coll_test.nwz")
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 def test_add_to_castcollection(self):
     cc = CastCollection(
             Cast(np.arange(100), T=np.random.rand(100), S=np.random.rand(100),
                  coords=(-17.42, 80.09)),
             Cast(np.arange(100), T=np.random.rand(100), S=np.random.rand(100),
                  coords=(-17.426, 80.112)),
             Cast(np.arange(100), T=np.random.rand(100), S=np.random.rand(100),
                  coords=(-17.45, 80.16)))
     cc.add_bathymetry(self.bathymetry)
     correctresult = np.array([92.61373822294766, 123.15924954803165,
                               150.24992416068667])
     depths = [c.properties["depth"] for c in cc]
     self.assertTrue(np.allclose(depths, correctresult))
     return
Ejemplo n.º 5
0
 def test_count_casts(self):
     castlikes = [
         AbstractCast(),
         AbstractCast(),
         CastCollection([AbstractCast(), AbstractCast()]),
         AbstractCast()
     ]
     self.assertEqual(count_casts(castlikes), 5)
     return
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
class TestData():
    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 save_nwl(self):
        self.cast.save_json(join(self.path, "reference_cast_test.nwl"),
                            binary=False)
        self.collection.save_json(join(self.path, "reference_coll_test.nwl"),
                                  binary=False)

    def save_nwz(self):
        self.cast.save_json(join(self.path, "reference_cast_test.nwz"))
        self.collection.save_json(join(self.path, "reference_coll_test.nwz"))

    def save_hdf(self):
        self.cast.save_hdf(join(self.path, "reference_cast_test.h5"))
        self.collection.save_hdf(join(self.path, "reference_coll_test.h5"))
Ejemplo n.º 8
0
class TestData():

    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 save_nwl(self):
        self.cast.save_json(join(self.path, "reference_cast_test.nwl"), binary=False)
        self.collection.save_json(join(self.path, "reference_coll_test.nwl"), binary=False)

    def save_nwz(self):
        self.cast.save_json(join(self.path, "reference_cast_test.nwz"))
        self.collection.save_json(join(self.path, "reference_coll_test.nwz"))

    def save_hdf(self):
        self.cast.save_hdf(join(self.path, "reference_cast_test.h5"))
        self.collection.save_hdf(join(self.path, "reference_coll_test.h5"))
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
 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(self.p, temp=self.temp, sal=self.sal, date=dt)
     self.ctd = CTDCast(self.p, temp=self.temp, sal=self.sal, date=dt)
     self.ctdz = CTDCast(self.p, temp=self.temp, sal=self.sal, date=dt)
     self.xbt = XBTCast(self.p, temp=self.temp, sal=self.sal, date=dt)
     self.collection = CastCollection(self.ctd, self.xbt, self.ctd)
     return