/// <summary> /// 生产平差器 /// </summary> /// <param name="type"></param> /// <returns></returns> public static MatrixAdjuster Create(AdjustmentType type) { MatrixAdjuster Adjustment = null; switch (type) { case AdjustmentType.参数平差: Adjustment = new ParamAdjuster(); break; case AdjustmentType.条件平差: Adjustment = new ConditionalAdjuster(); break; case AdjustmentType.具有参数的条件平差: Adjustment = new ConditionalAdjusterWithParam(); break; case AdjustmentType.具有条件的参数平差: Adjustment = new ParamAdjusterWithCondition(); break; case AdjustmentType.卡尔曼滤波: Adjustment = new SimpleKalmanFilter(); // Adjustment = new KalmanFilter(); break; case AdjustmentType.均方根滤波: Adjustment = new SquareRootInformationFilter(); break; case AdjustmentType.序贯平差: Adjustment = new SequentialAdjuster(); break; case AdjustmentType.参数加权平差: Adjustment = new WeightedParamAdjuster(); break; case AdjustmentType.递归最小二乘: Adjustment = new RecursiveAdjuster(); break; case AdjustmentType.单期递归最小二乘: Adjustment = new SingleRecursiveAdjuster(); break; default: //Adjustment = new ParamAdjuster(); break; } if (Adjustment == null) { throw new Exception("尚未实现 " + type); } return(Adjustment); }
/// <summary> /// 滤波 /// </summary> /// <param name="newVal"></param> /// <returns></returns> public RmsedNumeral Filter(RmsedNumeral newVal) { var builder = new OneDimAdjustMatrixBuilder(newVal, PrevAdjustment); var sp = new SimpleKalmanFilter(); var a = sp.Run(builder); var est = a.Estimated; this.PrevAdjustment = a;//update return(new RmsedNumeral(est[0], est.GetRmsVector()[0])); }
/// <summary> /// 水平Kalman滤波 /// </summary> /// <param name="val"></param> /// <returns></returns> private double DoLevelKalmanFilter(double val) { var builder = new OneDimAdjustMatrixBuilder(val, Adjustment); var sp = new SimpleKalmanFilter(); Adjustment = sp.Run(builder); var smoothData = Adjustment.Estimated[0]; return(smoothData); }
/// <summary> /// 滤波。默认期望为常数。 /// </summary> /// <param name="rawValue"></param> /// <returns></returns> protected double Filter(double rawValue) { AdjustResultMatrix prev = CurrentAdjustment; var builder = new OneDimAdjustMatrixBuilder(rawValue, prev); var sp = new SimpleKalmanFilter(); var ad = sp.Run(builder); CurrentAdjustment = ad; var smoothData = ad.Estimated[0]; return(smoothData); }