Exemple #1
0
        // [TestMethod()]
        public void NormPathLengthTest()
        {
            var target    = new NormPathLength(); // TODO: 初始化为适当的值
            var matReader = new MatlabMatrixReader <double>(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\X.mat");
            var input     = matReader.ReadMatrix();

            var actual = target.Process((Matrix)input, RIPP.Lib.MathLib.VectorType.Row);

            var writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\filter\out_normpathlength_my.mat");

            writer.WriteMatrix <double>(actual, "dd");
            writer.Close();

            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\filter\out_normpathlength_mx_my.mat");
            writer.WriteMatrix <double>(target.Mean.ToColumnMatrix(), "mxmy");
            writer.Close();

            var Scale = target.Scale.ToColumnMatrix().Clone();

            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\filter\out_normpathlength_sd_my.mat");
            writer.WriteMatrix <double>(Scale, "sdmy");
            writer.Close();
        }
Exemple #2
0
        //  [TestMethod]
        public void SpectraFitTest()
        {
            var matReader = new MatlabMatrixReader <double>(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\cx.mat");
            var cx        = matReader.ReadMatrix();

            matReader = new MatlabMatrixReader <double>(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\vx.mat");

            var vx = matReader.ReadMatrix();

            var f1 = new Sgdiff();

            f1.P = 2;
            var cx1    = f1.Process((Matrix)cx);
            var writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\cx1.mat");

            writer.WriteMatrix <double>(cx1, "cx1");
            writer.Close();



            var f2  = new SavitzkyGolay(5);
            var cx2 = f2.Process((Matrix)cx1);

            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\cx2.mat");
            writer.WriteMatrix <double>(cx2, "cx2");
            writer.Close();


            var f3 = new VarRegionManu();

            f3.Xaxis = new DenseVector(cx.RowCount);
            for (int i = 1; i <= cx.RowCount; i++)
            {
                f3.Xaxis[i - 1] = i;
            }
            var a = f3.Argus;

            a["Xaxis"].Value = f3.Xaxis;


            f3.XaxisRegion = new System.Collections.Generic.List <RegionPoint>();
            f3.XaxisRegion.Add(new RegionPoint(131, 314));
            f3.XaxisRegion.Add(new RegionPoint(468, 677));
            a["XaxisRegion"].Value = f3.XaxisRegion;
            f3.Argus = a;

            var lst = new System.Collections.Generic.List <Vector>();

            for (int i = 0; i < cx2.ColumnCount; i++)
            {
                lst.Add(f3.VarProcess((Vector)cx2.Column(i)));
            }
            var cx3 = new DenseMatrix(lst[0].Count, cx2.ColumnCount);

            for (int i = 0; i < cx2.ColumnCount; i++)
            {
                cx3.SetColumn(i, lst[i]);
            }


            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\cx3.mat");
            writer.WriteMatrix <double>(cx3, "cx3");
            writer.Close();


            var f4  = new NormPathLength();
            var cx4 = f4.Process(cx3);

            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\cx4.mat");
            writer.WriteMatrix <double>(cx4, "cx4");
            writer.Close();


            matReader = new MatlabMatrixReader <double>(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\mcx4.mat");
            cx4       = (Matrix)matReader.ReadMatrix();


            var fitr = new DenseMatrix(cx4.ColumnCount - 1, cx4.ColumnCount);

            for (int i = 0; i < cx4.ColumnCount; i++)
            {
                var subm = new DenseMatrix(cx4.RowCount, cx4.ColumnCount - 1);
                int tag  = 0;
                for (int k = 0; k < cx4.ColumnCount; k++)
                {
                    if (k == i)
                    {
                        continue;
                    }
                    subm.SetColumn(tag, cx4.Column(k));
                    tag++;
                }

                var fr = SpectraFit.Fit((Matrix)subm, (Vector)cx4.Column(i));


                fitr.SetColumn(i, fr);
            }

            writer = new MatlabMatrixWriter(@"F:\3506\15chemometrics\RIPP_DEMO\src\RIPP\testdata\fit\fitr.mat");
            writer.WriteMatrix <double>(fitr, "fitr");
            writer.Close();
        }