private void InterpolateCvY(double value) { var interpColumnName = CvYColumnConverter.NameFromValue(value); var interpTable = new TableProcessing.Table("Interpolate " + interpColumnName); interpTable.AddColumn(tables.OrdinKtgr.Column("PY")); var floorValue = double.NegativeInfinity; var ceilValue = double.PositiveInfinity; for (var i = 0; i < tables.OrdinKtgr.DataTable.Columns.Count; i++) { var column = tables.OrdinKtgr.DataTable.Columns[i]; if (column.ColumnName.IndexOf("CvY_", StringComparison.Ordinal) != 0) { continue; } var CV_value = CvYColumnConverter.ValueFromName(column.ColumnName); if (CV_value < value) { floorValue = CV_value; } else if (CV_value > value) { ceilValue = CV_value; break; } } var floorStr = CvYColumnConverter.NameFromValue(floorValue); var ceilStr = CvYColumnConverter.NameFromValue(ceilValue); interpTable.AddColumn(tables.OrdinKtgr.Column(floorStr)); var column_res = interpTable.Column(interpColumnName); interpTable.AddColumn(tables.OrdinKtgr.Column(ceilStr)); interpTable.IterateRows(row => { double[] x = { floorValue, ceilValue }; double[] y = { row[floorStr].DoubleValue, row[ceilStr].DoubleValue }; var res = LinearSpline.Interpolate(x, y).Interpolate(value); row.Set(column_res.Name, res); }, column_res.Name); tables.OrdinKtgr.AddColumn(interpTable.Column(interpColumnName)); }
private void Calc_CvY_Column() { tables.CalcsHydro.AddColumn(tables.BazaInfoHydro.Column("CvY")); tables.CalcsHydro.IterateRows(row => { var value_CvY = row["CvY"].DoubleValue; var name = CvYColumnConverter.NameFromValue(value_CvY); row.Set("CvY_Column", name); }, "CvY_Column"); }
private void TestConvertToName(double value, string name) { Assert.AreEqual(name, CvYColumnConverter.NameFromValue(value), "value({0}) -> name({1})", value, name); }