{
  "schemaVersion": 1,
  "slug": "humidity-calculator",
  "category": "weather",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "07b31927dcba60d70a7034c37fd12b596622e9119c7fd1d510f848c26df85cf8",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/humidity-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "es = 6.112 × e^(17.67T ÷ (T + 243.5)) ; e = 6.112 × e^(17.67D ÷ (D + 243.5)) ; RH = 100 × e ÷ es ; AH = 216.7 × e ÷ (T + 273.15)",
    "vars": [
      [
        "T",
        "air temperature (°C)"
      ],
      [
        "D",
        "dew point (°C)"
      ],
      [
        "es",
        "saturation vapor pressure (hPa)"
      ],
      [
        "e",
        "actual vapor pressure (hPa)"
      ]
    ],
    "note": "Valid only when dew point ≤ air temperature; RH is not clamped. Mixing ratio assumes 1013.25 hPa. °F inputs convert to °C."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if (dewPoint > temperature) return { relativeHumidity: null, absoluteHumidity: null, vaporPressure: null, saturationPressure: null, mixingRatio: null, comfort: null, __error: 'inputError' }; const k = unit === 'f' ? 5/9 : 1; const off = unit === 'f' ? 32 : 0; const T = (temperature - off)*k; const D = (dewPoint - off)*k; const es = 6.112*Math.exp(17.67*T/(T + 243.5)); const e = 6.112*Math.exp(17.67*D/(D + 243.5)); const rh = e/es*100; const ah = 216.7*e/(T + 273.15); const p = 1013.25; return { relativeHumidity: rh, absoluteHumidity: ah, vaporPressure: e, saturationPressure: es, mixingRatio: 621.97*e/(p - e), comfort: rh < 30 ? 'Dry' : rh < 50 ? 'Comfortable' : rh < 65 ? 'Slightly humid' : rh < 80 ? 'Humid' : 'Very humid' };",
    "inputs": [
      {
        "name": "temperature",
        "type": "number",
        "default": 24,
        "min": -60,
        "max": 60,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "dewPoint",
        "type": "number",
        "default": 16,
        "min": -80,
        "max": 60,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "unit",
        "type": "select",
        "default": "c",
        "options": [
          {
            "value": "c"
          },
          {
            "value": "f"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "relativeHumidity",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "absoluteHumidity",
        "precision": 2,
        "unit": "g/m³"
      },
      {
        "name": "vaporPressure",
        "precision": 2,
        "unit": "hPa"
      },
      {
        "name": "saturationPressure",
        "precision": 2,
        "unit": "hPa"
      },
      {
        "name": "mixingRatio",
        "precision": 2,
        "unit": "g/kg"
      },
      {
        "name": "comfort",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
