Exemplo n.º 1
0
    def test_2(self):
        """ test coordinates values """

        dataset = ldm.open_dataset("test_dyn_diff.lue")

        frame = df.select(dataset.phenomenon,
                          property_names=['property1', 'property2'])

        p = frame['phenomenon']['prop_set']['property1']

        obj = p[2]
        rows = obj.values.shape[1]
        cols = obj.values.shape[2]

        xcellsize = math.fabs(obj.xcoord[1].values - obj.xcoord[0].values)
        ycellsize = math.fabs(obj.ycoord[1].values - obj.ycoord[0].values)

        self.assertAlmostEqual(1, obj.xcoord[0].values)
        self.assertAlmostEqual(3, obj.xcoord[0].values + cols * xcellsize)

        self.assertAlmostEqual(2, obj.ycoord[0].values)
        self.assertAlmostEqual(4, obj.ycoord[0].values + rows * ycellsize)

        obj = p[5]
        rows = obj.values.shape[1]
        cols = obj.values.shape[2]
        xcellsize = math.fabs(obj.xcoord[1].values - obj.xcoord[0].values)
        ycellsize = math.fabs(obj.ycoord[1].values - obj.ycoord[0].values)

        self.assertAlmostEqual(5, obj.xcoord[0].values)
        self.assertAlmostEqual(11, obj.xcoord[0].values + cols * xcellsize)

        self.assertAlmostEqual(6, obj.ycoord[0].values)
        self.assertAlmostEqual(12, obj.ycoord[0].values + rows * ycellsize)

        obj = p[4]
        rows = obj.values.shape[1]
        cols = obj.values.shape[2]
        xcellsize = math.fabs(obj.xcoord[1].values - obj.xcoord[0].values)
        ycellsize = math.fabs(obj.ycoord[1].values - obj.ycoord[0].values)

        self.assertAlmostEqual(13, obj.xcoord[0].values)
        self.assertAlmostEqual(20, obj.xcoord[0].values + cols * xcellsize)

        self.assertAlmostEqual(14, obj.ycoord[0].values)
        self.assertAlmostEqual(21, obj.ycoord[0].values + rows * ycellsize)
Exemplo n.º 2
0
  def  test_2(self):
    """ test coordinates values """
    dataset = ldm.open_dataset("test_const_same.lue")

    frame = df.select(dataset.catchment, property_names=['property1', 'property2'])

    pp = frame['catchment']['static_point']['property1']

    coords = pp['coordinates']
    arr = np.arange(6, dtype=np.float32).reshape(3, 2)
    self.assertEqual(True, np.allclose(arr, coords.values))

    fp = frame['catchment']['static_area']['property2']

    coords = fp['coordinates']
    arr = np.arange(12, dtype=np.float32).reshape(3, 4)
    self.assertEqual(True, np.array_equal(arr, coords.values))
Exemplo n.º 3
0
    def test_4(self):
        """ test access by time step """

        dataset = ldm.open_dataset("test_dyn_diff.lue")

        frame = df.select(dataset.phenomenon,
                          property_names=['property1', 'property2'])

        p = frame['phenomenon']['prop_set']['property1']

        # Oid 2, 2nd timestep
        obj = p[2]
        res = obj.loc['2002-02-03', :]

        arr = np.array([[[5.507979, 7.081478, 2.9090474],
                         [5.108276, 8.929469, 8.962931]]],
                       dtype=np.float32)

        self.assertEqual(True, np.allclose(arr, res.values))
Exemplo n.º 4
0
  def  test_1(self):
    """ test property values """

    dataset = ldm.open_dataset("test_const_same.lue")

    frame = df.select(dataset.catchment, property_names=['property1', 'property2'])

    pp = frame['catchment']['static_point']['property1']

    obj_values = pp['values']
    arr = np.array([0.4359949 , 0.02592623, 0.5496625 ], dtype=np.float32)
    self.assertEqual(True, np.allclose(arr, obj_values.values))


    pp = frame['catchment']['static_point']['property2']
    obj_values = pp['values']
    arr = np.array([8, 0, 10], dtype=np.int32)
    self.assertEqual(True, np.array_equal(arr, obj_values.values))

    fp = frame['catchment']['static_area']['property1']

    obj_values = fp['values']
    arr = np.array([[[0.4359949 , 0.02592623, 0.5496625 , 0.4353224 ],
        [0.4203678 , 0.3303348 , 0.20464863, 0.619271  ]],

       [[0.29965466, 0.2668273 , 0.6211338 , 0.5291421 ],
        [0.13457994, 0.5135781 , 0.18443987, 0.7853351 ]],

       [[0.8539753 , 0.49423683, 0.8465615 , 0.07964548],
        [0.5052461 , 0.0652865 , 0.42812234, 0.09653091]]], dtype=np.float32)
    self.assertEqual(True, np.allclose(arr, obj_values.values))

    fp = frame['catchment']['static_area']['property2']
    obj_values = fp['values']
    arr = np.array([[[ 8,  0, 10,  8],
        [ 8,  6,  4, 12]],

       [[ 5,  5, 12, 10],
        [ 2, 10,  3, 15]],

       [[17,  9, 16,  1],
        [10,  1,  8,  1]]], dtype=np.int32)
    self.assertEqual(True, np.array_equal(arr, obj_values.values))
