"use strict"; function heatIndexF(T, R) { return ( -42.379 + 2.04901523 * T + 10.14333127 * R - 0.22475541 * T * R - 0.00683783 * T * T - 0.05481717 * R * R + 0.00122874 * T * T * R + 0.00085282 * T * R * R - 0.00000199 * T * T * R * R ); } module.exports = { slug: "heat-index-us-nws", title: "Heat index (US NWS Rothfusz regression)", deck_category: "other", description: "Computes the heat index (apparent temperature) using the Rothfusz regression as used by the US National Weather Service.", inputs: [ { name: "temp_f", type: "number", unit: "degrees F", required: true, description: "Air temperature.", min: 80, max: 110 }, { name: "relative_humidity_percent", type: "number", unit: "%", required: true, description: "Relative humidity.", min: 40, max: 100 } ], outputs: [ { name: "heat_index_f", unit: "degrees F", description: "Heat index (apparent temperature)." } ], steps: [ "Rothfusz regression: HI = -42.379 + 2.04901523*T + 10.14333127*R - 0.22475541*T*R - 0.00683783*T*T - 0.05481717*R*R + 0.00122874*T*T*R + 0.00085282*T*R*R - 0.00000199*T*T*R*R, where T is temperature in F and R is relative humidity in percent.", "This card uses the base regression only, valid for approximately T from 80 to 110 F and R from 40 to 100 percent; NWS applies small additional adjustments outside a normal humidity band (very low or very high RH) that this card does not include.", "Round to the nearest whole degree." ], constants: [], sources: [ { kind: "url", value: "https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml", title: "The Heat Index Equation (Rothfusz regression)", publisher: "National Weather Service Weather Prediction Center (NOAA)", retrieved_utc: "2026-09-30T19:53:00Z", note: "Official NWS statement of the Rothfusz regression for heat index." } ], disclaimer: null, questionText(inputs) { return `Using the NWS Rothfusz regression, what is the heat index at ${inputs.temp_f} degrees F and ${inputs.relative_humidity_percent}% relative humidity?`; }, run(inputs) { const { temp_f, relative_humidity_percent } = inputs || {}; if (typeof temp_f !== "number" || temp_f < 80 || temp_f > 110) throw new Error("temp_f must be a number between 80 and 110"); if (typeof relative_humidity_percent !== "number" || relative_humidity_percent < 40 || relative_humidity_percent > 100) { throw new Error("relative_humidity_percent must be a number between 40 and 100"); } const hi = Math.round(heatIndexF(temp_f, relative_humidity_percent)); return { answer: `${hi} degrees F`, values: { heat_index_f: hi } }; }, examples: [ { name: "worked example", inputs: { temp_f: 90, relative_humidity_percent: 50 }, expected: { answer: "95 degrees F" }, check: "By hand, summing each regression term at T=90, R=50: -42.379 + 184.4114 + 507.1666 - 1011.3993 - 55.3864 - 137.0429 + 497.6397 + 191.8845 - 40.2975 = 94.60, rounding to 95." }, { name: "test vector: hotter and drier", inputs: { temp_f: 100, relative_humidity_percent: 40 }, expected: { answer: "109 degrees F" }, check: "By hand, summing each regression term at T=100, R=40: -42.379 + 204.9015 + 405.7333 - 899.0216 - 68.3783 - 87.7075 + 491.496 + 136.4512 - 31.84 = 109.26, rounding to 109." } ] };