Python利用Goff-Gratch方程式,通过温度和湿度计算露点温度

单纯用来记笔记而已

1、首先计算饱和水汽压Ew

2、再利用相对湿度和饱和水汽压Ew计算水汽压

 3、最后用水汽压计算得到露点温度

import math

# 水汽压常数
SQYA = 10.79574
SQYB = -5.028
SQYC = 0.000150475
SQYD = -8.2969
SQYE = 0.00042873
SQYF = 4.76955
SQYG = 0.78614
SXDWD = 273.16

# 露点温度常数
LDWDA = 7.69
LDWDB = 243.92
BHSQY0 = 6.1078

def calculate_vapour_pressure_and_dew_point_temperature(temperature, humidity):
    """
    根据气温和相对湿度计算水汽压和露点温度
    :param temperature: 温度 (摄氏度)
    :param humidity: 湿度 (百分比)
    :return: 水汽压 (hPa), 露点温度 (摄氏度)
    """
    if temperature < -273.15:
        raise ValueError("Error: Temperature cannot be below absolute zero!")
    
    if humidity < 0 or humidity > 100:
        raise ValueError("Error: Humidity must be between 0 and 100!")

    # 转换为开尔文
    temp_k = temperature + 273.15

    # 相对湿度去掉百分号
    humidity /= 100

    # 根据公式计算饱和水汽压
    saturation_vapour_pressure = math.pow(10, SQYA * (1 - SXDWD / temp_k) + SQYB * math.log10(temp_k / SXDWD) +
                                         SQYC * (1 - math.pow(10, SQYD * (temp_k / SXDWD - 1))) +
                                         SQYE * (math.pow(10, SQYF * (1 - SXDWD / temp_k)) - 1) + SQYG)

    # 计算水汽压 = 饱和水汽压 * 相对湿度
    vapour_pressure = humidity * saturation_vapour_pressure
    

    # 计算露点温度,由水汽压计算得到
    dew_point_temperature = (LDWDB * math.log10(vapour_pressure / BHSQY0)) / (LDWDA - math.log10(vapour_pressure / BHSQY0))

    return saturation_vapour_pressure, vapour_pressure, dew_point_temperature

def main():    
    # 输入:温度(°C)和相对湿度(%)
    temperatures = [5.9]  # 温度列表
    humidities = [39, 40, 41, 42, 43, 44, 45]  # 湿度列表

    print("Temp (°C) | RH (%) | Ew (hPa) | e (hPa) | Td (°C) |")
    print("-----------------------------------------------------")

    for T in temperatures:
        for RH in humidities:
            Ew, e_s, T_d = calculate_vapour_pressure_and_dew_point_temperature(T, RH)
            print(f"{T:>10} | {RH:>6} | {Ew:>8.2f} | {e_s:>7.2f} | {T_d:>8.2f} |")
if __name__ == "__main__":
    main()

相关公式摘取至:地面气象观测 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

放氮气的蜗牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值