Exemplo n.º 5
0
    def test_1(self):
        """ test property values """

        dataset = ldm.open_dataset("test_dyn_diff.lue")

        frame = df.select(dataset.phenomenon,
                          property_names=['property1', 'property2'])

        p = frame['phenomenon']['prop_set']['property1']

        arr = np.array([[
            [4.359949, 0.25926232, 5.496625], [4.353224, 4.203678, 3.3033483]
        ], [[5.507979, 7.081478, 2.9090474], [5.108276, 8.929469, 8.962931]],
                        [[9.670299, 5.4723225, 9.726844],
                         [7.14816, 6.9772882, 2.1608949]]],
                       dtype=np.float32)

        v = p[2]

        self.assertEqual(True, np.allclose(arr, v.values))

        v = p[5]
        arr = np.array(
            [[[4.359949, 0.25926232, 5.496625, 4.353224, 4.203678],
              [3.3033483, 2.0464864, 6.1927094, 2.9965467, 2.6682727],
              [6.2113385, 5.291421, 1.3457994, 5.1357813, 1.8443986],
              [7.8533516, 8.539753, 4.9423685, 8.465615, 0.7964548]],
             [[5.507979, 7.081478, 2.9090474, 5.108276, 8.929469],
              [8.962931, 1.255853, 2.0724287, 0.51467204, 4.408098],
              [0.2987621, 4.568332, 6.4914403, 2.7848728, 6.762549],
              [5.908628, 0.23981883, 5.588541, 2.5925245, 4.151012]],
             [[9.670299, 5.4723225, 9.726844, 7.14816, 6.9772882],
              [2.1608949, 9.762745, 0.06230255, 2.5298235, 4.347915],
              [7.7938294, 1.9768507, 8.629932, 9.834006, 1.6384224],
              [5.9733396, 0.08986098, 3.865713, 0.4416006, 9.566529]]],
            dtype=np.float32)

        self.assertEqual(True, np.allclose(arr, v.values))

        v = p[4]
        #self.assertEqual(True, np.allclose(arr, v.values))

        p = frame['phenomenon']['prop_set']['property2']

        v = p[2]
        arr = np.array([[[8, 0, 10], [8, 8, 6]], [[11, 14, 5], [10, 17, 17]],
                        [[19, 10, 19], [14, 13, 4]]],
                       dtype=np.int32)

        self.assertEqual(True, np.array_equal(arr, v.values))

        v = p[5]
        arr = np.array([[[8, 0, 10, 8, 8], [6, 4, 12, 5, 5],
                         [12, 10, 2, 10, 3], [15, 17, 9, 16, 1]],
                        [[11, 14, 5, 10, 17], [17, 2, 4, 1, 8],
                         [0, 9, 12, 5, 13], [11, 0, 11, 5, 8]],
                        [[19, 10, 19, 14, 13], [4, 19, 0, 5, 8],
                         [15, 3, 17, 19, 3], [11, 0, 7, 0, 19]]],
                       dtype=np.int32)

        self.assertEqual(True, np.array_equal(arr, v.values))

        v = p[4]
        arr = np.array(
            [[[8, 0, 10, 8, 8, 6, 4], [12, 5, 5, 12, 10, 2, 10],
              [3, 15, 17, 9, 16, 1, 10], [1, 8, 1, 2, 11, 4, 2],
              [4, 6, 9, 4, 12, 9, 10], [7, 15, 11, 3, 14, 19, 10]],
             [[11, 14, 5, 10, 17, 17, 2], [4, 1, 8, 0, 9, 12, 5],
              [13, 11, 0, 11, 5, 8, 5], [13, 8, 3, 10, 15, 6, 4],
              [7, 18, 19, 13, 18, 16, 7], [1, 13, 11, 7, 4, 8, 9]],
             [[19, 10, 19, 14, 13, 4, 19], [0, 5, 8, 15, 3, 17, 19],
              [3, 11, 0, 7, 0, 19, 8], [18, 15, 17, 3, 1, 12, 3],
              [14, 8, 10, 18, 10, 2, 3], [10, 10, 12, 8, 12, 7, 12]]],
            dtype=np.int32)

        self.assertEqual(True, np.array_equal(arr, v.values))
