How to GET humidex and all other data layers

Hello!
I’d like to use GET api calls to obtain humidex (and other data layers) from PAII sensors. I’m using the GET statement below, but it does not include humidex.
I’d appreciate anyone who can help :smiley:

curl -X GET "https://api.purpleair.com/v1/sensors/118883" -H "X-API-Key:XXXXXXX..."

1 Like

Certain layers, including Humidex, aren’t currently available on the API. A complete list of queryable fields is available in our API Documentation.

One option is to locally calculate Humidex using temperature and humidity data from the API. If doing this, please note that temperature and humidity from the API are uncorrected. You can read more about this and available corrections in the Temperature and Humidity section of our What do PurpleAir Sensors Measure article.

1 Like

Here is the humidex function:

	export function getHumidex(T, RH) {
		/*
		https://en.wikipedia.org/wiki/Humidex
		From https://www.physlink.com/Education/AskExperts/ae287.cfm 

		humidex = (air temperature) + h 
		where, h = (0.5555)*(e - 10.0); and, 
		e = 6.11 * exp(5417.7530 * ((1/273.16) - (1/dewpoint))) 
		*/
		T = ftoc(T);
		if (RH > 100) RH = 100;
		var dewpoint = dew(T, RH) + 273.15;
		//console.log("dewpoint: " + dewpoint);
		var e = 6.11 * Math.exp(5417.7530 * ((1/273.16) - (1/dewpoint)));
		var h = (0.5555)*(e - 10.0);
		var humidex = T + h
		//console.log("humidex: " + humidex);
		return Math.round(humidex);
		
	/*
		Also a related and simplified formula that takes temperature and the relative humidity inputs is: 
		Humidex = T + 5/9 * (e-10) 	where: 
		e = vapour pressure(6.112*10^(7.5*T/(237.7+T))*H/100) 
	
		T= air temperature (degrees Celsius) 
		H= humidity (%) 
		*/
	}

1 Like

And this is what we do to the temperature readings before using them in the humidex function:

	export function estimateHumidity(raw) {
		let est = 1.4498 * raw + 7.022;
		if (est > 100) {
			est = 100;
		}
	    return est;
	}
	
	export function estimateTemperature(raw) {
		return 1.0227 * raw - 9.375;
	}

1 Like

And the helper functions use in the humidex calculation above:

    export function dew(T, RH) {
        //console.log("T: "+ T + " RH: " + RH);
        /*
        From http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
        RH: =100*(EXP((17.625*TD)/(243.04+TD))/EXP((17.625*T)/(243.04+T)))
        TD: =243.04*(LN(RH/100)+((17.625*T)/(243.04+T)))/(17.625-LN(RH/100)-((17.625*T)/(243.04+T)))
         T: =243.04*(((17.625*TD)/(243.04+TD))-LN(RH/100))/(17.625+LN(RH/100)-((17.625*TD)/(243.04+TD)))
         (• replace "T", "TD", and "RH" with your actual cell references)
         (• T and TD inputs/outputs to the equations are in Celsius)
    
        */
        return 243.04 * (Math.log(RH / 100) + ((17.625 * T) / (243.04 + T))) / (17.625 - Math.log(RH / 100) - ((17.625 * T) / (243.04 + T)));
    }

    export function ftoc(f) {
        //	T(°C) = (T(°F) - 32) × 5/9
        return (Math.round(1 * ((f - 32) * (5 / 9)))) / 1;
    }

1 Like