Example #1
0
 public XYZMeshedColumnPlotData(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
 {
     _matrixProxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns)
     {
         ParentObject = this
     };
     SetXBoundsFromTemplate(new FiniteNumericalBoundaries());
     SetYBoundsFromTemplate(new FiniteNumericalBoundaries());
     SetVBoundsFromTemplate(new FiniteNumericalBoundaries());
 }
Example #2
0
        /// <summary>
        /// Shows the dialog in which the user can select options for the 2D Fourier transformation, and then executes the Fourier transformation
        /// The result is stored in a newly created data table in the same folder as the source data table.
        /// </summary>
        /// <param name="table">The table containing the data to transform.</param>
        /// <param name="selectedDataRows">The selected data rows of the table. (A value of <c>null</c> can be provided here).</param>
        /// <param name="selectedDataColumns">The selected data columns of the table. (A value of <c>null</c> can be provided here).</param>
        /// <param name="selectedPropertyColumns">The selected property columns of the table. (A value of <c>null</c> can be provided here).</param>
        public static void ShowRealFourierTransformation2DDialog(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
        {
            DataTableMatrixProxy proxy = null;
            RealFourierTransformation2DOptions options = null;

            try
            {
                proxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns);

                options = null != _lastUsedOptions ? (RealFourierTransformation2DOptions)_lastUsedOptions.Clone() : new RealFourierTransformation2DOptions();
                proxy.TryGetRowHeaderIncrement(out var rowIncrementValue, out var rowIncrementMessage);
                proxy.TryGetColumnHeaderIncrement(out var columnIncrementValue, out var columnIncrementMessage);

                options.IsUserDefinedRowIncrementValue = false;
                options.RowIncrementValue   = rowIncrementValue;
                options.RowIncrementMessage = rowIncrementMessage;

                options.IsUserDefinedColumnIncrementValue = false;
                options.ColumnIncrementValue   = columnIncrementValue;
                options.ColumnIncrementMessage = columnIncrementMessage;
            }
            catch (Exception ex)
            {
                Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in preparation of Fourier transformation");
                return;
            }

            if (!Current.Gui.ShowDialog(ref options, "Choose fourier transform options", false))
            {
                return;
            }

            _lastUsedOptions = options;

            try
            {
                var resultTable = new DataTable {
                    Name = string.Format("{0}Fourier{1} of {2}", table.Folder, options.OutputKind, table.ShortName)
                };
                ExecuteFouriertransformation2D(proxy, options, resultTable);

                // Create a DataSource
                var dataSource = new FourierTransformation2DDataSource(proxy, options, new Altaxo.Data.DataSourceImportOptions());
                resultTable.DataSource = dataSource;

                Current.ProjectService.OpenOrCreateWorksheetForTable(resultTable);
            }
            catch (Exception ex)
            {
                Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in execution of Fourier transformation");
                return;
            }
        }
