Jul 232013
Share on Facebook0Share on Google+0Pin on Pinterest0Tweet about this on TwitterShare on LinkedIn0Email this to someoneShare

I’m right at the 4 inch mark for the month of July. This is the most rain I can remember recording in one month. The dewpoint temperatures are very high. In fact, dew covered my front yard this morning. This is an exceptionally rare occurrence. The National Weather Service is saying we won’t get a monsoon break anytime soon. This is from their forecast discussion this morning. Other forecasts and models show the moisture moving out later this week or early next week. We will see.

A special request from a local pilot got me going on the programing front last weekend. Dr. PS missed my inclusion of density altitude on my website. Because of altitude, dry air and large temperature fluctuations throughout the day, the density altitude can change drastically. Some of my Air Force and CAP friends have relayed stories of private pilots flying to Flagstaff, filling up with gas, and not being able to return to the skies because the density altitude is about 10,000 feet, not 7,000. Density altitude take into account the air temperature, local barometric pressure and water content. It represents the altitude you would otherwise see with standard atmospheric conditions. It’s an important pilot issue.

I added it to the barometric pressure section of my main webpage last night. It took a several new attempts to reinvigorate an old attempt that had clunky equations and formatting. To give you a feel for what it takes to calculate one number like this, here is the php code I wrote to handle the job. It’s a bit over 100 lines of code. It was good to succeed in crunching through details. The results are on the main page.

/* This script returns the html code for printing Density Altitude. The inputs are
* taken from Sandysoft’s Cumulus software:
*  http://sandaysoft.com/ 
* Temperature, sea level barometric pressure, dewpoint temperature and altitude
* are webtags in the software. The tags are converted to numeric output by Cumulus.
* When uploaded to the FTP site by Cumulus, the output file
* should be a php file. This file can be included in a main php file for website
* generation. Assumes tagged input is reported in the units shown.
* php variable        tagged input    definition
*     $tact                <#temp>            outside temp(F)
*    $paltmb                <#press>        sea level barametric pressure(mb)
*    $palthg                                calculated sea level barametric pressure(inHg)
*     $pstnhg                                calculated station pressure(inHg)
*    $pstnmb                                calculated station pressure(mb)
*     $dpt                <#dew>            outside dewpoint(F)
*     $vaporp                                calculated vapor pressure(mb)
*      $tvirtual                             calculated virtual temperature(K)
*    $stnalt                <#altitude>        station altitude(ft)
*    $stnaltm                            calculated station altitude(m)
*      $densityalt                            calculated density altitude(ft)
*      $densityaltm                        calculated density altitude(m)
*     $pressalt                            caluclated pressure altitude
*     $base                                generic variable for use in pow($base, $exp) function
*     $exp                                generic variable for use in pow($base, $exp) function
* The equations are from the Salt Lake City National Weather Service office.
* They have several projects that area published on the web:
*  http://www.wrh.noaa.gov/slc/projects/wxcalc/wxcalc.php
* A very nice PDF of the calculation is here:
*  http://www.wrh.noaa.gov/slc/projects/wxcalc/formulas/densityAltitude.pdf
*  You have to read the document very carefully to not lose track of the units
*  used for input, and calculated outputs. Also, some of the other pdf files on
*  the main site provide simpler methods to calculate things.

*  The output is the density altitude in feet and meters. It is unformatted and
*  relies on the local css file for formatting and style.

// tagged input
$tact =
$paltmb =
$dpt =
$stnalt =
$stnalt = rtrim($stnalt,” ft”);

/* Conversion to proper units
* temperature to Kelvin
* dewpoint to Celcius
* pressure to inHg (in a new variable)
* altitude in meters
$tact = 5/9*($tact – 32);
$tact = $tact + 273.15;
$palthg = 0.02953*$paltmb;
$dpt = 5/9*($dpt – 32);
//$dpt = $dpt + 273.15;
$stnaltm = $stnalt*0.3048;

//calculate station pressures
$base = (288-0.0065*$stnaltm)/288;
$pstnmb = $paltmb*pow($base, 5.2561);
$pstnhg = $pstnmb*0.02953;

//Calculate vapor pressure
$expo = (7.5*$dpt)/(237.7+$dpt);
$ten = pow(10,$expo);
//$vaporp = 6.11*10^((7.5*$dpt)/(237.7+$dpt));
$vaporp = 6.11*$ten;
//Calculate virtual temperature
$tvirtual = $tact/(1-0.379*($vaporp/$pstnmb));
echo $tvirtual;
$tvirtual = 1.8*$tvirtual;

//calculate pressure altitude
$base = $pstnmb/1013.25;
$pressalt = (1-pow($base, 0.190284))*145366.45;

//calculate density altitude
$base = 17.326*$pstnhg/$tvirtual;
$densityalt = 145366.18*(1-pow($base,0.235));
$densityaltm = $densityalt*0.3048;

//Provide unformatted output if desired
//echo “station pressure(inhg): “.$pstnhg;
//echo “station pressure(mb): “.$pstnmb;
//echo “actual temperature(k): “.$tact;
//echo “vapor pressure(): “.$vaporp;
//echo “Virtual Temperature(R): “.$tvirtual;
//echo “Density Altitude(ft): “.round($densityalt);
//echo “Density Altitude (m): “.round($densityaltm);
//echo “pressure altitude(ft): “.round($pressalt);

Share on Facebook0Share on Google+0Pin on Pinterest0Tweet about this on TwitterShare on LinkedIn0Email this to someoneShare


[suffusion-the-author display='description']
 Posted by at 7:19 am

Sorry, the comment form is closed at this time.

5 visitors online now
3 guests, 2 bots, 0 members
Max visitors today: 9 at 08:36 am UTC
This month: 18 at 07-02-2017 09:28 am UTC
This year: 86 at 03-09-2017 03:59 pm UTC
All time: 1611 at 04-27-2012 06:53 pm UTC