科学データを含むcsv形式のファイルがいくつかあり、それらを3Dでプロットすることを検討しています。ファイルの内容は、次の例のように、日時、周波数 (Hz)、強度 (dB) として編成されます。
2014-03-15 18:00:00, 19700000.0, -30.19
2014-03-15 18:00:00, 19700781.25, -31.19
2014-03-15 18:00:00, 19701562.5, -30.43
2014-03-15 18:00:00, 19702343.75, -30.37
2014-03-15 18:00:00, 19703125.0, -27.06
プロット コンテキストでは、3 つの値はそれぞれ x、y、z を表します。
datetime、float、float型で構成されるdatasampleという名前のカスタム型を作成し、配列を次のように宣言したいと思います。
ILArray<datasample>
プロットのために ILArray をファイルからロードする特定の関数または推奨される方法はありますか?
ILNumerics は最初の列の日時形式を正しく処理できますか、それともファイルを前処理して別の形式に変換する必要がありますか?
あなたの親切なサポートをありがとう
次のソースコードで回答後に更新しました。これで360万ポイントを ロードし、3Dプロットがスムーズにレンダリングされました。Z値に基づいて個々のポイントに色を付ける方法についての指示が必要です。入力に何百万ものポイントがあるサーフェスを使用するのは少し...重いようです:-) 私が使用できるパフォーマンスのヒントはありますか?
これはスクリーンショットです:
using ILNumerics;
using ILNumerics.Drawing;
using ILNumerics.Drawing.Plotting;
using System.IO;
using System.Globalization;
private void ilPanel1_Load(object sender, EventArgs e)
{
fsin = new System.IO.StreamReader("testlong.iln");
while(fsin.EndOfStream == false)
{
datarow = fsin.ReadLine();
// Console.WriteLine(datarow);
rowvalues = datarow.Split(',');
inrows = inrows + 1;
tempX.Add(float.Parse(rowvalues[0], CultureInfo.InvariantCulture));
tempY.Add(float.Parse(rowvalues[1], CultureInfo.InvariantCulture));
tempZ.Add(float.Parse(rowvalues[2], CultureInfo.InvariantCulture));
}
fsin.Close();
// now that I know the input size (number of x,y,z tuples), I can
// create and initialize the ILArray :
ILArray<float> datasamples = ILMath.zeros<float>(3, (int)inrows );
label1.Text = String.Format("Data points read: {0:N0}", inrows);
// ... and now I can copy data from the input arrays:
datasamples["0;:"] = tempX.ToArray();
datasamples["1;:"] = tempY.ToArray();
datasamples["2;:"] = tempZ.ToArray();
// these are no longer used so...
tempX.Clear();
tempY.Clear();
tempZ.Clear();
var scene = new ILScene {
new ILPlotCube(twoDMode: false) {
new ILPoints {
Positions = datasamples,
Color = Color.Blue,
// Colors =
Size = 0.5F
}
}
};
// at the end of all modifications, call Configure()
ilPanel1.Scene = scene;
ilPanel1.Scene.Configure();
ilPanel1.Refresh();
}