Esempio n. 1
0
    def testDepthStatisticsRun(self):
        with TempDir() as d:
            neighborhood = 3    # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "'Mean Depth';Variance;"\
                    "'Standard Deviation';'Terrain Ruggedness (VRM)';"\
                    "'Interquartile Range';Kurtosis"

            depth_statistics.main(
                config.bathy_raster, neighborhood, out_workspace, stats)

            # mean of depth summary rasters
            mean_depths = {
                'mean': -20.56248074571827,
                'sdev': 0.2946229406453136,
                'var': 0.1281792675921596,
                'iqr': 0.45498055403516,
                'kurt': -0.90668194852357
            }

            for (prefix, expected_value) in mean_depths.items():
                raster_path = os.path.join(
                    d, "{0}_{1}_{2:03d}.tif".format(self.base,
                                                    prefix, neighborhood))
                self.assertTrue(os.path.exists(raster_path))
                self.assertAlmostEqual(
                    su.raster_properties(raster_path, 'MEAN'), expected_value)
Esempio n. 2
0
    def testDepthStatisticsRun(self):
        with TempDir() as d:
            neighborhood = 3  # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "'Mean Depth';Variance;"\
                    "'Standard Deviation';'Terrain Ruggedness (VRM)';"\
                    "'Interquartile Range';Kurtosis"

            depth_statistics.main(config.bathy_raster, neighborhood,
                                  out_workspace, stats)

            # mean of depth summary rasters
            mean_depths = {
                'mean': -20.56248074571827,
                'sdev': 0.2946229406453136,
                'var': 0.1281792675921596,
                'iqr': 0.45498055403516,
                'kurt': -0.90668194852357
            }

            for (prefix, expected_value) in mean_depths.items():
                raster_path = os.path.join(
                    d, "{0}_{1}_{2:03d}.tif".format(self.base, prefix,
                                                    neighborhood))
                self.assertTrue(os.path.exists(raster_path))
                self.assertAlmostEqual(
                    su.raster_properties(raster_path, 'MEAN'), expected_value)
Esempio n. 3
0
    def testDepthStatisticsOnlyDiffToMean(self):
        """test just difference to mean."""
        with TempDir() as d:
            neighborhood = 3    # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "'Difference to Mean'"

            depth_statistics.main(
                config.bathy_raster, neighborhood, out_workspace, stats)

            prefix = 'mean_diff'
            expected_value = -0.0055500285014563
            raster_path = os.path.join(
                d, "{0}_{1}_{2:03d}.tif".format(self.base,
                                                    prefix, neighborhood))
            self.assertTrue(os.path.exists(raster_path))
            self.assertAlmostEqual(
                su.raster_properties(raster_path, 'MEAN'), expected_value)
Esempio n. 4
0
    def testDepthStatisticsOnlyDiffToMean(self):
        """test just difference to mean."""
        with TempDir() as d:
            neighborhood = 3  # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "'Difference to Mean'"

            depth_statistics.main(config.bathy_raster, neighborhood,
                                  out_workspace, stats)

            prefix = 'mean_diff'
            expected_value = -0.0055500285014563
            raster_path = os.path.join(
                d, "{0}_{1}_{2:03d}.tif".format(self.base, prefix,
                                                neighborhood))
            self.assertTrue(os.path.exists(raster_path))
            self.assertAlmostEqual(su.raster_properties(raster_path, 'MEAN'),
                                   expected_value)
Esempio n. 5
0
    def testDepthStatisticsRun(self):
        with TempDir() as d:
            neighborhood = 3 # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "Mean Depth;Variance;Standard Deviation"
            depth_statistics.main(config.bathy_raster, neighborhood,
                    out_workspace, stats)

            # mean of depth summary rasters
            mean_depths = {
                'meandepth': -20.56248074571827,
                'stdevdepth': 0.2946229406453136,
                'vardepth': 0.1281792675921596}

            for (stat, mean_value) in mean_depths.items():
                raster = os.path.join(d, stat)
                self.assertTrue(os.path.exists(raster))
                self.assertAlmostEqual(su.raster_properties(raster, "MEAN"), \
                        mean_value)
Esempio n. 6
0
    def testDepthStatisticsRun(self):
        with TempDir() as d:
            neighborhood = 3  # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "Mean Depth;Variance;Standard Deviation"
            depth_statistics.main(config.bathy_raster, neighborhood,
                                  out_workspace, stats)

            # mean of depth summary rasters
            mean_depths = {
                'meandepth': -20.56248074571827,
                'stdevdepth': 0.2946229406453136,
                'vardepth': 0.1281792675921596
            }

            for (stat, mean_value) in mean_depths.items():
                raster = os.path.join(d, stat)
                self.assertTrue(os.path.exists(raster))
                self.assertAlmostEqual(su.raster_properties(raster, "MEAN"),
                                       mean_value)
Esempio n. 7
0
    def testDepthStatisticsKurtosisExact(self):
        """Check for an exact raster match for kurtosis raster."""
        with TempDir() as d:
            neighborhood = 3    # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "Kurtosis"

            depth_statistics.main(
                config.bathy_raster, neighborhood, out_workspace, stats)

            raster_path = os.path.join(
                    d, "{}_kurt_{:03d}.tif".format(self.base, neighborhood))

            self.assertTrue(os.path.exists(raster_path))

            # convert output raster to a NumPy array
            kurt_computed = arcpy.RasterToNumPyArray(raster_path)

            # load the comparison array
            kurt_known = np.load(config.kurtosis_npy)

            # seeing differences on the order of 1e-7, turn down tolerance
            self.assertTrue(np.allclose(kurt_computed, kurt_known, atol=1e-6))
Esempio n. 8
0
    def testDepthStatisticsKurtosisExact(self):
        """Check for an exact raster match for kurtosis raster."""
        with TempDir() as d:
            neighborhood = 3  # 3x3 neighborhood
            arcpy.env.scratchWorkspace = d
            out_workspace = d
            stats = "Kurtosis"

            depth_statistics.main(config.bathy_raster, neighborhood,
                                  out_workspace, stats)

            raster_path = os.path.join(
                d, "{}_kurt_{:03d}.tif".format(self.base, neighborhood))

            self.assertTrue(os.path.exists(raster_path))

            # convert output raster to a NumPy array
            kurt_computed = arcpy.RasterToNumPyArray(raster_path)

            # load the comparison array
            kurt_known = np.load(config.kurtosis_npy)

            # seeing differences on the order of 1e-7, turn down tolerance
            self.assertTrue(np.allclose(kurt_computed, kurt_known, atol=1e-6))