﻿<?xml version="1.0" encoding="utf-8"?><file><version>2026.1.2.8</version><rootType typeID="VirtualLabAPI.Core.Modules.SnippetCodeWithParameter, VirtualLabAPI, Version=2026.1.2.8, Culture=neutral, PublicKeyToken=null" Referent="0"><SnippetCodeWithParameter._snippetCode>		List&lt;DetectorResultObject&gt; detectorResults = new List&lt;DetectorResultObject&gt;();␍
␍
␍
		if (WavefrontData == null) {␍
			throw new ArgumentException("No wavefront data given.");␍
		}␍
		if (WavefrontData.Count != 1) {␍
			throw new ArgumentException("Only single input field supported.");␍
		}␍
␍
		DataArrayGridLess daGridlessWavefrontData = WavefrontData[0] as DataArrayGridLess;␍
␍
		if (daGridlessWavefrontData == null) {␍
			throw new ArgumentException("Only gridless input data supported.");␍
		}␍
␍
		//calculate radial wavefront information␍
		DataArray1D daRadialWavefrontInformation = calculateRadialWavefrontData(daGridlessWavefrontData);␍
␍
		// sample detector output for documents␍
		detectorResults.Add(VL_Detectors.CreateDetectorResult(daRadialWavefrontInformation, "Radial Wavefront Information"));␍
␍
		return detectorResults;␍
</SnippetCodeWithParameter._snippetCode><SnippetCodeWithParameter._snippetCodeBody>␍
	/// &lt;summary&gt;␍
	/// Defines how the view settings shall be changed after the resulting document windows ␍
	/// are shown.␍
	/// &lt;/summary&gt;␍
	/// &lt;param name="formDocument"&gt;The document window for which the view settings are adapted.&lt;/param&gt;␍
	public static void ChangeViewSettingsAfterShow(FormDocument formDocument) {␍
	}␍
␍
␍
	//support method to initialize the cache of the snippet␍
	private DataArray1D calculateRadialWavefrontData(DataArrayGridLess inputWavefrontData) {␍
␍
		//Globals.DataDisplay.LogMessage("init");␍
		//generate list of positions and phase values for interpolation␍
		List&lt;VectorD&gt; listPositionsForInterpolation = new List&lt;VectorD&gt;();␍
		List&lt;double&gt; listPhaseValuesForInterpolation = new List&lt;double&gt;();␍
␍
␍
		double minX = double.MaxValue;␍
		double minY = double.MaxValue;␍
		double maxX = double.MinValue;␍
		double maxY = double.MinValue;␍
␍
␍
		//get current value␍
		double currValue_0 = inputWavefrontData.Data[0][0].Re;␍
␍
		//loop over all point of the input wavefront data to compensate␍
		for (int runPoints = 0; runPoints &lt; inputWavefrontData.NoOfDataPoints; runPoints++) {␍
			//get position␍
			VectorD currPosition = new VectorD(inputWavefrontData.Coordinates[0, runPoints].Re,␍
											   inputWavefrontData.Coordinates[1, runPoints].Re);␍
			//get current value␍
			double currValue = inputWavefrontData.Data[0][runPoints].Re;␍
␍
			if (!double.IsNaN(currValue) &amp;&amp;␍
				!currPosition.IsUndefined) {␍
				listPositionsForInterpolation.Add(currPosition);␍
				listPhaseValuesForInterpolation.Add(currValue - currValue_0);␍
␍
				minX = Math.Min(minX, currPosition.X);␍
				minY = Math.Min(minY, currPosition.Y);␍
				maxX = Math.Max(maxX, currPosition.X);␍
				maxY = Math.Max(maxY, currPosition.Y);␍
			}␍
		}␍
␍
␍
␍
		//generate complex field to ␍
		ComplexField cfSplineInputParameter = new ComplexField(new Vector(listPositionsForInterpolation.Count, 3), false, PrecisionMode.Double);␍
		for (int runLists = 0; runLists &lt; listPositionsForInterpolation.Count; runLists++) {␍
			cfSplineInputParameter[runLists, 0] = listPositionsForInterpolation[runLists].X;␍
			cfSplineInputParameter[runLists, 1] = listPositionsForInterpolation[runLists].Y;␍
			cfSplineInputParameter[runLists, 2] = listPhaseValuesForInterpolation[runLists];␍
		}␍
		//generate spline interpolation object for initial input parameter␍
		SplineInterpolationGenerator splineGenerator = new SplineInterpolationGenerator(cfSplineInputParameter, Vector3D.UndefinedVector, 3, 3, false);␍
		SplineInterpolation splineInterpolationInputWavefront = splineGenerator.GenerateSplineInterpolationObject();␍
␍
		double samplingDistanceRadial = 100e-9;␍
		int numberPoints = (int)(maxX / samplingDistanceRadial);␍
		if (numberPoints % 2 == 0) {␍
			numberPoints++;␍
		}␍
␍
		CFieldDerivative1DReal cfRadialPhaseValue = new CFieldDerivative1DReal(numberPoints, double.NaN);␍
		CFieldDerivative1DReal cfRadialPhaseGradient = new CFieldDerivative1DReal(numberPoints, double.NaN);␍
␍
		//loop over all points␍
		for (int runPoints = 0; runPoints &lt; numberPoints; runPoints++) {␍
			//define radial position␍
			double currR = runPoints * samplingDistanceRadial;␍
			//evaluate phase			␍
			double evaluatedRadialPhaseValue = splineInterpolationInputWavefront.PointInterpolate(new VectorD(currR, 0));␍
			double evaluatedRadialPhaseGradient = splineInterpolationInputWavefront.PointInterpolationGradient(new VectorD(currR, 0)).X;␍
			//store values in data matrix␍
			cfRadialPhaseValue[runPoints] = evaluatedRadialPhaseValue;␍
			cfRadialPhaseGradient[runPoints] = evaluatedRadialPhaseGradient;␍
		}␍
␍
		//generate 1D data array ␍
		DataArray1D daRadialPhaseResponseInput = new DataArray1D(new ComplexField1DArray(new ComplexField[] { cfRadialPhaseValue, cfRadialPhaseGradient }),␍
																 new PhysicalProperty[] { PhysicalProperty.AngleRad, PhysicalProperty.NoUnit },␍
																 new string[] { "Interpolated Input Phase", "Interpolated Input Phase Gradient" },␍
																 samplingDistanceRadial,␍
																 0,␍
																 PhysicalProperty.Length,␍
																 "Radius");␍
␍
		return daRadialPhaseResponseInput;␍
␍
	}␍
