当前位置: 首页>>代码示例>>C#>>正文


C# DataTable.GetTableProperty方法代码示例

本文整理汇总了C#中Altaxo.Data.DataTable.GetTableProperty方法的典型用法代码示例。如果您正苦于以下问题:C# DataTable.GetTableProperty方法的具体用法?C# DataTable.GetTableProperty怎么用?C# DataTable.GetTableProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Altaxo.Data.DataTable的用法示例。


在下文中一共展示了DataTable.GetTableProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAnalysis

    public  static WorksheetAnalysis GetAnalysis(DataTable table)
    {
      MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

      if(plsMemo==null)
        throw new ArgumentException("Table does not contain a PLSContentMemento");
  
      return plsMemo.Analysis;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:ChemometricCommands.cs

示例2: GetContentAsMultivariateContentMemento

		public static MultivariateContentMemento GetContentAsMultivariateContentMemento(DataTable table)
		{
			var result = table.GetTableProperty("Content") as MultivariateContentMemento;
			return result;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:5,代码来源:WorksheetAnalysis.cs

示例3: Export

		/// <summary>
		/// Exports a table to a PLS2CalibrationSet
		/// </summary>
		/// <param name="table">The table where the calibration model is stored.</param>
		/// <param name="calibrationSet"></param>
		public static void Export(
			DataTable table,
			out PCRCalibrationModel calibrationSet)
		{
			int numberOfX = GetNumberOfX(table);
			int numberOfY = GetNumberOfY(table);
			int numberOfFactors = GetNumberOfFactors(table);
			int numberOfMeasurements = GetNumberOfMeasurements(table);

			calibrationSet = new PCRCalibrationModel();

			calibrationSet.NumberOfX = numberOfX;
			calibrationSet.NumberOfY = numberOfY;
			calibrationSet.NumberOfFactors = numberOfFactors;
			MultivariatePreprocessingModel preprocessSet = new MultivariatePreprocessingModel();
			MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;
			if (plsMemo != null)
				preprocessSet.PreprocessOptions = plsMemo.SpectralPreprocessing;
			calibrationSet.SetPreprocessingModel(preprocessSet);

			Altaxo.Collections.AscendingIntegerCollection sel = new Altaxo.Collections.AscendingIntegerCollection();
			Altaxo.Data.DataColumn col;

			col = table.DataColumns.TryGetColumn(GetXOfX_ColumnName());
			if (col == null || !(col is INumericColumn)) NotFound(GetXOfX_ColumnName());
			preprocessSet.XOfX = Altaxo.Calc.LinearAlgebra.DataColumnWrapper.ToROVector((INumericColumn)col, numberOfX);

			col = table.DataColumns.TryGetColumn(GetXMean_ColumnName());
			if (col == null) NotFound(GetXMean_ColumnName());
			preprocessSet.XMean = Altaxo.Calc.LinearAlgebra.DataColumnWrapper.ToROVector(col, numberOfX);

			col = table.DataColumns.TryGetColumn(GetXScale_ColumnName());
			if (col == null) NotFound(GetXScale_ColumnName());
			preprocessSet.XScale = Altaxo.Calc.LinearAlgebra.DataColumnWrapper.ToROVector(col, numberOfX);

			sel.Clear();
			col = table.DataColumns.TryGetColumn(GetYMean_ColumnName());
			if (col == null) NotFound(GetYMean_ColumnName());
			sel.Add(table.DataColumns.GetColumnNumber(col));
			preprocessSet.YMean = DataColumnWrapper.ToROVector(col, numberOfY);

			sel.Clear();
			col = table.DataColumns.TryGetColumn(GetYScale_ColumnName());
			if (col == null) NotFound(GetYScale_ColumnName());
			sel.Add(table.DataColumns.GetColumnNumber(col));
			preprocessSet.YScale = DataColumnWrapper.ToROVector(col, numberOfY);

			sel.Clear();
			for (int i = 0; i < numberOfFactors; i++)
			{
				string colname = GetXScore_ColumnName(i);
				col = table.DataColumns.TryGetColumn(colname);
				if (col == null) NotFound(colname);
				sel.Add(table.DataColumns.GetColumnNumber(col));
			}
			calibrationSet.XScores = DataTableWrapper.ToROColumnMatrix(table.DataColumns, sel, numberOfMeasurements);

			sel.Clear();
			for (int i = 0; i < numberOfFactors; i++)
			{
				string colname = GetXLoad_ColumnName(i);
				col = table.DataColumns.TryGetColumn(colname);
				if (col == null) NotFound(colname);
				sel.Add(table.DataColumns.GetColumnNumber(col));
			}
			calibrationSet.XLoads = DataTableWrapper.ToRORowMatrix(table.DataColumns, sel, numberOfX);

			sel.Clear();
			for (int i = 0; i < numberOfY; i++)
			{
				string colname = GetYLoad_ColumnName(i);
				col = table.DataColumns.TryGetColumn(colname);
				if (col == null) NotFound(colname);
				sel.Add(table.DataColumns.GetColumnNumber(col));
			}
			calibrationSet.YLoads = DataTableWrapper.ToROColumnMatrix(table.DataColumns, sel, numberOfMeasurements);

			sel.Clear();
			col = table.DataColumns.TryGetColumn(GetCrossProduct_ColumnName());
			if (col == null) NotFound(GetCrossProduct_ColumnName());
			calibrationSet.CrossProduct = Altaxo.Calc.LinearAlgebra.DataColumnWrapper.ToROVector(col, numberOfFactors);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:87,代码来源:PCRWorksheetAnalysis.cs

示例4: CalculateXLeverage

    /// <summary>
    /// Calculates the leverage of the spectral data.
    /// </summary>
    /// <param name="table">Table where the calibration model is stored.</param>
    /// <param name="numberOfFactors">Number of factors used to calculate leverage.</param>
    public virtual void CalculateXLeverage(
      DataTable table, int numberOfFactors)
    {
      MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

      if(plsMemo==null)
        throw new ArgumentException("Table does not contain a PLSContentMemento");

      IMultivariateCalibrationModel calib = this.GetCalibrationModel(table);
      IMatrix matrixX = GetRawSpectra(plsMemo);

      MultivariateRegression.PreprocessSpectraForPrediction(calib,plsMemo.SpectralPreprocessing,matrixX);

      MultivariateRegression regress = this.CreateNewRegressionObject();
      regress.SetCalibrationModel(calib);

      IROMatrix xLeverage = regress.GetXLeverageFromRaw(matrixX,numberOfFactors);

      for(int i=0;i<xLeverage.Columns;i++)
      {
        Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
        MatrixMath.SetColumn(xLeverage,i,DataColumnWrapper.ToVertMatrix(col,xLeverage.Rows),0);
        table.DataColumns.Add(
          col,
          xLeverage.Columns==1 ? GetXLeverage_ColumnName(numberOfFactors) : GetXLeverage_ColumnName(i,numberOfFactors),
          Altaxo.Data.ColumnKind.V,GetXLeverage_ColumnGroup());
      }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:33,代码来源:WorksheetAnalysis.cs

示例5: PredictValues

    /// <summary>
    /// This predicts the selected columns/rows against a user choosen calibration model.
    /// The orientation of spectra is given by the parameter <c>spectrumIsRow</c>.
    /// </summary>
    /// <param name="srctable">Table holding the specta to predict values for.</param>
    /// <param name="selectedColumns">Columns selected in the source table.</param>
    /// <param name="selectedRows">Rows selected in the source table.</param>
    /// <param name="destTable">The table to store the prediction result.</param>
    /// <param name="modelTable">The table where the calibration model is stored.</param>
    /// <param name="numberOfFactors">Number of factors used to predict the values.</param>
    /// <param name="spectrumIsRow">If true, the spectra is horizontally oriented, else it is vertically oriented.</param>
    public virtual void PredictValues(
      DataTable srctable,
      IAscendingIntegerCollection selectedColumns,
      IAscendingIntegerCollection selectedRows,
      bool spectrumIsRow,
      int numberOfFactors,
      DataTable modelTable,
      DataTable destTable)
    {

      IMultivariateCalibrationModel calibModel = GetCalibrationModel(modelTable);
      //      Export(modelTable, out calibModel);
      MultivariateContentMemento memento = modelTable.GetTableProperty("Content") as MultivariateContentMemento;

      // Fill matrixX with spectra
      Altaxo.Collections.AscendingIntegerCollection spectralIndices;
      Altaxo.Collections.AscendingIntegerCollection measurementIndices;
      
      
      spectralIndices = new Altaxo.Collections.AscendingIntegerCollection(selectedColumns);
      measurementIndices = new Altaxo.Collections.AscendingIntegerCollection(selectedRows);
      RemoveNonNumericCells(srctable,measurementIndices,spectralIndices);

      // exchange selection if spectrum is column
      if(!spectrumIsRow)
      {
        Altaxo.Collections.AscendingIntegerCollection hlp;
        hlp = spectralIndices;
        spectralIndices = measurementIndices;
        measurementIndices = hlp;
      }
      
      // if there are more data than expected, we have to map the spectral indices
      if(spectralIndices.Count>calibModel.NumberOfX)
      {
        double[] xofx = GetXOfSpectra(srctable,spectrumIsRow,spectralIndices,measurementIndices);

        string errormsg;
        AscendingIntegerCollection map = MapSpectralX(calibModel.PreprocessingModel.XOfX,VectorMath.ToROVector(xofx),out errormsg);
        if(map==null)
          throw new ApplicationException("Can not map spectral data: " + errormsg);
        else
        {
          AscendingIntegerCollection newspectralindices = new AscendingIntegerCollection();
          for(int i=0;i<map.Count;i++)
            newspectralindices.Add(spectralIndices[map[i]]);
          spectralIndices = newspectralindices;
        }
      }

      IMatrix matrixX = GetRawSpectra(srctable,spectrumIsRow,spectralIndices,measurementIndices);

      MatrixMath.BEMatrix predictedY = new MatrixMath.BEMatrix(measurementIndices.Count,calibModel.NumberOfY);
      CalculatePredictedY(calibModel,memento.SpectralPreprocessing,matrixX,numberOfFactors, predictedY,null);

      // now save the predicted y in the destination table

      Altaxo.Data.DoubleColumn labelCol = new Altaxo.Data.DoubleColumn();
      for(int i=0;i<measurementIndices.Count;i++)
      {
        labelCol[i] = measurementIndices[i];
      }
      destTable.DataColumns.Add(labelCol,"MeasurementLabel",Altaxo.Data.ColumnKind.Label,0);

      for(int k=0;k<predictedY.Columns;k++)
      {
        Altaxo.Data.DoubleColumn predictedYcol = new Altaxo.Data.DoubleColumn();

        for(int i=0;i<measurementIndices.Count;i++)
        {
          predictedYcol[i] = predictedY[i,k];
        }
        destTable.DataColumns.Add(predictedYcol,"Predicted Y" + k.ToString(), Altaxo.Data.ColumnKind.V,0);
      }

      
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:88,代码来源:WorksheetAnalysis.cs

示例6: CalculatePredictedAndResidual

    public  virtual void CalculatePredictedAndResidual(
      DataTable table,
      int whichY,
      int numberOfFactors,
      bool saveYPredicted,
      bool saveYResidual,
      bool saveXResidual)
    {
      MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

      if(plsMemo==null)
        throw new ArgumentException("Table does not contain a PLSContentMemento");

      IMultivariateCalibrationModel calib = GetCalibrationModel(table);
      //      Export(table,out calib);


      IMatrix matrixX = GetRawSpectra(plsMemo);

      MatrixMath.BEMatrix predictedY = new MatrixMath.BEMatrix(matrixX.Rows,calib.NumberOfY);
      MatrixMath.BEMatrix spectralResiduals = new MatrixMath.BEMatrix(matrixX.Rows,1);
      CalculatePredictedY(calib,plsMemo.SpectralPreprocessing,matrixX,numberOfFactors,predictedY,spectralResiduals);

      if(saveYPredicted)
      {
        // insert a column with the proper name into the table and fill it
        string ycolname = GetYPredicted_ColumnName(whichY,numberOfFactors);
        Altaxo.Data.DoubleColumn ycolumn = new Altaxo.Data.DoubleColumn();

        for(int i=0;i<predictedY.Rows;i++)
          ycolumn[i] = predictedY[i,whichY];
      
        table.DataColumns.Add(ycolumn,ycolname,Altaxo.Data.ColumnKind.V,GetYPredicted_ColumnGroup());
      }

      // subract the original y data
      IMatrix matrixY = GetOriginalY(plsMemo);
      MatrixMath.SubtractColumn(predictedY,matrixY,whichY,predictedY);

      if(saveYResidual)
      {
        // insert a column with the proper name into the table and fill it
        string ycolname = GetYResidual_ColumnName(whichY,numberOfFactors);
        Altaxo.Data.DoubleColumn ycolumn = new Altaxo.Data.DoubleColumn();

        for(int i=0;i<predictedY.Rows;i++)
          ycolumn[i] = predictedY[i,whichY];
      
        table.DataColumns.Add(ycolumn,ycolname,Altaxo.Data.ColumnKind.V,GetYResidual_ColumnGroup());
      }


      if(saveXResidual)
      {
        // insert a column with the proper name into the table and fill it
        string ycolname = GetXResidual_ColumnName(whichY,numberOfFactors);
        Altaxo.Data.DoubleColumn ycolumn = new Altaxo.Data.DoubleColumn();

        for(int i=0;i<matrixX.Rows;i++)
        {
          ycolumn[i] = spectralResiduals[i,0];
        }
        table.DataColumns.Add(ycolumn,ycolname,Altaxo.Data.ColumnKind.V,GetXResidual_ColumnGroup());
      }
      
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:66,代码来源:WorksheetAnalysis.cs


注:本文中的Altaxo.Data.DataTable.GetTableProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。