private static INullableQueryTable <T> TempMath <T>(INullableQueryTable <T> sourceTable, string temperatureName, string humidityName, string dewPointName, Func <TemperatureMath, double> valueSelector) where T : struct { return(sourceTable.ToNewTable((o, n) => { n.AddSerie(sourceTable.TryGetSerie(temperatureName) .Zip(sourceTable.TryGetSerie(humidityName), dewPointName, (t, h) => { if (!t.HasValue || !h.HasValue) { return null; } var tempMath = new TemperatureMath(Convert.ToDouble(t.Value), Convert.ToDouble(h.Value)); return (T)Convert.ChangeType(valueSelector(tempMath), typeof(T)); })); })); }
private static T?CalcSnowingTemperature <T>(float dewPoint, T?humidity) where T : struct { if (humidity.HasValue == false) { return(null); } float temp = dewPoint; var doubleHumidity = humidity.ToDouble(); var calc = new TemperatureMath(temp, doubleHumidity); temp = (float)(temp + (temp - calc.Taupunkt)); for (int i = 0; i < 3; i++) { var calc2 = new TemperatureMath(temp, doubleHumidity); temp = (float)(temp + (dewPoint - calc2.Taupunkt)); } return(temp.ToType <T>()); }
public double ConvertWithWindChill(double input, double wind) { return(Convert(TemperatureMath.CalculateWindChill(input, SourceUnit, wind))); }