Пример #1
0
 public bool AddID(string modelpath)
 {
     if (string.IsNullOrWhiteSpace(modelpath))
     {
         return(false);
     }
     return(this.AddID(BindModel.ReadModel <IdentifyModel>(modelpath)));
 }
Пример #2
0
 public bool AddAnn(string modelpath)
 {
     if (string.IsNullOrWhiteSpace(modelpath))
     {
         return(false);
     }
     return(this.AddAnn(BindModel.ReadModel <PLSSubModel>(modelpath)));
 }
Пример #3
0
 public bool CheckPLSIsExist(string modelPath, bool ispls1)
 {
     if (string.IsNullOrWhiteSpace(modelPath))
     {
         return(false);
     }
     return(this.CheckPLSIsExist(BindModel.ReadModel <PLSSubModel>(modelPath), ispls1));
 }
Пример #4
0
 public bool AddFit(string modelpath)
 {
     if (string.IsNullOrWhiteSpace(modelpath))
     {
         return(false);
     }
     return(this.AddFit(BindModel.ReadModel <FittingModel>(modelpath)));
 }
Пример #5
0
        /// <summary>
        /// 将方法加载为方法包
        /// </summary>
        /// <param name="fullPath"></param>
        /// <returns></returns>
        public static BindModel LoadModel(string fullPath)
        {
            if (string.IsNullOrWhiteSpace(fullPath))
            {
                return(null);
            }
            FileInfo  info = new FileInfo(fullPath);
            BindModel m    = null;

            var exten = info.Extension.ToLower().Substring(1);

            if (exten == FileExtensionEnum.Allmethods.ToString().ToLower())
            {
                m = BindModel.ReadModel <BindModel>(fullPath);
            }
            else if (exten == FileExtensionEnum.IdLib.ToString().ToLower())
            {
                m = new BindModel();
                m.AddID(BindModel.ReadModel <IdentifyModel>(fullPath));
            }
            else if (exten == FileExtensionEnum.FitLib.ToString().ToLower())
            {
                m = new BindModel();
                m.AddFit(BindModel.ReadModel <FittingModel>(fullPath));
            }
            else if (exten == FileExtensionEnum.PLSBind.ToString().ToLower())
            {
                m = new BindModel();

                m.PLS = BindModel.ReadModel <PLSModel>(fullPath);
            }
            else if (exten == FileExtensionEnum.ItgBind.ToString().ToLower())
            {
                m     = new BindModel();
                m.Itg = BindModel.ReadModel <IntegrateModel>(fullPath);
            }
            m.FullPath = fullPath;
            m.Name     = info.Name.Replace(info.Extension, "");
            return(m);
        }
Пример #6
0
        public IntegratePropertyResult Predict(Spectrum spec, bool needFilter = true)
        {
            IntegratePropertyResult result = new IntegratePropertyResult()
            {
                FitRate    = this.FitRate,
                IDRate     = this.IDRate,
                PLS1Rate   = this.PLS1Rate,
                PLSANNRate = this.PLSANNRate,
                Comp       = this._comp.Clone()
            };

            if (this._comp == null)//性质为空,则返回NULL
            {
                return(null);
            }


            if (this._pls1 != null && this._pls1.Comp.Name == this._comp.Name)
            {
                result.PLS1Result = this._pls1.Predict(spec, needFilter);
            }
            if (this._plsann != null && this._plsann.Comp.Name == this._comp.Name)
            {
                result.PLSANNResult = this._plsann.Predict(spec, needFilter);
            }

            //识别
            if (this._identify != null && this._identify.Count > 0)
            {
                foreach (var i in this._identify)
                {
                    if (i.SpecLib.Components.Contains(this._comp.Name))
                    {
                        result.IDResult = BindModel.CombineIdResult(result.IDResult, i.Predict(spec, needFilter));
                    }
                }
                //过滤其它性质
                ComponentList clst = new ComponentList();
                foreach (var c in result.IDResult.Components)
                {
                    if (c.Name == this._comp.Name)
                    {
                        clst.Add(c.Clone());
                        break;
                    }
                }
                foreach (var s in result.IDResult.Items)
                {
                    var c = s.Spec.Components[this._comp.Name].Clone();
                    s.Spec.Components = new ComponentList();
                    s.Spec.Components.Add(c);
                }
                result.IDResult.Components = clst;
            }

            //拟合
            if (this._fittings != null && this._fittings.Count > 0)
            {
                var fitmodel = Serialize.DeepClone <FittingModel>(this._fittings.First());
                for (int i = 1; i < this._fittings.Count; i++)
                {
                    if (this._fittings[i].SpecLib.Components.Contains(this._comp.Name))
                    {
                        fitmodel.SpecLib.Merger(this._fittings[i].SpecLib);
                    }
                }
                result.FitResult = fitmodel.Predict(spec, needFilter);
                //过滤其它性质
                ComponentList clst = new ComponentList();
                foreach (var c in result.FitResult.FitSpec.Components)
                {
                    if (c.Name == this._comp.Name)
                    {
                        clst.Add(c.Clone());
                        break;
                    }
                }
                result.FitResult.FitSpec.Components = clst;

                foreach (var s in result.FitResult.Specs)
                {
                    var c = s.Spec.Components[this._comp.Name].Clone();
                    s.Spec.Components = new ComponentList();
                    s.Spec.Components.Add(c);
                }
            }


            return(result);
        }