Taupunkt-Temperatur berechnen

Dieses PHP-Script berechnet die Taupunkt-Temperatur. Eingabewert ist die Temperatur (in °C) sowie die Luftfeuchte (in %).

Der $nil-Wert bestimmt den Wert der zurückgegeben werden soll, wenn die Berechnung scheitert. Das ist beispielsweise dann der Fall, wenn schon die Eingabewerte Fehler beinhalten.

<?php
/*
    This Software calculates dewpoint by given 2m-temperature and 2m-humidity.

    Copyright (C) 2020 Guido Richter / tintenkobold.de

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License [http://www.gnu.org/licenses/] for more details.
*/

function tp($nil,$t2m,$rh2m)
{
	if($rh2m>0 AND is_numeric($t2m))
	{
		// calculate dewpoint
		$saturation_pressure	= 6.1078*pow(10,((7.5*$t2m)/(237.3+$t2m)));
		$saturation_deficit	= ($rh2m/100)*$saturation_pressure;
		$dp			= (234.67*(log($saturation_deficit)/log(10))-184.2)/(8.233-(log($saturation_deficit)/log(10)));
		return $dp;
	}
	else return $nil;
}

?>

Schreibe einen Kommentar