コード例 #1
0
    def test_single_variogram_raster(self):
        si = spatialinventory.RasterInventory("N2O-Agrar-2012", "g/m2",
                                              "Example N2O inventory of "
                                              "organic soils",
                                              ("2012-01-01 00:00:00",
                                               "2013-01-01 00:00:00"),
                                              creator="Tester")

        si.import_inventory_as_raster(self.invin, self.uncertin)
        v = variogram.Variogram()
        coords = si.get_coord()
        data = np.hstack((coords, si.inv_array.reshape((si.inv_array.size,
                                                        1))))
        sv1 = v.semivvarh(data, 5, 5)
        sv2 = v.semivvarh(data, 50, 5)
        self.assertEqual(round(sv1, 3), 0.168)
        self.assertEqual(round(sv2, 3), 0.217)
コード例 #2
0
    def test_plot_variogram_raster(self):
        si = spatialinventory.RasterInventory("N2O-Agrar-2012", "g/m2",
                                              "Example N2O inventory of "
                                              "organic soils",
                                              ("2012-01-01 00:00:00",
                                               "2013-01-01 00:00:00"),
                                              creator="Tester")
        v = variogram.Variogram()
        si.import_inventory_as_raster(self.invin, self.uncertin)
        sv, svm, c, c0 = si.get_variogram(10, 80, True)
        si.plot_variogram("/tmp/sauventory_test_spherical_vario.png")
        sv, svm, c, c0 = si.get_variogram(10, 80, True, type=v.gaussian)
        si.plot_variogram("/tmp/sauventory_test_gaussian_vario.png")
        sv, svm, c, c0 = si.get_variogram(10, 80, True, type=v.exponential)
        si.plot_variogram("/tmp/sauventory_test_exponential_vario.png")

        self.assertEqual(round(np.max(sv[1]), 3), 0.245)
        self.assertEqual(round(np.min(si.inv_sv[1]), 3), 0.168)
コード例 #3
0
 def test_soil_variogram(self):
     v = variogram.Variogram()
     si = spatialinventory.SpatialInventory("Soil data", "g/m2",
                                            "Example soil data",
                                            ("1990-01-01 00:00:00",
                                             "1990-01-01 00:00:00"))
     data = self.sdata[:, :3]
     si.inv_coord = data[:, :2]
     si.inv_array = data[:, 2]
     # print(data)
     # Define variogram parameters
     bw = 100  # Bandwidth
     hmax = 1200  # Maximum distance
     hs = np.arange(0, 600, bw)  # Distance intervals
     sv, svmodel, c, c0 = si.get_variogram(bw, hmax, model=True,
                                           type=v.nugget)
     cov = si.get_covariance(bw, hmax)
     si.plot_variogram(file="/tmp/sauventory_test_soil_vario.png",
                       caxis=True, naxis=True)
コード例 #4
0
    def test_empirical_variogram_raster(self):
        si = spatialinventory.RasterInventory("N2O-Agrar-2012", "g/m2",
                                              "Example N2O inventory of "
                                              "organic soils",
                                              ("2012-01-01 00:00:00",
                                               "2013-01-01 00:00:00"),
                                              creator="Tester")

        si.import_inventory_as_raster(self.invin, self.uncertin)
        v = variogram.Variogram()
        coords = si.get_coord()
        data = np.hstack((coords, si.inv_array.reshape((si.inv_array.size,
                                                        1))))
        # Define variogram parameters
        bw = 10  # Bandwidth
        hs = np.arange(0, 80, bw)  # Distance intervals
        svario = v.semivvar(data, hs, bw)
        self.assertEqual(round(np.max(svario[1]), 3), 0.245)
        self.assertEqual(round(np.min(svario[1]), 3), 0.168)
コード例 #5
0
    def test_single_variogram_vector(self):
        si = spatialinventory.VectorInventory("N2O-Agrar-EU-2010", "Gg",
                                              "N2O inventory for EU-27"
                                              "emissions from agriculture",
                                              ("2010-01-01 00:00:00",
                                               "2011-01-01 00:00:00"),
                                              creator="Tester")

        si.import_inventory_as_vector(self.invvector, 'n2o_Gg',
                                      uncert='uncert_Gg', index='NUTS_ID',
                                      relative=True)
        v = variogram.Variogram()
        coords = si.get_coord()
        data = np.hstack((coords, si.inv_array.reshape((si.inv_array.size,
                                                        1))))
        sv1 = v.semivvarh(data, 10, 8)
        sv2 = v.semivvarh(data, 20, 8)
        self.assertEqual(round(sv1, 3), 136703201.471)
        self.assertEqual(round(sv2, 3), 145110190.277)
コード例 #6
0
    def test_gaussian_variogram_raster(self):
        si = spatialinventory.RasterInventory("N2O-Agrar-2012", "g/m2",
                                              "Example N2O inventory of "
                                              "organic soils",
                                              ("2012-01-01 00:00:00",
                                               "2013-01-01 00:00:00"),
                                              creator="Tester")

        si.import_inventory_as_raster(self.invin, self.uncertin)
        v = variogram.Variogram()
        coords = si.get_coord()
        data = np.hstack((coords, si.inv_array.reshape((si.inv_array.size,
                                                        1))))
        # Define variogram parameters
        bw = 10  # Bandwidth
        hs = np.arange(0, 80, bw)  # Distance intervals
        # svario = v.semivvar(data, hs, bw)
        svmodel, svario, c, c0 = v.cvmodel(data, hs, bw, model=v.gaussian)
        self.assertEqual(round(svmodel(svario[0][0]), 3), 0.)
        self.assertEqual(round(svmodel(svario[0][7]), 3), 0.340)
コード例 #7
0
    def test_empirical_variogram_vector(self):
        si = spatialinventory.VectorInventory("N2O-Agrar-EU-2010", "Gg",
                                              "N2O inventory for EU-27"
                                              "emissions from agriculture",
                                              ("2010-01-01 00:00:00",
                                               "2011-01-01 00:00:00"),
                                              creator="Tester")

        si.import_inventory_as_vector(self.invvector, 'n2o_Gg',
                                      uncert='uncert_Gg', index='NUTS_ID',
                                      relative=True)
        v = variogram.Variogram()
        coords = si.get_coord()
        data = np.hstack((coords, si.inv_array.reshape((si.inv_array.size,
                                                        1))))

        # Define variogram parameters
        bw = 10  # Bandwidth
        hs = np.arange(0, 80, bw)  # Distance intervals
        svario = v.semivvar(data, hs, bw)
        self.assertEqual(round(np.max(svario[1]), 3), 142924111.258)
        self.assertEqual(round(np.min(svario[1]), 3), 16520.533)