Potentielle Äquivalenttemperatur (ThetaE) berechnen

Dieses PHP-Script berechnet die potentielle Äquivalenttemperatur (ThetaE) einer Luftmasse mit den Eingabewerten Temperatur (in °C), Luftfeuchte (in %), Luftdruck (in hPa) und Höhe über Normalnull (in Metern).

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 thetae value by given 2m-temperature,2m-humidity,pressure(QNH) and station height.

    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 thetae($nil,$t2m,$rh2m,$p,$h)
{
	if($p>800 AND is_numeric($h) AND $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)));
		// calculate thetae
		$sp 		= 6.1078*pow(10,((7.5*$dp)/(237.3+$dp)));
		$sm 		= (0.622*$sp)/$p;
		$te 		= 2.5*pow(10,6);
		$thetae 	= $t2m+((10/1005)*$h)+(($te/1005)*$sm);
		return $thetae;
	}
	else return $nil;
}
?>

Schreibe einen Kommentar