public void RepresentDensityField3D() { ILScene scene = new ILScene(); currSurfPlotCube = new ILPlotCube(); currSurfPlotCube.TwoDMode = false; ILInArray <double> ilaDataMeshToShow = dmDensityMesh.ToArray(); ILInArray <double> ilaXvalues = dmDensityMeshXcoord.Row(0).ToArray(); ILInArray <double> ilaYvalues = dmDensityMeshYcoord.Column(0).ToArray(); ILSurface surf = new ILSurface(ilaDataMeshToShow, ilaXvalues, ilaYvalues); surf.UseLighting = true; surf.Colormap = Colormaps.ILNumerics; //surf.Children.Add(new ILColorbar()); currSurfPlotCube.Children.Add(surf); currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) * Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI); currSurfPlotCube.Projection = Projection.Perspective; scene.Add(currSurfPlotCube); ilPanel1.Scene = scene; }
/// <summary> /// Computes FFT for the given sampleset. /// </summary> /// <param name="Samples">Sampleset on which to compute a FFT</param> public FFT(List <double> Samples, List <BandFrequencyDefinition> CustomBands = null) { using (ILScope.Enter()) { ILInArray <double> inArr = Samples.ToArray(); ILRetArray <complex> output = ILMath.fft(inArr); rawFFTOutput = output.ToArray(); } ComputeFrequencyPowerSamples(); //FrequencyBands ComputeAbsoluteBandPower(BandFrequencyDefinition.Delta); ComputeAbsoluteBandPower(BandFrequencyDefinition.Theta); ComputeAbsoluteBandPower(BandFrequencyDefinition.Alpha); ComputeAbsoluteBandPower(BandFrequencyDefinition.Beta); ComputeAbsoluteBandPower(BandFrequencyDefinition.Gamma); if (CustomBands != null) { foreach (BandFrequencyDefinition customBand in CustomBands) { ComputeAbsoluteBandPower(customBand); } } }
public Field3Drepresentation(DenseMatrix dmDataToRepresent, Dictionary <string, object> properties, string description = "") { InitializeComponent(); strDataDescription = description; ThreadSafeOperations.SetText(lblDescription, strDataDescription, false); defaultProperties = properties; strOutputDirectory = (string)defaultProperties["DefaultDataFilesLocation"]; if (!ServiceTools.CheckIfDirectoryExists(strOutputDirectory)) { strOutputDirectory = ""; } dmData = dmDataToRepresent.Copy(); ILScene scene = new ILScene(); currSurfPlotCube = new ILPlotCube(); currSurfPlotCube.TwoDMode = false; ILSurface surf; ILInArray <double> ilaDataMeshToShow = dmData.ToArray(); if ((dmDataXcoord != null) && (dmDataYcoord != null)) { ILInArray <double> ilaXvalues = dmDataXcoord.Row(0).ToArray(); ILInArray <double> ilaYvalues = dmDataYcoord.Column(0).ToArray(); surf = new ILSurface(ilaDataMeshToShow, ilaXvalues, ilaYvalues); } else { surf = new ILSurface(ilaDataMeshToShow); } surf.UseLighting = true; surf.Colormap = Colormaps.ILNumerics; surf.Children.Add(new ILColorbar()); currSurfPlotCube.Children.Add(surf); currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) * Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI); currSurfPlotCube.Projection = Projection.Perspective; scene.Add(currSurfPlotCube); ilPanel1.Scene = scene; }
public void Update(ILInArray <double> A) { using (ILScope.Enter(A)) { var plot = ilPanel1.Scene.First <ILLinePlot>(tag: "mylineplot"); if (plot != null) { plot.Update(ILMath.tosingle(A)); plot.Configure(); ilPanel1.Refresh(); } } }
/// <summary> /// Example update function used for dynamic updates to the plot /// </summary> /// <param name="A">New data, matching the requirements of your plot</param> public void Update(ILInArray <double> A) { using (ILScope.Enter(A)) { // fetch a reference to the plot var plot = ilPanel1.Scene.First <ILLinePlot>(tag: "mylineplot"); if (plot != null) { // make sure, to convert elements to float plot.Update(ILMath.tosingle(A)); // // ... do more manipulations here ... // finished with updates? -> Call Configure() on the changes plot.Configure(); // cause immediate redraw of the scene ilPanel1.Refresh(); } } }
/// <summary> /// This methids creates a system array based on an ILNumerics array. /// </summary> /// <typeparam name="T">The type of the objects stored in the array.</typeparam> /// <param name="A">The ILNumerics array.</param> /// <returns>Returns the newly created system array contain the values of the ILNumerics array.</returns> private static System.Array toSystemMatrix <T>(ILInArray <T> A) { using (ILScope.Enter(A)) { // some error checking (to be improved...) if (object.Equals(A, null)) { throw new ArgumentException("A may not be null"); } if (!A.IsMatrix) { throw new ArgumentException("Matrix expected"); } // create return array System.Array ret = Array.CreateInstance(typeof(T), A.S.ToIntArray().Reverse().ToArray()); // fetch underlying system array T[] workArr = A.GetArrayForRead(); // copy memory block Buffer.BlockCopy(workArr, 0, ret, 0, Marshal.SizeOf(typeof(T)) * A.S.NumberOfElements); return(ret); } }
private void RepresentData() { ThreadSafeOperations.SetText(lblFileName, dataFileName, false); ILInArray <double> dataValues = dmDataToShow.ToArray(); ILScene scene = new ILScene(); ILPlotCube currSurfPlotCube = new ILPlotCube(); currSurfPlotCube.TwoDMode = false; ILSurface surf = new ILSurface(dataValues); surf.UseLighting = true; surf.Colormap = Colormaps.Jet; surf.Children.Add(new ILColorbar()); currSurfPlotCube.Children.Add(surf); currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) * Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI); currSurfPlotCube.Projection = Projection.Perspective; scene.Add(currSurfPlotCube); //scene.First<ILSurface>().MouseClick += (s, arg) => //{ // // we start at the mouse event target -> this will be the // // surface group node (the parent of "Fill" and "Wireframe") // var group = arg.Target.Parent; // if (group != null) // { // // walk up to the next camera node // Matrix4 trans = group.Transform; // while (!(group is ILCamera) && group != null) // { // group = group.Parent; // // collect all nodes on the path up // trans = group.Transform * trans; // } // if (group != null && (group is ILCamera)) // { // // convert args.LocationF to world coords // // The Z coord is not provided by the mouse! -> choose arbitrary value // var pos = new Vector3(arg.LocationF.X * 2 - 1, arg.LocationF.Y * -2 + 1, 0); // // invert the matrix. // trans = Matrix4.Invert(trans); // // trans now converts from the world coord system (at the camera) to // // the local coord system in the 'target' group node (surface). // // In order to transform the mouse (viewport) position, we // // left multiply the transformation matrix. // pos = trans * pos; // // view result in the window title // //Text = "Model Position: " + pos.ToString(); // ThreadSafeOperations.SetText(lblStatus, pos.ToString(), false); // } // } //}; ilPanel1.Scene = scene; }
public Field4Drepresentation( DenseMatrix dmListOfData, Dictionary <string, object> properties, Dictionary <string, int> valuesColumnsIndeces = null, SlicingVariable varSliceBy = SlicingVariable.z, string description = "") { InitializeComponent(); variableSliceBy = varSliceBy; if (valuesColumnsIndeces == null) { valuesColumnsIndeces = new Dictionary <string, int>(); valuesColumnsIndeces.Add("x", 0); valuesColumnsIndeces.Add("y", 1); valuesColumnsIndeces.Add("z", 2); valuesColumnsIndeces.Add("values", 3); } strDataDescription = description; ThreadSafeOperations.SetText(lblDescription, strDataDescription, false); defaultProperties = properties; strOutputDirectory = (string)defaultProperties["DefaultDataFilesLocation"]; if (!ServiceTools.CheckIfDirectoryExists(strOutputDirectory)) { strOutputDirectory = ""; } dmDataList = dmListOfData.Copy(); double dataMaxVal = dmDataList.Column(3).Max(); double dataMinVal = dmDataList.Column(3).Min(); ILScene scene = new ILScene(); currSurfPlotCube = new ILPlotCube(); currSurfPlotCube.TwoDMode = false; List <List <DenseMatrix> > lDataMatricesForSurfices = ReshapeDataToMatrices(dmDataList, variableSliceBy); foreach (List <DenseMatrix> currSurfMatricesList in lDataMatricesForSurfices) { ILInArray <double> ilaXvalues = currSurfMatricesList[0].ToArray(); ILInArray <double> ilaYvalues = currSurfMatricesList[1].ToArray(); ILInArray <double> ilaZvalues = currSurfMatricesList[2].ToArray(); MathNet.Numerics.LinearAlgebra.Single.DenseMatrix floatDMcolors = MathNet.Numerics.LinearAlgebra.Single.DenseMatrix.Create(currSurfMatricesList[0].RowCount, currSurfMatricesList[0].ColumnCount, 0.0f); currSurfMatricesList[3].MapConvert <Single>(dval => Convert.ToSingle(dval), floatDMcolors, MathNet.Numerics.LinearAlgebra.Zeros.Include); ILInArray <float> ilaForColorValues = floatDMcolors.ToArray(); ILSurface currSurf = new ILSurface(ilaZvalues, ilaXvalues, ilaYvalues); currSurf.ColorMode = ILSurface.ColorModes.RBGA; ColorScheme newCS = new ColorScheme(""); //ColorSchemeRuler newCSR = new ColorSchemeRuler(newCS, dataMinVal, dataMaxVal); double[,] dmRvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal); return(currColor.Red / 255.0d); }).ToArray(); double[,] dmGvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal); return(currColor.Green / 255.0d); }).ToArray(); double[,] dmBvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal); return(currColor.Blue / 255.0d); }).ToArray(); float[, ,] rgbaArrData = new float[4, dmRvalues.GetLength(0), dmRvalues.GetLength(1)]; for (int i = 0; i < dmRvalues.GetLength(0); i++) { for (int j = 0; j < dmRvalues.GetLength(1); j++) { rgbaArrData[0, i, j] = Convert.ToSingle(dmRvalues[i, j]); rgbaArrData[1, i, j] = Convert.ToSingle(dmGvalues[i, j]); rgbaArrData[2, i, j] = Convert.ToSingle(dmBvalues[i, j]); rgbaArrData[3, i, j] = 0.3f; } } currSurf.UpdateRGBA(null, rgbaArrData); currSurf.UseLighting = true; currSurfPlotCube.Children.Add(currSurf); //if (currSurfPlotCube.Children.Count() > 4) //{ // currSurfPlotCube.Children.Add(new ILColorbar()); //} //if (currSurfPlotCube.Children.Count() > 4) //{ // break; //} } // surf.Children.Add(new ILColorbar()); //currSurfPlotCube.Children.Add(new ILColorbar()); //currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) * // Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI); currSurfPlotCube.Projection = Projection.Orthographic; currSurfPlotCube.Plots.Reset(); scene.Add(currSurfPlotCube); ilPanel1.Scene = scene; }
private void GraphForm_Load(object sender, EventArgs e) { ILInArray<double> GraphData = CrossCorrExpMatrixReShiftedILN; //Here I use GraphData to plot the surface }
public GraphForm(ILInArray<double> pCrossCorrExpMatrixReShiftedILN) { InitializeComponent(); CrossCorrExpMatrixReShiftedILN = pCrossCorrExpMatrixReShiftedILN; }