[Phphtmllib-devel] SF.net SVN: phphtmllib:[3521] trunk/open2300/lib/modules/api/ AviationWeather.in
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-06-28 23:20:47
|
Revision: 3521 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3521&view=rev Author: hemna Date: 2010-06-28 23:20:40 +0000 (Mon, 28 Jun 2010) Log Message: ----------- hacks Modified Paths: -------------- trunk/open2300/lib/modules/api/AviationWeather.inc Modified: trunk/open2300/lib/modules/api/AviationWeather.inc =================================================================== --- trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 22:40:43 UTC (rev 3520) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:20:40 UTC (rev 3521) @@ -717,10 +717,10 @@ * @link http://www.4wx.com/wxcalc/formulas/densityAltitude.php */ protected function density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) { + $this->e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC); //get vapor pressure ($Vp) - $Vpexp = (7.5*$dewC) / (237.7+$dewC); - $Vp = 6.11*pow(10, $Vpexp); + $Vp = $this->vapor_pressure($dewC); //get virtual Temp $Tv (in Kelvin) $TvK = ($tempC / (1-($Vp / $Pmb) * (1-0.622))); @@ -733,9 +733,164 @@ return $Ad; } + + + private function vapr_pressure($dewC) { + $Vpexp = (7.5*$dewC) / (237.7+$dewC); + $Vp = 6.11*pow(10, $Vpexp); + return $Vp; + } + // Calculate absolute air pressure given the barometric pressure(mb) and altitude(meters) + private function calcAbsPress($Pmb, $altM) { + $k1 = 0.190284; + $k2 = 8.4288*Math.pow(10,-5); + $p1 = pow($Pmb,$k1); + $p2 = $altM*$k2; + $p3 = 0.3+pow( ($p1-$p2), (1/$k1) ); + return $p3; + } + + + // Calculate the air density in kg/m3 + private function calcDensity($absPmb, $e, $tc) { + $Rv=461.4964; + $Rd=287.0531; + + $tk = $tc + 273.15; + $pv = $e*100; + $pd = ($absPmb-$e)*100; + $d= ($pv/($Rv*$tk)) + ($pd/($Rd*$tk)); + return $d; + } + + // Calculate the ISA altitude (meters) for a given density (kg/m3) + private function calcAltitude($d) { + $g=9.80665; + $Po=101325; + $To=288.15; + $L=6.5; + $R=8.314320; + $M=28.9644; + $D=$d*1000; + $p2=( ($L*$R)/($g*$M-$L*$R) )*log( ($R*$To*$D)/($M*$Po) ); + + $H=-($To/$L)*( exp($p2)-1 ); + + $h = $H*1000; + + return $h; + } + + + + // Calculate the Z altitude (meters), given the H altitide (meters) + private function calcZ($h) { + $r=6369E3; + + return (($r*$h)/($r-$h)); + + } + + + // Calculate the H altitude (meters), given the Z altitide (meters) + private function calcH($z) { + $r=6369E3; + + return (($r*$z)/($r+$z)); + } + + + // Calculate the actual pressure (mb)from the altimeter setting (mb) and geopotential altitude (m) + private function calcAs2Press($As, $h) { + $k1=.190263; + $k2=8.417286E-5; + + $p=pow( (pow($As,$k1)-($k2*$h)),(1/$k1) ); + + return $p; + } + + + private function e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC) { + + $in_per_mb = (1/33.86389); + $mb_per_in = 33.86389; + + $m_per_ft = 0.304800; + $ft_per_m = (1/.304800); + + + $zm = $altitude*$m_per_ft; + + + // Calculate the vapor pressures (mb) given the ambient temperature (c) and dewpoint (c) + + $esmb = $this->calcVaporPressure_wobus($tempC); + $emb = $this->calcVaporPressure_wobus($dewC); + + + // Calculate geopotential altitude H (m) from geometric altitude (m) Z + + $hm = $this->calcH($zm); + + + // Calculate the absolute pressure given the altimeter setting(mb) and geopotential elevation(meters) + + $actpressmb = $this->calcAs2Press($Pmb, $hm); + + + // Calculate the air density (kg/m3) from absolute pressure (mb) vapor pressure (mb) and temp (c) + + $density = $this->calcDensity($actpressmb, $emb, $tempC); + $relden = 100*($density/1.225); + + + // Calculate the geopotential altitude (m) in ISA with that same density (kg/m3) + + $densaltm = $this->calcAltitude($density); + + // Calculate geometric altitude Z (m) from geopotential altitude (m) H + + $densaltzm = $this->calcZ($densaltm); + + + // Convert Units for output + + $actpress = $actpressmb*$in_per_mb; + $densalt = $densaltzm*$ft_per_m; + + if ( $densalt > 36090 || $densalt < -15000 ) { + + var_dump ("Out of range for Troposhere Algorithm: Altitude =" . round($densalt,0) . " feet" ); + return; + } + + var_dump("Absolute Pressure ".round($actpress,3)); + var_dump("Density altitude ".round($densalt,0)); + var_dump("Relative Density ".round($relden,2)); + + } + + + + + + + + + + + + + + + + + + protected function do_images($icao) { $airport_images = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |