Monday, September 28, 2009

testing one two three 
0        1         2         3         4         5         6         7
1234567890123456789012345678901234567890123456789012345678901234567890123456
Testing one two three

Tuesday, July 21, 2009

//------------------------------------------------------------------------------
//
// dods2unix($dods_date)
//
// This routine turns a dods-style date into a unix timestamp. It should work
// after 07dec08 (the date I wrote it) but not sure how it would work for
// earlier dates due to the fact that I don't know for sure how things like
// leap year are handled.
//
// (Note: 1228629600 is the unix timestamp for midnight December 7th, 2008.
// 733384 is the dods-style date for December 7th, 2008)
//
//
//------------------------------------------------------------------------------
function dods2unix($dods_date){
return (1228629600 + 60*60+($dods_date - 733384)*86400);
// the 60*60 is for local machine vs mountain time zone...
// you may need to mess with this...
}
//------------------------------------------------------------------------------
//
//
// function uv2deg($u, $v)
//
// Converts winds in u and v to degrees
//
//
//
//
//
//------------------------------------------------------------------------------
function uv2deg($u, $v){
//convert u, v components to direction and speed
// (Remember u and v are wind *vectors* ... *not* conventional winds
// in which direction is the direction *from* which winds are coming!)

// Quadrant I (positive u and v...this would be a wind *from* the SW quadrant
If ($u >= 0 and $v > 0){
$wind_dir = @sprintf("%03.0f", @round((180 /M_PI) * @atan($u/$v))+180,-1);
}

// Quadrant II (negative u, positive v... wind *from* SE)
If ($u <>= 0){
$wind_dir = @sprintf("%03.0f", @round((180 /M_PI) * @atan($v/abs($u))+90),-1);
}

// Quadrant III (negative u and v...wind from NE quadrant)
if ($u <= 0 And $v < 0){
$wind_dir = @sprintf("%03.0f", @round((180 /M_PI) * @atan(abs($u)/abs($v))),-1);
}

// Quadrant IV (positive u, negative v...wind *from* the NW)
If ($u > 0 and $v <= 0 ){
$wind_dir = @sprintf("%03.0f", @round((180 /M_PI) * @atan(abs($v)/$u)+270),-1);
}


if ($u==0 and $v==0){
$wind_dir="Ca";
}

if ($wind_dir=="000"){
$wind_dir = "360";
}

return $wind_dir;
}