Exemplo n.º 6
0
    def test_1(self):
        """ test array values """

        dataset = ldm.open_dataset("catchments.lue")

        frame = df.select(dataset.catchment,
                          property_names=['property1', 'property2'])

        p = frame['catchment']['static']['property1']

        arr = np.array([[4.359949, 0.25926232, 5.496625],
                        [4.353224, 4.203678, 3.3033483]],
                       dtype=np.float32)

        obj = p[2]

        self.assertEqual(True, np.allclose(arr, obj.values))

        obj = p[5]
        arr = np.array(
            [[1.3457994, 5.1357813, 1.8443986, 7.8533516, 8.539753],
             [4.9423685, 8.465615, 0.7964548, 5.0524607, 0.65286505],
             [4.2812233, 0.96530914, 1.2715998, 5.967453, 2.26012],
             [1.0694568, 2.203062, 3.498263, 4.677875, 2.0174322]],
            dtype=np.float32)

        self.assertEqual(True, np.allclose(arr, obj.values))

        obj = p[4]
        arr = np.array([[
            3.663424, 8.508505, 4.0627503, 0.27202365, 2.4717724, 0.6714437,
            9.93852
        ],
                        [
                            9.705803, 8.0025835, 6.0181713, 7.6495986,
                            1.6922544, 2.9302323, 5.240669
                        ],
                        [
                            3.5662427, 0.45678964, 9.831534, 4.4135494,
                            5.0400043, 3.235413, 2.5974476
                        ],
                        [
                            3.8688989, 8.320169, 7.3674707, 3.7921057,
                            0.13017337, 7.9740496, 2.693888
                        ],
                        [
                            5.826849, 0.2555094, 6.6220202, 3.8752344,
                            4.970738, 4.1490583, 3.508719
                        ],
                        [
                            5.509779, 9.729107, 1.1277622, 3.1325853,
                            0.4179771, 7.3839974, 6.575124
                        ]],
                       dtype=np.float32)

        self.assertEqual(True, np.allclose(arr, obj.values))

        p = frame['catchment']['static']['property2']

        obj = p[2]
        arr = np.array([[4, 12, 5], [5, 12, 10]], dtype=np.int32)

        self.assertEqual(True, np.array_equal(arr, obj.values))

        obj = p[5]
        arr = np.array([[12, 9, 10, 7, 15], [11, 3, 14, 19, 10],
                        [17, 6, 11, 8, 8], [15, 10, 19, 10, 1]],
                       dtype=np.int32)

        self.assertEqual(True, np.array_equal(arr, obj.values))

        obj = p[4]
        arr = np.array([[4, 8, 12, 13, 3, 17, 15], [2, 17, 14, 15, 10, 4, 18],
                        [11, 6, 5, 18, 8, 10, 12], [16, 12, 3, 11, 9, 10, 13],
                        [4, 3, 2, 5, 0, 12, 5], [3, 1, 5, 4, 5, 9, 10]],
                       dtype=np.int32)
        self.assertEqual(True, np.array_equal(arr, obj.values))
Exemplo n.º 7
0
  def  test_1(self):
    """ test property values """

    dataset = ldm.open_dataset("test_dyn_same.lue")

    frame = df.select(dataset.catchment, property_names=['property1', 'property2'])


    p = frame['catchment']['dynamic_point']['property1']

    arr = np.array([[0.4359949 , 0.02592623, 0.5496625 , 0.4353224 ],
       [0.4203678 , 0.3303348 , 0.20464863, 0.619271  ],
       [0.29965466, 0.2668273 , 0.6211338 , 0.5291421 ]], dtype=np.float32)

    obj_values = p['values']
    self.assertEqual(True, np.allclose(arr, obj_values.values))


    p = frame['catchment']['dynamic_point']['property2']
    obj_values = p['values']
    arr = np.array([[ 8,  0, 10,  8],
       [ 8,  6,  4, 12],
       [ 5,  5, 12, 10]], dtype=np.int32)

    self.assertEqual(True, np.allclose(arr, obj_values.values))


    p = frame['catchment']['dynamic_area']['property2']
    obj_values = p['values']
    arr = np.array([[[[11,  6,  5, 18],
         [ 8, 10, 12, 16]],

        [[12,  3, 11,  9],
         [10, 13,  4,  3]],

        [[ 2,  5,  0, 12],
         [ 5,  3,  1,  5]],

        [[ 4,  5,  9, 10],
         [16, 19,  0,  4]]],


       [[[12,  3, 17,  4],
         [14, 13, 15,  0]],

        [[ 4, 14,  1,  0],
         [ 7, 11,  1,  1]],

        [[ 0,  7, 13,  3],
         [17,  8, 12,  5]],

        [[12, 19,  8,  4],
         [ 8,  8, 10, 10]]],


       [[[ 0,  3,  9, 14],
         [15, 15, 10, 19]],

        [[ 6,  9, 14, 17],
         [ 8, 16,  8, 14]],

        [[ 0,  0, 18,  2],
         [13,  5,  4,  7]],

        [[18, 11, 18, 14],
         [10, 10,  4,  0]]]], dtype=np.int32)

    self.assertEqual(True, np.array_equal(arr, obj_values.values))