单纯用来记笔记而已
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()
相关公式摘取至:地面气象观测