public static BitmapSource ILArrayToBitmapSource(ILArray <double> surface) { // Define parameters used to create the BitmapSource. PixelFormat pf = PixelFormats.Bgr32; int width = surface.Dimensions[0]; int height = surface.Dimensions[1]; int bytes = (pf.BitsPerPixel + 7) / 8; int rawStride = (width * bytes); byte[] rawImage = new byte[rawStride * height]; int index = 0; ColourMap ColourMap = new ColourMap(ColourMapType.Jet, 256); byte[,] cmap = ColourMap.ToByteArray(); double range = surface.MaxValue - surface.MinValue; double min = surface.MinValue; int magnitude = 0; ILArray <int> scaled = (ILArray <int>)ILMath.convert(NumericType.Int32, ILMath.floor((surface - min) * 256.0 / range)); ILIterator <int> iterator = scaled.CreateIterator(); Stopwatch sw = Stopwatch.StartNew(); sw.Reset(); sw.Start(); magnitude = iterator.Value; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { if (magnitude == 256) { magnitude = 255; } rawImage[index] = cmap[magnitude, 3]; rawImage[index + 1] = cmap[magnitude, 2]; rawImage[index + 2] = cmap[magnitude, 1]; rawImage[index + 3] = cmap[magnitude, 0]; index += bytes; magnitude = iterator.Increment(); } } sw.Stop(); string result; result = "Elapsed time: " + sw.ElapsedMilliseconds.ToString() + " ms"; // Create a BitmapSource. BitmapSource bitmap = BitmapSource.Create(width, height, 96, 96, pf, null, rawImage, rawStride); return(bitmap); }
public static BitmapSource ILArrayToBitmapSourceReversed(ILArray <double> surface, ColourMap colourMap) { // Define parameters used to create the BitmapSource. PixelFormat pf = PixelFormats.Bgr32; int width = surface.Dimensions[0]; int height = surface.Dimensions[1]; int bytes = (pf.BitsPerPixel + 7) / 8; int rawStride = (width * bytes); byte[] rawImage = new byte[rawStride * height]; int index = 0; byte[,] cmap = colourMap.ToByteArray(); int colourMapLength = colourMap.Length; double range = surface.MaxValue - surface.MinValue; double min = surface.MinValue; int magnitude = 0; ILArray <int> scaled = (ILArray <int>)ILMath.convert(NumericType.Int32, ILMath.floor((surface - min) * (double)(colourMapLength - 1) / range)); ILIterator <int> iterator = scaled.CreateIterator(); magnitude = iterator.Value; for (int y = height - 1; y >= 0; --y) { index = y * rawStride; for (int x = 0; x < width; ++x) { rawImage[index] = cmap[magnitude, 3]; rawImage[index + 1] = cmap[magnitude, 2]; rawImage[index + 2] = cmap[magnitude, 1]; rawImage[index + 3] = cmap[magnitude, 0]; index += bytes; magnitude = iterator.Increment(); } } // Create a BitmapSource. BitmapSource bitmap = BitmapSource.Create(width, height, 96, 96, pf, null, rawImage, rawStride); return(bitmap); }
private void Wenner1D_Form_Load(object sender, EventArgs e) { try { DataTable table = new DataTable(); if (inforadio == 0) { table.Columns.AddRange(new DataColumn[] { new DataColumn("a (m)"), new DataColumn("Distance (m)"), new DataColumn("C1"), new DataColumn("C2"), new DataColumn("P1"), new DataColumn("P2"), new DataColumn("Z/n (m)"), new DataColumn("V (mV)"), new DataColumn("I (mA)"), new DataColumn("R (Ω)"), new DataColumn("K (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_a = new double[L]; double[] data_C1 = new double[L]; double[] data_C2 = new double[L]; double[] data_P1 = new double[L]; double[] data_P2 = new double[L]; double[] data_V = new double[L]; double[] data_I = new double[L]; double[] data_R = new double[L]; double[] data_K = new double[L]; double[] data_Rho = new double[L]; double[] data_dis = new double[L]; double[] data_n = new double[L]; double pi = 3.14; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_C1[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_C2[i] = Convert.ToDouble(MyDataColumns[selected[2]]); data_P1[i] = Convert.ToDouble(MyDataColumns[selected[3]]); data_P2[i] = Convert.ToDouble(MyDataColumns[selected[4]]); data_V[i] = Convert.ToDouble(MyDataColumns[selected[5]]); data_I[i] = Convert.ToDouble(MyDataColumns[selected[6]]); data_R[i] = data_V[i] / data_I[i]; data_K[i] = 2 * pi * data_a[i]; data_n[i] = data_P2[i] - data_P1[i]; data_Rho[i] = data_R[i] * data_K[i]; data_dis[i] = (data_C1[i] - poz - 1) * data_a[0] + data_a[i] + (data_a[i] / 2); object[] Data_Row = { data_a[i], data_dis[i], data_C1[i], data_C2[i], data_P1[i], data_P2[i], data_n[i], data_V[i], data_I[i],data_R[i], data_K[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_n; ILArray <double> dat_dis = data_dis; ILArray <double> dat_Rho = data_Rho; ILArray <float> ddis = ILMath.convert <double, float>(dat_dis); ILArray <float> drho = ILMath.convert <double, float>(dat_Rho); ILArray <float> position = ILMath.zeros <float>(3, data_dis.Length); position[0, ":"] = ddis[":"]; position[1, ":"] = drho[":"]; ilPanel1.Scene.Add(new ILPlotCube { Axes = { YAxis = { Label = { Text = "ρa (Ω.m)" } }, XAxis = { Label = { Text = "Distance (m)" } } }, Children = { new ILPoints { Positions = position, Size = 4 } } }); } if (inforadio == 1) { table.Columns.AddRange(new DataColumn[] { new DataColumn("a (m)"), new DataColumn("Distance (m)"), new DataColumn("C1"), new DataColumn("C2"), new DataColumn("P1"), new DataColumn("P2"), new DataColumn("Z/n (m)"), new DataColumn("R (Ω)"), new DataColumn("K (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_a = new double[L]; double[] data_C1 = new double[L]; double[] data_C2 = new double[L]; double[] data_P1 = new double[L]; double[] data_P2 = new double[L]; double[] data_R = new double[L]; double[] data_K = new double[L]; double[] data_Rho = new double[L]; double[] data_dis = new double[L]; double[] data_n = new double[L]; double pi = 3.14; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_C1[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_C2[i] = Convert.ToDouble(MyDataColumns[selected[2]]); data_P1[i] = Convert.ToDouble(MyDataColumns[selected[3]]); data_P2[i] = Convert.ToDouble(MyDataColumns[selected[4]]); data_R[i] = Convert.ToDouble(MyDataColumns[selected[5]]); data_K[i] = 2 * pi * data_a[i]; data_Rho[i] = data_R[i] * data_K[i]; data_n[i] = data_P2[i] - data_P1[i]; data_dis[i] = (data_C1[i] - poz - 1) * data_a[0] + data_a[i] + (data_a[i] / 2); object[] Data_Row = { data_a[i], data_dis[i], data_C1[i], data_C2[i], data_P1[i], data_P2[i], data_n[i], data_R[i], data_K[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_n; ILArray <double> dat_dis = data_dis; ILArray <double> dat_Rho = data_Rho; ILArray <float> ddis = ILMath.convert <double, float>(dat_dis); ILArray <float> drho = ILMath.convert <double, float>(dat_Rho); ILArray <float> position = ILMath.zeros <float>(3, data_dis.Length); position[0, ":"] = ddis[":"]; position[1, ":"] = drho[":"]; ilPanel1.Scene.Add(new ILPlotCube { Axes = { YAxis = { Label = { Text = "ρa (Ω.m)" } }, XAxis = { Label = { Text = "Distance (m)" } } }, Children = { new ILPoints { Positions = position, Size = 4 } } }); } if (inforadio == 2) { table.Columns.AddRange(new DataColumn[] { new DataColumn("Distance (m)"), new DataColumn("a (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_dis = new double[L]; double[] data_a = new double[L]; double[] data_Rho = new double[L]; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_dis[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_Rho[i] = Convert.ToDouble(MyDataColumns[selected[2]]); object[] Data_Row = { data_dis[i], data_a[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_a; ILArray <double> dat_dis = data_dis; ILArray <double> dat_Rho = data_Rho; ILArray <float> ddis = ILMath.convert <double, float>(dat_dis); ILArray <float> drho = ILMath.convert <double, float>(dat_Rho); ILArray <float> position = ILMath.zeros <float>(3, data_dis.Length); position[0, ":"] = ddis[":"]; position[1, ":"] = drho[":"]; ilPanel1.Scene.Add(new ILPlotCube { Axes = { YAxis = { Label = { Text = "ρa (Ω.m)" } }, XAxis = { Label = { Text = "Distance (m)" } } }, Children = { new ILPoints { Positions = position, Size = 4 } } }); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
private void PlotByIsolines( DenseMatrix dmListOfData, Dictionary <string, object> properties, string description = "") { 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> > llDataMatricesSlicedByZ = ReshapeDataToMatrices(dmDataList, SlicingVariable.z); DenseMatrix dmXvalues = llDataMatricesSlicedByZ[0][0].Copy(); DenseMatrix dmYvalues = llDataMatricesSlicedByZ[0][1].Copy(); List <List <DataValuesOver3DGrid> > lDataVectorsForSurfices = Group_DVOG_DataByValues(dmDataList); foreach (List <DataValuesOver3DGrid> currSurfVectorsList in lDataVectorsForSurfices) { //ILInArray<float> ilaXvalues = // currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.x)).ToArray(); //ILInArray<float> ilaYvalues = // currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.y)).ToArray(); //ILInArray<float> ilaZvalues = // currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.z)).ToArray(); //ILSurface currSurf = new ILSurface(ilaZvalues, ilaXvalues, ilaYvalues); // не катит - надо, чтобы сетка z была m*n, сетка x = m*[1|n], сетка y - [1|m]*n // поэтому просто список точек, которые должны составить поверхность, - не катят // => или отрисовывать множества точек, без привязки именно к понятию поверхности. Это пока не получилось // => или переформировать список точек так, чтобы они составили m*n поверхность // скомпоновать матрицу значений Z, соответствующих значениям x и y DenseMatrix dmZvalues = DenseMatrix.Create(dmXvalues.RowCount, dmXvalues.ColumnCount, (r, c) => { double x = dmXvalues[r, c]; double y = dmYvalues[r, c]; int idx = currSurfVectorsList.FindIndex(dvog => ((dvog.x == x) && (dvog.y == y))); if (idx == -1) // ничего нужного нет { return(double.NaN); } else { return(currSurfVectorsList[idx].z); } }); ILArray <double> arrXvalues = (ILArray <double>)(dmXvalues.ToArray()); ILArray <double> arrYvalues = (ILArray <double>)(dmYvalues.ToArray()); ILArray <double> arrZvalues = (ILArray <double>)(dmZvalues.ToArray()); // сформируем colors array ColorScheme newCS = new ColorScheme(""); DenseMatrix dmValues = DenseMatrix.Create(dmXvalues.RowCount, dmXvalues.ColumnCount, (r, c) => { double x = dmXvalues[r, c]; double y = dmYvalues[r, c]; int idx = currSurfVectorsList.FindIndex(dvog => ((dvog.x == x) && (dvog.y == y))); if (idx == -1) // ничего нужного нет { return(double.NaN); } else { return(currSurfVectorsList[idx].values[0]); } }); double[,] dmRvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(dmValues[r, c], dataMinVal, dataMaxVal); return(currColor.Red / 255.0d); }).ToArray(); double[,] dmGvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(dmValues[r, c], dataMinVal, dataMaxVal); return(currColor.Green / 255.0d); }).ToArray(); double[,] dmBvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount, (r, c) => { Bgr currColor = newCS.GetColorByValueAndRange(dmValues[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; } } ILSurface currSurf = new ILSurface(ILMath.convert <double, float>(arrZvalues), ILMath.convert <double, float>(arrXvalues), ILMath.convert <double, float>(arrYvalues), rgbaArrData); currSurf.UseLighting = true; currSurfPlotCube.Children.Add(currSurf); } currSurfPlotCube.Projection = Projection.Orthographic; currSurfPlotCube.Plots.Reset(); scene.Add(currSurfPlotCube); ilPanel1.Scene = scene; }
private void Wenner2D_Form_Load(object sender, EventArgs e) { try { DataTable table = new DataTable(); if (inforadio == 0) { table.Columns.AddRange(new DataColumn[] { new DataColumn("a (m)"), new DataColumn("Distance (m)"), new DataColumn("C1"), new DataColumn("C2"), new DataColumn("P1"), new DataColumn("P2"), new DataColumn("Z/n (m)"), new DataColumn("V (mV)"), new DataColumn("I (mA)"), new DataColumn("R (Ω)"), new DataColumn("K (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_a = new double[L]; double[] data_C1 = new double[L]; double[] data_C2 = new double[L]; double[] data_P1 = new double[L]; double[] data_P2 = new double[L]; double[] data_V = new double[L]; double[] data_I = new double[L]; double[] data_R = new double[L]; double[] data_K = new double[L]; double[] data_Rho = new double[L]; double[] data_dis = new double[L]; double[] data_n = new double[L]; double pi = 3.14; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_C1[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_C2[i] = Convert.ToDouble(MyDataColumns[selected[2]]); data_P1[i] = Convert.ToDouble(MyDataColumns[selected[3]]); data_P2[i] = Convert.ToDouble(MyDataColumns[selected[4]]); data_V[i] = Convert.ToDouble(MyDataColumns[selected[5]]); data_I[i] = Convert.ToDouble(MyDataColumns[selected[6]]); data_R[i] = data_V[i] / data_I[i]; data_K[i] = 2 * pi * data_a[i]; data_n[i] = data_P2[i] - data_P1[i]; data_Rho[i] = data_R[i] * data_K[i]; data_dis[i] = (data_C1[i] - poz - 1) * data_a[0] + data_a[i] + (data_a[i] / 2); object[] Data_Row = { data_a[i], data_dis[i], data_C1[i], data_C2[i], data_P1[i], data_P2[i], data_n[i], data_V[i], data_I[i],data_R[i], data_K[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_n; double[] X = data_dis; double[] Y = data_n; double[] Z = data_Rho; double minX = X.Min(); double maxX = X.Max(); double minY = Y.Min(); double maxY = Y.Max(); double intX = 1; double intY = 0.1; int LX = Convert.ToInt32((maxX - minX) / intX); int LY = Convert.ToInt32((maxY - minY) / intY); double[] intpX = new double[LX]; double[] intpY = new double[LY]; for (int i = 0; i < LX; i++) { if (i == 0) { intpX[i] = minX; } else { intpX[i] = intpX[i - 1] + intX; } } for (int i = 0; i < LY; i++) { if (i == 0) { intpY[i] = minY; } else { intpY[i] = intpY[i - 1] + intY; } } // IDW int nX = intpX.Length; int nY = intpY.Length; int N = nX * nY; double[] intpZ = new double[N]; double[] susX = new double[N]; double[] susY = new double[N]; for (int i = 0; i < nY; i++) { for (int j = 0; j < nX; j++) { susX[j + (nX * (i))] = intpX[j]; susY[j + (nX * (i))] = intpY[i]; } } double k = 2; for (int i = 0; i < N; i++) { double[] d_obs = new double[X.Length]; double[] d_ok = new double[X.Length]; double[] spd_ok = new double[X.Length]; double[] Zspd_ok = new double[X.Length]; double[] s_spd_ok = new double[X.Length]; double[] s_Zspd_ok = new double[X.Length]; for (int j = 0; j < X.Length; j++) { d_obs[j] = Math.Sqrt(Math.Pow(X[j] - susX[i], 2) + Math.Pow(Y[j] - susY[i], 2)); d_ok[j] = Math.Pow(d_obs[j], k); spd_ok[j] = 1 / (d_ok[j] + 0.00001); Zspd_ok[j] = Z[j] * spd_ok[j]; if (j == 0) { s_spd_ok[j] = spd_ok[j]; s_Zspd_ok[j] = Zspd_ok[j]; } else { s_spd_ok[j] = s_spd_ok[j - 1] + spd_ok[j]; s_Zspd_ok[j] = s_Zspd_ok[j - 1] + Zspd_ok[j]; } } intpZ[i] = s_Zspd_ok[X.Length - 1] / s_spd_ok[X.Length - 1]; } ILArray <double> ILintpZ = intpZ; ILArray <double> matrix = ILMath.zeros(nY, nX); for (int i = 0; i < nY; i++) { ILArray <int> rangeX = ILMath.vec <int>(0, nX - 1); ILArray <int> rangeZ = ILMath.vec <int>(0 + (nX) * (i), (nX * (i + 1) - 1)); matrix[i, rangeX] = ILintpZ[rangeZ]; } ILArray <float> matrixf = ILMath.convert <double, float>(matrix); ILArray <float> Xf = ILMath.convert <double, float>(intpX); ILArray <float> Yf = -1 * ILMath.convert <double, float>(intpY); ilPanel1.Scene.Add(new ILPlotCube { Axes = { XAxis = { Label = { Text = "Distance (m)" } }, YAxis = { Label = { Text = "n" } } }, Children = { new ILSurface(matrixf, Xf, Yf) { // make thin transparent wireframes Wireframe = { Color = Color.FromArgb(50,Color.LightGray) }, // choose a different colormap Colormap = new ILColormap(Colormaps.Jet), // add a colorbar (see below) Children = { new ILColorbar() } } } }); } if (inforadio == 1) { table.Columns.AddRange(new DataColumn[] { new DataColumn("a (m)"), new DataColumn("Distance (m)"), new DataColumn("C1"), new DataColumn("C2"), new DataColumn("P1"), new DataColumn("P2"), new DataColumn("Z/n (m)"), new DataColumn("R (Ω)"), new DataColumn("K (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_a = new double[L]; double[] data_C1 = new double[L]; double[] data_C2 = new double[L]; double[] data_P1 = new double[L]; double[] data_P2 = new double[L]; double[] data_R = new double[L]; double[] data_K = new double[L]; double[] data_Rho = new double[L]; double[] data_dis = new double[L]; double[] data_n = new double[L]; double pi = 3.14; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_C1[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_C2[i] = Convert.ToDouble(MyDataColumns[selected[2]]); data_P1[i] = Convert.ToDouble(MyDataColumns[selected[3]]); data_P2[i] = Convert.ToDouble(MyDataColumns[selected[4]]); data_R[i] = Convert.ToDouble(MyDataColumns[selected[5]]); data_K[i] = 2 * pi * data_a[i]; data_Rho[i] = data_R[i] * data_K[i]; data_n[i] = data_P2[i] - data_P1[i]; data_dis[i] = (data_C1[i] - poz - 1) * data_a[0] + data_a[i] + (data_a[i] / 2); object[] Data_Row = { data_a[i], data_dis[i], data_C1[i], data_C2[i], data_P1[i], data_P2[i], data_n[i], data_R[i], data_K[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_n; double[] X = data_dis; double[] Y = data_n; double[] Z = data_Rho; double minX = X.Min(); double maxX = X.Max(); double minY = Y.Min(); double maxY = Y.Max(); double intX = 1; double intY = 0.1; int LX = Convert.ToInt32((maxX - minX) / intX); int LY = Convert.ToInt32((maxY - minY) / intY); double[] intpX = new double[LX]; double[] intpY = new double[LY]; for (int i = 0; i < LX; i++) { if (i == 0) { intpX[i] = minX; } else { intpX[i] = intpX[i - 1] + intX; } } for (int i = 0; i < LY; i++) { if (i == 0) { intpY[i] = minY; } else { intpY[i] = intpY[i - 1] + intY; } } // IDW int nX = intpX.Length; int nY = intpY.Length; int N = nX * nY; double[] intpZ = new double[N]; double[] susX = new double[N]; double[] susY = new double[N]; for (int i = 0; i < nY; i++) { for (int j = 0; j < nX; j++) { susX[j + (nX * (i))] = intpX[j]; susY[j + (nX * (i))] = intpY[i]; } } double k = 2; for (int i = 0; i < N; i++) { double[] d_obs = new double[X.Length]; double[] d_ok = new double[X.Length]; double[] spd_ok = new double[X.Length]; double[] Zspd_ok = new double[X.Length]; double[] s_spd_ok = new double[X.Length]; double[] s_Zspd_ok = new double[X.Length]; for (int j = 0; j < X.Length; j++) { d_obs[j] = Math.Sqrt(Math.Pow(X[j] - susX[i], 2) + Math.Pow(Y[j] - susY[i], 2)); d_ok[j] = Math.Pow(d_obs[j], k); spd_ok[j] = 1 / (d_ok[j] + 0.00001); Zspd_ok[j] = Z[j] * spd_ok[j]; if (j == 0) { s_spd_ok[j] = spd_ok[j]; s_Zspd_ok[j] = Zspd_ok[j]; } else { s_spd_ok[j] = s_spd_ok[j - 1] + spd_ok[j]; s_Zspd_ok[j] = s_Zspd_ok[j - 1] + Zspd_ok[j]; } } intpZ[i] = s_Zspd_ok[X.Length - 1] / s_spd_ok[X.Length - 1]; } ILArray <double> ILintpZ = intpZ; ILArray <double> matrix = ILMath.zeros(nY, nX); for (int i = 0; i < nY; i++) { ILArray <int> rangeX = ILMath.vec <int>(0, nX - 1); ILArray <int> rangeZ = ILMath.vec <int>(0 + (nX) * (i), (nX * (i + 1) - 1)); matrix[i, rangeX] = ILintpZ[rangeZ]; } ILArray <float> matrixf = ILMath.convert <double, float>(matrix); ILArray <float> Xf = ILMath.convert <double, float>(intpX); ILArray <float> Yf = -1 * ILMath.convert <double, float>(intpY); ilPanel1.Scene.Add(new ILPlotCube { Axes = { XAxis = { Label = { Text = "Distance (m)" } }, YAxis = { Label = { Text = "n" } } }, Children = { new ILSurface(matrixf, Xf, Yf) { // make thin transparent wireframes Wireframe = { Color = Color.FromArgb(50,Color.LightGray) }, // choose a different colormap Colormap = new ILColormap(Colormaps.Jet), // add a colorbar (see below) Children = { new ILColorbar() } } } }); } if (inforadio == 2) { table.Columns.AddRange(new DataColumn[] { new DataColumn("Distance (m)"), new DataColumn("a (m)"), new DataColumn("ρa (Ω.m)") }); string[] MyDataLines = MyDataString.Split('\n'); L = MyDataLines.Length; double[] data_dis = new double[L]; double[] data_a = new double[L]; double[] data_Rho = new double[L]; for (int i = 0; i < L; i++) { string[] MyDataColumns = MyDataLines[i].Split('\t'); data_a[i] = Convert.ToDouble(MyDataColumns[selected[1]]); data_dis[i] = Convert.ToDouble(MyDataColumns[selected[0]]); data_Rho[i] = Convert.ToDouble(MyDataColumns[selected[2]]); object[] Data_Row = { data_dis[i], data_a[i], data_Rho[i] }; table.Rows.Add(Data_Row); } dataGridView1.DataSource = table; dis = data_dis; Rho = data_Rho; a = data_a; double[] X = data_dis; double[] Y = data_a; double[] Z = data_Rho; double minX = X.Min(); double maxX = X.Max(); double minY = Y.Min(); double maxY = Y.Max(); double intX = 1; double intY = 1; int LX = Convert.ToInt32((maxX - minX) / intX); int LY = Convert.ToInt32((maxY - minY) / intY); double[] intpX = new double[LX]; double[] intpY = new double[LY]; for (int i = 0; i < LX; i++) { if (i == 0) { intpX[i] = minX; } else { intpX[i] = intpX[i - 1] + intX; } } for (int i = 0; i < LY; i++) { if (i == 0) { intpY[i] = minY; } else { intpY[i] = intpY[i - 1] + intY; } } // IDW int nX = intpX.Length; int nY = intpY.Length; int N = nX * nY; double[] intpZ = new double[N]; double[] susX = new double[N]; double[] susY = new double[N]; for (int i = 0; i < nY; i++) { for (int j = 0; j < nX; j++) { susX[j + (nX * (i))] = intpX[j]; susY[j + (nX * (i))] = intpY[i]; } } double k = 2; for (int i = 0; i < N; i++) { double[] d_obs = new double[X.Length]; double[] d_ok = new double[X.Length]; double[] spd_ok = new double[X.Length]; double[] Zspd_ok = new double[X.Length]; double[] s_spd_ok = new double[X.Length]; double[] s_Zspd_ok = new double[X.Length]; for (int j = 0; j < X.Length; j++) { d_obs[j] = Math.Sqrt(Math.Pow(X[j] - susX[i], 2) + Math.Pow(Y[j] - susY[i], 2)); d_ok[j] = Math.Pow(d_obs[j], k); spd_ok[j] = 1 / (d_ok[j] + 0.00001); Zspd_ok[j] = Z[j] * spd_ok[j]; if (j == 0) { s_spd_ok[j] = spd_ok[j]; s_Zspd_ok[j] = Zspd_ok[j]; } else { s_spd_ok[j] = s_spd_ok[j - 1] + spd_ok[j]; s_Zspd_ok[j] = s_Zspd_ok[j - 1] + Zspd_ok[j]; } } intpZ[i] = s_Zspd_ok[X.Length - 1] / s_spd_ok[X.Length - 1]; } ILArray <double> ILintpZ = intpZ; ILArray <double> matrix = ILMath.zeros(nY, nX); for (int i = 0; i < nY; i++) { ILArray <int> rangeX = ILMath.vec <int>(0, nX - 1); ILArray <int> rangeZ = ILMath.vec <int>(0 + (nX) * (i), (nX * (i + 1) - 1)); matrix[i, rangeX] = ILintpZ[rangeZ]; } ILArray <float> matrixf = ILMath.convert <double, float>(matrix); ILArray <float> Xf = ILMath.convert <double, float>(intpX); ILArray <float> Yf = -1 * ILMath.convert <double, float>(intpY); ilPanel1.Scene.Add(new ILPlotCube { Axes = { XAxis = { Label = { Text = "Distance (m)" } }, YAxis = { Label = { Text = "a" } } }, Children = { new ILSurface(matrixf, Xf, Yf) { // make thin transparent wireframes Wireframe = { Color = Color.FromArgb(50,Color.LightGray) }, // choose a different colormap Colormap = new ILColormap(Colormaps.Jet), // add a colorbar (see below) Children = { new ILColorbar() } } } }); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }