public V2DataOnGrid(string info, double EM_frequency, Grid1D OX_settings, Grid1D OY_settings) : base(info, EM_frequency) { EM_array = new Complex[OX_settings.knot_count, OY_settings.knot_count]; grid_settings = new Grid1D[2]; grid_settings[0] = OX_settings; grid_settings[1] = OY_settings; }
/* * (data format in file named filename) * * descriptions - (string) * EM_frequency - (float with point, not comma) * stride_OX, knot_count_OX - (float, int) * stride_OY, knot_count_OY - (float, int) * (x_1,1, y_1,1) ... (x_1,knot_count_OX, y_1,knot_count_OX) - (float, float) * ... ... * ... ... * ... ... * (x_knot_count_OY,1, y_knot_count_OY,1) ... (x_knot_count_OY,knot_count_OX, y_knot_count_OY,knot_count_OX) - (float, float) * * Example: * * "date - 16/11/2020" * 12 * 1 2 * 3 2 * (-1.1, 1.2) (-1.3, 0.9) * (-4.1, 1.6) (3.4, -4.2) */ public V2DataOnGrid(string filename) : base("", 0) { string path = "../../../" + filename; double EM_frequency; Grid1D OX_settings, OY_settings; char[] delimiterChars = { ' ', ',', '(', ')' }; try { string[] lines = System.IO.File.ReadAllLines(path); info = lines[0]; EM_frequency = Convert.ToDouble(lines[1]); string[] numbers = lines[2].Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); OX_settings = new Grid1D((float)Convert.ToDouble(numbers[0]), Convert.ToInt32(numbers[1])); Array.Clear(numbers, 0, numbers.Length); numbers = lines[3].Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); OY_settings = new Grid1D((float)Convert.ToDouble(numbers[0]), Convert.ToInt32(numbers[1])); Array.Clear(numbers, 0, numbers.Length); grid_settings = new Grid1D[2]; grid_settings[0] = OX_settings; grid_settings[1] = OY_settings; EM_array = new Complex[OX_settings.knot_count, OY_settings.knot_count]; int x = 0, y = 0; for (int i = 4; i < lines.Length; i++) { numbers = lines[i].Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); for (x = 0; x < OX_settings.knot_count; x++) { EM_array[x, y] = new Complex(double.Parse(numbers[2 * x], System.Globalization.CultureInfo.InvariantCulture), double.Parse(numbers[2 * x + 1], System.Globalization.CultureInfo.InvariantCulture)); } y++; Array.Clear(numbers, 0, numbers.Length); } base.info = info; base.EM_frequency = EM_frequency; } finally { Console.WriteLine(" < The 'try catch' block is finished > \n"); } }