Example #3
0
		/// <summary>
		/// Shows the dialog in which the user can select options for the 2D Fourier transformation, and then executes the Fourier transformation
		/// The result is stored in a newly created data table in the same folder as the source data table.
		/// </summary>
		/// <param name="table">The table containing the data to transform.</param>
		/// <param name="selectedDataRows">The selected data rows of the table. (A value of <c>null</c> can be provided here).</param>
		/// <param name="selectedDataColumns">The selected data columns of the table. (A value of <c>null</c> can be provided here).</param>
		/// <param name="selectedPropertyColumns">The selected property columns of the table. (A value of <c>null</c> can be provided here).</param>
		public static void ShowRealFourierTransformation2DDialog(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
		{
			DataTableMatrixProxy proxy = null;
			RealFourierTransformation2DOptions options = null;

			try
			{
				proxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns);

				options = null != _lastUsedOptions ? (RealFourierTransformation2DOptions)_lastUsedOptions.Clone() : new RealFourierTransformation2DOptions();

				double rowIncrementValue; string rowIncrementMessage;
				proxy.TryGetRowHeaderIncrement(out rowIncrementValue, out rowIncrementMessage);
				double columnIncrementValue; string columnIncrementMessage;
				proxy.TryGetColumnHeaderIncrement(out columnIncrementValue, out columnIncrementMessage);

				options.IsUserDefinedRowIncrementValue = false;
				options.RowIncrementValue = rowIncrementValue;
				options.RowIncrementMessage = rowIncrementMessage;

				options.IsUserDefinedColumnIncrementValue = false;
				options.ColumnIncrementValue = columnIncrementValue;
				options.ColumnIncrementMessage = columnIncrementMessage;
			}
			catch (Exception ex)
			{
				Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in preparation of Fourier transformation");
				return;
			}

			if (!Current.Gui.ShowDialog(ref options, "Choose fourier transform options", false))
				return;

			_lastUsedOptions = options;

			try
			{
				var resultTable = new DataTable { Name = string.Format("{0}Fourier{1} of {2}", table.Folder, options.OutputKind, table.ShortName) };
				ExecuteFouriertransformation2D(proxy, options, resultTable);

				// Create a DataSource
				Altaxo.Worksheet.Commands.Analysis.FourierTransformation2DDataSource dataSource = new FourierTransformation2DDataSource(proxy, options, new Altaxo.Data.DataSourceImportOptions());
				resultTable.DataSource = dataSource;

				Current.ProjectService.OpenOrCreateWorksheetForTable(resultTable);
			}
			catch (Exception ex)
			{
				Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in execution of Fourier transformation");
				return;
			}
		}
        protected override IEnumerable <Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName()
        {
            if (null != _inputData)
            {
                yield return(new Main.DocumentNodeAndName(_inputData, () => _inputData = null, "Data"));
            }

            if (null != _transformationOptions)
            {
                yield return(new Main.DocumentNodeAndName(_transformationOptions, () => _transformationOptions = null, "TransformationOptions"));
            }

            if (null != _importOptions)
            {
                yield return(new Main.DocumentNodeAndName(_importOptions, () => _importOptions = null, "ImportOptions"));
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FourierTransformation2DDataSource"/> class.
        /// </summary>
        /// <param name="inputData">The input data designates the original source of data (used then for the Fourier transformation).</param>
        /// <param name="transformationOptions">The Fourier transformation options.</param>
        /// <param name="importOptions">The data source import options.</param>
        /// <exception cref="System.ArgumentNullException">
        /// inputData
        /// or
        /// transformationOptions
        /// or
        /// importOptions
        /// </exception>
        public FourierTransformation2DDataSource(DataTableMatrixProxy inputData, RealFourierTransformation2DOptions transformationOptions, IDataSourceImportOptions importOptions)
        {
            if (null == inputData)
            {
                throw new ArgumentNullException("inputData");
            }
            if (null == transformationOptions)
            {
                throw new ArgumentNullException("transformationOptions");
            }
            if (null == importOptions)
            {
                throw new ArgumentNullException("importOptions");
            }

            using (var token = SuspendGetToken())
            {
                FourierTransformation2DOptions = transformationOptions;
                ImportOptions = importOptions;
                InputData     = inputData;
            }
        }
Example #6
0
		public XYZMeshedColumnPlotData(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
		{
			_matrixProxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns) { ParentObject = this };
			this.SetXBoundsFromTemplate(new FiniteNumericalBoundaries());
			this.SetYBoundsFromTemplate(new FiniteNumericalBoundaries());
			this.SetVBoundsFromTemplate(new FiniteNumericalBoundaries());
		}
Example #7
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                bool bSurrogateUsed = false;

                XYZMeshedColumnPlotData s = null != o ? (XYZMeshedColumnPlotData)o : new XYZMeshedColumnPlotData();

                var surr = new XmlSerializationSurrogate0();

#pragma warning disable 618
                s._matrixProxy = DataTableMatrixProxy.CreateEmptyInstance(); // this instance is replaced later in the deserialization callback function and is intended to avoid null reference errors
#pragma warning restore 618

                object deserobj;
                deserobj = info.GetValue("XColumn", s);
                if (deserobj is Main.AbsoluteDocumentPath)
                {
                    surr._xColumnPath = (Main.AbsoluteDocumentPath)deserobj;
                    bSurrogateUsed    = true;
                }
                else
                {
                    surr._xColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)deserobj);
                }

                deserobj = info.GetValue("YColumn", s);
                if (deserobj is Main.AbsoluteDocumentPath)
                {
                    surr._yColumnPath = (Main.AbsoluteDocumentPath)deserobj;
                    bSurrogateUsed    = true;
                }
                else
                {
                    surr._yColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)deserobj);
                }

                int count = info.OpenArray();
                surr._vColumnPaths   = new Main.AbsoluteDocumentPath[count];
                surr._vColumnProxies = new IReadableColumnProxy[count];
                for (int i = 0; i < count; i++)
                {
                    deserobj = info.GetValue("e", s);
                    if (deserobj is Main.AbsoluteDocumentPath)
                    {
                        surr._vColumnPaths[i] = (Main.AbsoluteDocumentPath)deserobj;
                        bSurrogateUsed        = true;
                    }
                    else
                    {
                        surr._vColumnProxies[i] = ReadableColumnProxyBase.FromColumn((Altaxo.Data.IReadableColumn)deserobj);
                    }
                }
                info.CloseArray(count);

                s._xBoundaries = (IPhysicalBoundaries)info.GetValue("XBoundaries", s);
                s._yBoundaries = (IPhysicalBoundaries)info.GetValue("YBoundaries", s);
                s._vBoundaries = (IPhysicalBoundaries)info.GetValue("VBoundaries", s);

                s._xBoundaries.ParentObject = s;
                s._yBoundaries.ParentObject = s;
                s._vBoundaries.ParentObject = s;

                if (bSurrogateUsed)
                {
                    surr._plotAssociation         = s;
                    info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);
                }

                return(s);
            }
		protected override IEnumerable<Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName()
		{
			if (null != _inputData)
				yield return new Main.DocumentNodeAndName(_inputData, () => _inputData = null, "Data");

			if (null != _transformationOptions)
				yield return new Main.DocumentNodeAndName(_transformationOptions, () => _transformationOptions = null, "TransformationOptions");

			if (null != _importOptions)
				yield return new Main.DocumentNodeAndName(_importOptions, () => _importOptions = null, "ImportOptions");
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="FourierTransformation2DDataSource"/> class.
		/// </summary>
		/// <param name="inputData">The input data designates the original source of data (used then for the Fourier transformation).</param>
		/// <param name="transformationOptions">The Fourier transformation options.</param>
		/// <param name="importOptions">The data source import options.</param>
		/// <exception cref="System.ArgumentNullException">
		/// inputData
		/// or
		/// transformationOptions
		/// or
		/// importOptions
		/// </exception>
		public FourierTransformation2DDataSource(DataTableMatrixProxy inputData, RealFourierTransformation2DOptions transformationOptions, IDataSourceImportOptions importOptions)
		{
			if (null == inputData)
				throw new ArgumentNullException("inputData");
			if (null == transformationOptions)
				throw new ArgumentNullException("transformationOptions");
			if (null == importOptions)
				throw new ArgumentNullException("importOptions");

			using (var token = SuspendGetToken())
			{
				this.FourierTransformation2DOptions = transformationOptions;
				this.ImportOptions = importOptions;
				this.InputData = inputData;
			}
		}
Example #10
0
        /// <summary>
        /// Executes a two dimensional Fourier transformation.
        /// </summary>
        /// <param name="matrixProxy">The proxy containing the matrix data that should be transformed, as well as the row header column and column header column that can be used to determine the spacing between adjacent rows and columns.</param>
        /// <param name="options">The options for the Fourier transformation.</param>
        /// <param name="destinationTable">The destination table that is used to store the Fourier transformed values.</param>
        /// <exception cref="System.NotImplementedException">Data pretreatment has an order which is not implemented yet.</exception>
        public static void ExecuteFouriertransformation2D(DataTableMatrixProxy matrixProxy, RealFourierTransformation2DOptions options, DataTable destinationTable)
        {
            // preparation step

            if (!options.IsUserDefinedRowIncrementValue)
            {
                matrixProxy.TryGetRowHeaderIncrement(out var rowIncrementValue, out var rowIncrementMessage);
                options.RowIncrementValue   = rowIncrementValue;
                options.RowIncrementMessage = rowIncrementMessage;
            }

            if (!options.IsUserDefinedColumnIncrementValue)
            {
                matrixProxy.TryGetColumnHeaderIncrement(out var columnIncrementValue, out var columnIncrementMessage);
                options.ColumnIncrementValue   = columnIncrementValue;
                options.ColumnIncrementMessage = columnIncrementMessage;
            }

            var matrix = matrixProxy.GetMatrix((r, c) => new Altaxo.Calc.LinearAlgebra.DoubleMatrixInArray1DRowMajorRepresentation(r, c));

            var fft = new Altaxo.Calc.Fourier.RealFourierTransformation2D(matrix, true)
            {
                ColumnSpacing = options.RowIncrementValue,
                RowSpacing    = options.ColumnIncrementValue
            };

            if (options.DataPretreatmentCorrectionOrder.HasValue)
            {
                switch (options.DataPretreatmentCorrectionOrder.Value)
                {
                case 0:
                    fft.DataPretreatment += RealFourierTransformation2D.RemoveZeroOrderFromMatrixIgnoringInvalidElements;
                    break;

                case 1:
                    fft.DataPretreatment += RealFourierTransformation2D.RemoveFirstOrderFromMatrixIgnoringInvalidElements;
                    break;

                case 2:
                    fft.DataPretreatment += RealFourierTransformation2D.RemoveSecondOrderFromMatrixIgnoringInvalidElements;
                    break;

                case 3:
                    fft.DataPretreatment += RealFourierTransformation2D.RemoveThirdOrderFromMatrixIgnoringInvalidElements;
                    break;

                default:
                    throw new NotImplementedException(string.Format("Regression of order {0} is not implemented yet", options.DataPretreatmentCorrectionOrder.Value));
                }
            }

            if (options.ReplacementValueForNaNMatrixElements.HasValue)
            {
                Altaxo.Calc.LinearAlgebra.MatrixMath.ReplaceNaNElementsWith(matrix, options.ReplacementValueForNaNMatrixElements.Value);
            }
            if (options.ReplacementValueForInfiniteMatrixElements.HasValue)
            {
                Altaxo.Calc.LinearAlgebra.MatrixMath.ReplaceNaNAndInfiniteElementsWith(matrix, options.ReplacementValueForInfiniteMatrixElements.Value);
            }

            if (options.FourierWindow != null)
            {
                fft.DataPretreatment += options.FourierWindow.Apply;
            }

            fft.Execute();

            IMatrix <double>   resultMatrix;
            IROVector <double> rowFrequencies;
            IROVector <double> columnFrequencies;

            if (options.CenterResult)
            {
                fft.GetResultCentered(options.ResultingFractionOfRowsUsed, options.ResultingFractionOfColumnsUsed, options.OutputKind, out resultMatrix, out rowFrequencies, out columnFrequencies);
            }
            else
            {
                fft.GetResult(options.ResultingFractionOfRowsUsed, options.ResultingFractionOfColumnsUsed, options.OutputKind, out resultMatrix, out rowFrequencies, out columnFrequencies);
            }

            var matTableConverter = new Altaxo.Data.MatrixToDataTableConverter(resultMatrix, destinationTable);

            if (options.OutputFrequencyHeaderColumns)
            {
                matTableConverter.AddMatrixRowHeaderData(rowFrequencies, string.IsNullOrEmpty(options.FrequencyRowHeaderColumnName) ? "RowFrequencies" : options.FrequencyRowHeaderColumnName);
                matTableConverter.AddMatrixColumnHeaderData(columnFrequencies, string.IsNullOrEmpty(options.FrequencyColumnHeaderColumnName) ? "ColumnFrequencies" : options.FrequencyColumnHeaderColumnName);
            }

            if (options.OutputPeriodHeaderColumns)
            {
                matTableConverter.AddMatrixRowHeaderData(VectorMath.ToInverseROVector(rowFrequencies), string.IsNullOrEmpty(options.PeriodRowHeaderColumnName) ? "RowPeriods" : options.PeriodRowHeaderColumnName);
                matTableConverter.AddMatrixColumnHeaderData(VectorMath.ToInverseROVector(columnFrequencies), string.IsNullOrEmpty(options.PeriodColumnHeaderColumnName) ? "ColumnPeriods" : options.PeriodColumnHeaderColumnName);
            }

            matTableConverter.Execute();
        }
Example #11
0
		/// <summary>
		/// Executes a two dimensional Fourier transformation.
		/// </summary>
		/// <param name="matrixProxy">The proxy containing the matrix data that should be transformed, as well as the row header column and column header column that can be used to determine the spacing between adjacent rows and columns.</param>
		/// <param name="options">The options for the Fourier transformation.</param>
		/// <param name="destinationTable">The destination table that is used to store the Fourier transformed values.</param>
		/// <exception cref="System.NotImplementedException">Data pretreatment has an order which is not implemented yet.</exception>
		public static void ExecuteFouriertransformation2D(DataTableMatrixProxy matrixProxy, RealFourierTransformation2DOptions options, DataTable destinationTable)
		{
			// preparation step

			if (!options.IsUserDefinedRowIncrementValue)
			{
				double rowIncrementValue; string rowIncrementMessage;
				matrixProxy.TryGetRowHeaderIncrement(out rowIncrementValue, out rowIncrementMessage);
				options.RowIncrementValue = rowIncrementValue;
				options.RowIncrementMessage = rowIncrementMessage;
			}

			if (!options.IsUserDefinedColumnIncrementValue)
			{
				double columnIncrementValue; string columnIncrementMessage;
				matrixProxy.TryGetColumnHeaderIncrement(out columnIncrementValue, out columnIncrementMessage);
				options.ColumnIncrementValue = columnIncrementValue;
				options.ColumnIncrementMessage = columnIncrementMessage;
			}

			var matrix = matrixProxy.GetMatrix((r, c) => new Altaxo.Calc.LinearAlgebra.DoubleMatrixInArray1DRowMajorRepresentation(r, c));

			var fft = new Altaxo.Calc.Fourier.RealFourierTransformation2D(matrix, true);
			fft.ColumnSpacing = options.RowIncrementValue;
			fft.RowSpacing = options.ColumnIncrementValue;

			if (options.DataPretreatmentCorrectionOrder.HasValue)
			{
				switch (options.DataPretreatmentCorrectionOrder.Value)
				{
					case 0:
						fft.DataPretreatment += RealFourierTransformation2D.RemoveZeroOrderFromMatrixIgnoringInvalidElements;
						break;

					case 1:
						fft.DataPretreatment += RealFourierTransformation2D.RemoveFirstOrderFromMatrixIgnoringInvalidElements;
						break;

					case 2:
						fft.DataPretreatment += RealFourierTransformation2D.RemoveSecondOrderFromMatrixIgnoringInvalidElements;
						break;

					case 3:
						fft.DataPretreatment += RealFourierTransformation2D.RemoveThirdOrderFromMatrixIgnoringInvalidElements;
						break;

					default:
						throw new NotImplementedException(string.Format("Regression of order {0} is not implemented yet", options.DataPretreatmentCorrectionOrder.Value));
				}
			}

			if (options.ReplacementValueForNaNMatrixElements.HasValue)
				Altaxo.Calc.LinearAlgebra.MatrixMath.ReplaceNaNElementsWith(matrix, options.ReplacementValueForNaNMatrixElements.Value);
			if (options.ReplacementValueForInfiniteMatrixElements.HasValue)
				Altaxo.Calc.LinearAlgebra.MatrixMath.ReplaceNaNAndInfiniteElementsWith(matrix, options.ReplacementValueForInfiniteMatrixElements.Value);

			if (options.FourierWindow != null)
			{
				fft.DataPretreatment += options.FourierWindow.Apply;
			}

			fft.Execute();

			IMatrix resultMatrix;
			IROVector rowFrequencies;
			IROVector columnFrequencies;

			if (options.CenterResult)
				fft.GetResultCentered(options.ResultingFractionOfRowsUsed, options.ResultingFractionOfColumnsUsed, options.OutputKind, out resultMatrix, out rowFrequencies, out columnFrequencies);
			else
				fft.GetResult(options.ResultingFractionOfRowsUsed, options.ResultingFractionOfColumnsUsed, options.OutputKind, out resultMatrix, out rowFrequencies, out columnFrequencies);

			var matTableConverter = new Altaxo.Data.MatrixToDataTableConverter(resultMatrix, destinationTable);

			if (options.OutputFrequencyHeaderColumns)
			{
				matTableConverter.AddMatrixRowHeaderData(rowFrequencies, string.IsNullOrEmpty(options.FrequencyRowHeaderColumnName) ? "RowFrequencies" : options.FrequencyRowHeaderColumnName);
				matTableConverter.AddMatrixColumnHeaderData(columnFrequencies, string.IsNullOrEmpty(options.FrequencyColumnHeaderColumnName) ? "ColumnFrequencies" : options.FrequencyColumnHeaderColumnName);
			}

			if (options.OutputPeriodHeaderColumns)
			{
				matTableConverter.AddMatrixRowHeaderData(VectorMath.Divide(1, rowFrequencies), string.IsNullOrEmpty(options.PeriodRowHeaderColumnName) ? "RowPeriods" : options.PeriodRowHeaderColumnName);
				matTableConverter.AddMatrixColumnHeaderData(VectorMath.Divide(1, columnFrequencies), string.IsNullOrEmpty(options.PeriodColumnHeaderColumnName) ? "ColumnPeriods" : options.PeriodColumnHeaderColumnName);
			}

			matTableConverter.Execute();
		}