public void PosteriorProbabilityTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTemp2005 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
                Raster rTemp2006 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));
                Raster rDoD      = RasterOperators.Subtract(rTemp2006, rTemp2005, new FileInfo(Path.Combine(tmp.Name, "rDoD.tif")));

                Raster GCDErosion1    = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.Erosion, 1, new FileInfo(Path.Combine(tmp.Name, "Erosion1.tif")));
                Raster GCDDeposition1 = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.Deposition, 1, new FileInfo(Path.Combine(tmp.Name, "Deposition1.tif")));
                Raster GCDAll1        = RasterOperators.NeighbourCount(rDoD, RasterOperators.GCDWindowType.All, 1, new FileInfo(Path.Combine(tmp.Name, "All1.tif")));

                ErrorRasterProperties props02 = new ErrorRasterProperties(0.2m);
                ErrorRasterProperties props01 = new ErrorRasterProperties(0.1m);
                // min 60% => 5 // max 100% => 9

                // 0.1 2006
                // 0.2 2005
                Raster r2005Error = RasterOperators.CreateErrorRaster(rTemp2005, props02, new FileInfo(Path.Combine(tmp.Name, "2005Dec_DEM_CONSTERR02.tif")));
                Raster r2006Error = RasterOperators.CreateErrorRaster(rTemp2006, props01, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));

                Raster propError = RasterOperators.RootSumSquares(r2006Error, r2005Error, new FileInfo(Path.Combine(tmp.Name, "properror.tif")));
                Raster postProb  = RasterOperators.CreatePriorProbabilityRaster(rDoD, propError, new FileInfo(Path.Combine(tmp.Name, "priorprob.tif")));

                Raster PostProb = RasterOperators.PosteriorProbability(rDoD, postProb, GCDErosion1, GCDDeposition1, new FileInfo(Path.Combine(tmp.Name, "postprob.tif")), new FileInfo(Path.Combine(tmp.Name, "cond.tif")), 5, 9);
            }
        }
        public void SetNullAbsoluteTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTemp2005 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
                Raster rTemp2006 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));
                Raster rDoD      = RasterOperators.Subtract(rTemp2006, rTemp2005, new FileInfo(Path.Combine(tmp.Name, "rDoD.tif")));

                ErrorRasterProperties props02 = new ErrorRasterProperties(0.2m);
                ErrorRasterProperties props01 = new ErrorRasterProperties(0.1m);
                // 0.1 2006
                // 0.2 2005
                Raster r2005Error = RasterOperators.CreateErrorRaster(rTemp2005, props02, new FileInfo(Path.Combine(tmp.Name, "2005Dec_DEM_CONSTERR02.tif")));
                Raster r2006Error = RasterOperators.CreateErrorRaster(rTemp2006, props01, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));
                Raster propError  = RasterOperators.RootSumSquares(r2006Error, r2005Error, new FileInfo(Path.Combine(tmp.Name, "properror.tif")));

                Raster rTemplateOutput5 = RasterOperators.AbsoluteSetNull(rDoD, RasterOperators.ThresholdOps.GreaterThan, propError, new FileInfo(Path.Combine(tmp.Name, "AbsRasterGreaterThan.tif")));
            }
        }
Exemple #3
0
        /// <summary>
        /// Single method Constructor
        /// </summary>
        /// <param name="rawDEM"></param>
        /// <param name="props"></param>
        /// <param name="outputRaster"></param>
        public CreateErrorRaster(Raster rawDEM, ErrorRasterProperties prop, Raster rOutputRaster) :
            base(new List <Raster> {
            rawDEM
        }, new List <Raster> {
            rOutputRaster
        })
        {
            _fisinputs = new Dictionary <string, List <int> >();
            _props     = new Dictionary <string, ErrorRasterProperties>()
            {
                { "", prop }
            };

            if (prop.TheType == ErrorRasterProperties.ERPType.ASSOC)
            {
                AddInputRaster(prop.AssociatedSurface);
                // Now keep track so we can find it later
                _assocRasters = new Dictionary <string, int>()
                {
                    { "", _inputRasters.Count - 1 }
                };
            }
            else if (prop.TheType == ErrorRasterProperties.ERPType.FIS)
            {
                _fisinputs[""] = new List <int>();
                _fisops        = new Dictionary <string, FISRasterOp>
                {
                    [""] = new FISRasterOp(prop.FISInputs, prop.FISRuleFile)
                };
                // Add the FIS rasters to these inputs so we can use them and keep track of their indices
                // so we can slice this data out and feed it to the FIS operator
                foreach (Raster fisinput in prop.FISInputs.Values)
                {
                    _fisinputs[""].Add(_inputRasters.Count);
                    AddInputRaster(fisinput);
                }
            }
        }
        public void ThresholdProbabilityNoSCTest()
        {
            using (ITempDir tmp = TempDir.Create())
            {
                Raster rTemp2005 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2005Dec_DEM\2005Dec_DEM.img")));
                Raster rTemp2006 = new Raster(new FileInfo(DirHelpers.GetTestRootPath(@"BudgetSeg\SulphurCreek\2006Feb_DEM\2006Feb_DEM.img")));
                Raster rDoD      = RasterOperators.Subtract(rTemp2006, rTemp2005, new FileInfo(Path.Combine(tmp.Name, "rDoD.tif")));

                ErrorRasterProperties props02 = new ErrorRasterProperties(0.2m);
                ErrorRasterProperties props01 = new ErrorRasterProperties(0.1m);
                // min 60% => 5 // max 100% => 9

                // 0.1 2006
                // 0.2 2005
                Raster r2005Error = RasterOperators.CreateErrorRaster(rTemp2005, props02, new FileInfo(Path.Combine(tmp.Name, "2005Dec_DEM_CONSTERR02.tif")));
                Raster r2006Error = RasterOperators.CreateErrorRaster(rTemp2006, props01, new FileInfo(Path.Combine(tmp.Name, "2006Feb_DEM_CONSTERR01.tif")));

                Raster propError = RasterOperators.RootSumSquares(r2006Error, r2005Error, new FileInfo(Path.Combine(tmp.Name, "properror.tif")));
                Raster postProb  = RasterOperators.CreatePriorProbabilityRaster(rDoD, propError, new FileInfo(Path.Combine(tmp.Name, "priorprob.tif")));

                Raster thrDoD = RasterOperators.ThresholdDoDProbability(rDoD, propError, new FileInfo(Path.Combine(tmp.Name, "tDoD.tif")), 0.95m);
            }
        }