Beispiel #1
0
        public Task <VariogramModule.IVariogram> GetSpatialVariogramAsync(LinearCombination.RealValueNodes nodes)
        {
            var task = taskFactory.StartNew(new Func <object, VariogramModule.IVariogram>(obj =>
            {
                Stopwatch sw = Stopwatch.StartNew();
                LinearCombination.RealValueNodes localNodes = (LinearCombination.RealValueNodes)obj;
                var variogramFitter = new LMDotNetVariogramFitter.Fitter() as VariogramModule.IVariogramFitter;

                traceSource.TraceEvent(TraceEventType.Start, 1, "Starting build of emperical variogram");
                var pointSet = new EmpVariogramBuilder.PointSet(localNodes.Lats, localNodes.Lons, localNodes.Values);

                var dist = FuncConvert.ToFSharpFunc(new Converter <Tuple <double, double>, FSharpFunc <Tuple <double, double>, double> >(t1 =>
                                                                                                                                         FuncConvert.ToFSharpFunc(new Converter <Tuple <double, double>, double>(t2 => SphereMath.GetDistance(t1.Item1, t1.Item2, t2.Item1, t2.Item2)))));

                var empVar = EmpVariogramBuilder.EmpiricalVariogramBuilder.BuildEmpiricalVariogram(pointSet, dist);
                sw.Stop();
                traceSource.TraceEvent(TraceEventType.Stop, 1, string.Format("Emperical variogram is build in {0}", sw.Elapsed));
                sw = Stopwatch.StartNew();
                traceSource.TraceEvent(TraceEventType.Start, 2, "Starting variogram fitting");
                var variogramRes = variogramFitter.Fit(empVar);
                sw.Stop();
                traceSource.TraceEvent(TraceEventType.Stop, 2, string.Format("Emperical variogram is build in {0}", sw.Elapsed));
                if (FSharpOption <VariogramModule.IDescribedVariogram> .get_IsNone(variogramRes))
                {
                    traceSource.TraceEvent(TraceEventType.Error, 3, "Fariogram fitting failed. Falling back to coarse variogram approximation");
                    return(variogramFitter.GetFallback(empVar));
                }
                else
                {
                    return(variogramRes.Value);
                }
            }), nodes);

            return(task);
        }
Beispiel #2
0
 public Task <VariogramModule.IVariogram> GetSpatialVariogramAsync(LinearCombination.RealValueNodes nodes)
 {
     return(component.GetAsync(nodes));
 }