"use strict"; function round2(x) { return Math.round(x * 100) / 100; } const B = 17.62; const C = 243.12; function dewPointC(tempC, rhPercent) { const alpha = Math.log(rhPercent / 100) + (B * tempC) / (C + tempC); return (C * alpha) / (B - alpha); } module.exports = { slug: "dew-point-magnus", title: "Dew point (Magnus formula)", deck_category: "other", description: "Computes the dew point temperature from air temperature and relative humidity using the Magnus formula.", inputs: [ { name: "temp_c", type: "number", unit: "degrees C", required: true, description: "Air temperature." }, { name: "relative_humidity_percent", type: "number", unit: "%", required: true, description: "Relative humidity.", min: 1, max: 100 } ], outputs: [ { name: "dew_point_c", unit: "degrees C", description: "Dew point temperature." } ], steps: [ "Magnus formula with the Alduchov-Eskridge coefficients: alpha = ln(RH/100) + (b*T)/(c+T), where T is temperature in C, RH is relative humidity in percent, b=17.62, c=243.12.", "Dew point Td = (c * alpha) / (b - alpha), in degrees C.", "Round to 2 decimals.", "Valid roughly for T between -45 C and 60 C and RH between 1% and 100%." ], constants: [ { name: "magnus_b", value: 17.62, unit: "dimensionless", source: 0 }, { name: "magnus_c", value: 243.12, unit: "degrees C", source: 0 } ], sources: [ { kind: "doi", value: "Alduchov, O.A. and Eskridge, R.E. (1996). Improved Magnus form approximation of saturation vapor pressure. Journal of Applied Meteorology, 35(4), 601-609.", title: "Improved Magnus form approximation of saturation vapor pressure", publisher: "Journal of Applied Meteorology (American Meteorological Society)", retrieved_utc: "2026-09-30T19:54:00Z", note: "Source of the b=17.62, c=243.12 coefficients, also reproduced by NOAA and ECMWF." } ], disclaimer: null, questionText(inputs) { return `Using the Magnus formula, what is the dew point at ${inputs.temp_c} degrees C and ${inputs.relative_humidity_percent}% relative humidity?`; }, run(inputs) { const { temp_c, relative_humidity_percent } = inputs || {}; if (typeof temp_c !== "number") throw new Error("temp_c must be a number"); if (typeof relative_humidity_percent !== "number" || relative_humidity_percent <= 0 || relative_humidity_percent > 100) { throw new Error("relative_humidity_percent must be a number between 1 and 100"); } const td = round2(dewPointC(temp_c, relative_humidity_percent)); return { answer: `${td.toFixed(2)} degrees C`, values: { dew_point_c: td } }; }, examples: [ { name: "worked example", inputs: { temp_c: 25, relative_humidity_percent: 60 }, expected: { answer: "16.69 degrees C" }, check: "By hand: alpha = ln(0.6) + (17.62*25)/(243.12+25) = -0.51083 + 1.64299 = 1.13216; Td = (243.12*1.13216)/(17.62-1.13216) = 275.25/16.4878 = 16.69. Cross-checked against the common rule-of-thumb Td ~ T - (100-RH)/5 = 25 - 8 = 17, which is close." }, { name: "test vector: cooler and drier", inputs: { temp_c: 20, relative_humidity_percent: 50 }, expected: { answer: "9.26 degrees C" }, check: "By hand: alpha = ln(0.5) + (17.62*20)/(243.12+20) = -0.69315 + 1.33933 = 0.64619; Td = (243.12*0.64619)/(17.62-0.64619) = 157.10/16.9738 = 9.26. Cross-checked against the rule-of-thumb Td ~ T - (100-RH)/5 = 20 - 10 = 10, which is close." } ] };