using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LuDianOperation { public class Ludian { //基于马哥拉斯改进公式计算水汽压与露点温度 public double T { get; set; } public double F { get; set; } private double Pa { get; set; } private double a { get; set; } private double b { get; set; } public static readonly double E0 = 6.1078; //海平面气压 // P0=Ps×10^[h/18400(1+Tm/273)] //P0为海平面气压,单位hPa; //Ps为本站气压,单位hPa; //h为气压传感器拔海高度,单位为m; //Tm为气柱平均温度,单位为℃,Tm=(t+t12)/2+h/400; //t为干球温度,单位℃; //t12为观测前12小时气温,单位℃。 /// <summary> /// 获得海平面气压 /// </summary> /// <param name="CurrentT">当前时间的温度</param> /// <param name="T12">12个小时之前的温度</param> /// <param name="CurrentStationPS">当前站点的气压</param> /// <param name="HaibaH">气压传感器拔海高度(海拔高度)</param> /// <returns>海平面气压(double)</returns> public double GetHaiPingMianQiYa(double CurrentT, double T12, double CurrentStationPS, double HaibaH) { try { //Tm=(t+t12)/2+h/400; double Tm = (CurrentT + T12) / 2 + HaibaH / 400; //[h/18400(1+Tm/273)] double centerDataOne = HaibaH / (18400 * (1 + Tm / 273)); //10^[h/18400(1+Tm/273)] double centerDataTwo = Math.Pow(10.0, centerDataOne); //Ps×10^[h/18400(1+Tm/273)] return Math.Round(CurrentStationPS * centerDataTwo, 1); } catch (Exception ex) { Console.WriteLine(ex.Message); return 0.0; } } /// <summary> /// 无参数构造函数 /// </summary> public Ludian() { } /// <summary> /// 构造函数 /// </summary> /// <param name="t">温度</param> /// <param name="f">湿度</param> public Ludian(double t, double f) { this.T = t; this.F = f; if (this.T > 0) { this.a = 7.69; this.b = 243.92; } else { this.a = 9.5; this.b = 265.5; } } #region 露点温度以及饱和水气压 /// <summary> /// 获得饱和水蒸气压 /// </summary> /// <returns></returns> public double GetES() { double Center = (a * this.T) / (b + this.T); return Math.Round(E0 * Math.Pow(10.0, Center), 1); } /// <summary> /// 计算中间变量 /// </summary> /// <returns></returns> private double E() { return GetES() * F * 0.01; } /// <summary> /// 计算出露点温度 /// </summary> /// <returns>double</returns> public double GetTd() { double ESS = E(); double AAA = b * Math.Log10(ESS / E0); double BBB = a - Math.Log10(ESS / E0); return Math.Round(AAA / BBB, 1); } #endregion #region 水气压 /// <summary> /// 根据水面温度获得水汽压 /// </summary> /// <returns></returns> public double GetEShuiQIYA(double Ts) { double Two = 17.269 * ((Ts - 273.16) / (Ts - 35.86)); return Math.Round(610.78 * Math.Exp(Two), 1); } /// <summary> /// 干湿球算法求水汽压 /// </summary> /// <param name="FSS">相对湿度</param> /// <returns></returns> public double GetEShuiQIYA() { return Math.Round((this.F * GetES() / 100), 2); } #endregion } }