</SnippetCodeWithParameter._snippetCodeBody><SnippetCodeWithParameter._variables typeID="System.Collections.Generic.List`1[[VirtualLabAPI.Core.Modules.GlobalParameterInternal, VirtualLabAPI, Version=2026.1.2.8, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">{}</SnippetCodeWithParameter._variables><SnippetCodeWithParameter._additionalUsings typeID="System.String[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"><entry typeID="System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"></entry></SnippetCodeWithParameter._additionalUsings><SnippetCodeWithParameter._externalReferenceDLLs typeID="System.Collections.IEnumerable, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">␀</SnippetCodeWithParameter._externalReferenceDLLs><SnippetCodeWithParameter._snippetHelp typeID="VirtualLabAPI.Core.Modules.SnippetHelpInformation, VirtualLabAPI, Version=2026.1.2.8, Culture=neutral, PublicKeyToken=null" Referent="1"><SnippetHelpInformation._title>Generate Radial Wavefront Phase Info</SnippetHelpInformation._title><SnippetHelpInformation._author></SnippetHelpInformation._author><SnippetHelpInformation._version></SnippetHelpInformation._version><SnippetHelpInformation._lastModified>4/7/2026 5:26:55 PM</SnippetHelpInformation._lastModified><SnippetHelpInformation._helpText></SnippetHelpInformation._helpText><SnippetHelpInformation._license typeID="VirtualLabAPI.Core.Modules.LicenseType, VirtualLabAPI, Version=2026.1.2.8, Culture=neutral, PublicKeyToken=null">Attribution␣1</SnippetHelpInformation._license><SnippetHelpInformation._userDefinedLicenseString></SnippetHelpInformation._userDefinedLicenseString><SnippetHelpInformation._textIsHTML>false</SnippetHelpInformation._textIsHTML><SnippetHelpInformation._image typeID="System.Drawing.Bitmap, System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">␀</SnippetHelpInformation._image><SnippetHelpInformation._imageScaleFactor>1</SnippetHelpInformation._imageScaleFactor></SnippetCodeWithParameter._snippetHelp></rootType></file>