"; } ?> CU Spaceflight - Landing Prediction (Beta)

CU Spaceflight - Landing Prediction


Using GRIB data from the " . fread($fp, 4) . "/" . fread($fp, 2) . "/" . fread($fp, 2) . " " . fread($fp, 2) . ":00 GMT model

"; if (!isset($_POST['submit'])) { // form not submitted, so display the form $time = localtime(time(), true); ?>
Launch Site:
Latitude:
Longitude:
Launch altitude (m):
Launch Time: " maxlength="2" size="2"> : " maxlength="2" size="2"> -
Ascent Rate (m/s):
Descent Rate (sea level m/s):
Burst Altitude (m):
Float time at apogee (s):

NOTE: Now updated to work world wide and up to 120 hours in the future, although its still very buggy and gives errors for some launch locations, we will be working to fix this soon.

Running auto forecast - will take several minutes

"; $output = shell_exec("./auto_prediction"); echo "

" . nl2br($output) . "

"; echo "

KML File

"; footer(); exit(1); } // use lock file as a mutex, this has potential for cockups if (file_exists("lock")) { echo "Server currently running a prediction, please try again in a few minutes or contact us on IRC (#highaltitude irc.freenode.net)."; footer(); exit(1); } $timestamp = mktime($_POST['hour'], $_POST['min'], $_POST['sec'], (int)$_POST['month'] + 1, $_POST['day'], (int)$_POST['year'] - 2000); //if ($timestamp < time() || $timestamp > (time() + 120*3600)) { if ($timestamp > (time() + 180*3600)) { echo "

Invalid launch time specified, time must be within 180 hours of the current time.

"; echo "

Launch time: " . gmstrftime("%b %d %Y %H:%M", $timestamp) . "
Current time: " . gmstrftime("%b %d %Y %H:%M", time()) . "

"; echo "

" . nl2br(print_r($_POST, true)) . "

"; footer(); exit(1); } if($_POST['initial_alt'] < -1000) { echo "

Invalid initial altitude specified, must be greater than -1000m.

"; footer(); exit(1); } // create lock file to prevent other users running the predictor at the same time $lockfile = fopen("lock", "w"); fclose($lockfile); $initial_zoom = "7"; $initial_lat = $_POST['lat']; $initial_lon = $_POST['lon']; if($_POST['float_time']>24*60*60) { echo "

Max float time allowed is 24 hours

"; footer(); exit(1); } $output = shell_exec("./one_off_prediction " . $_POST['lat'] . " " . $_POST['lon'] . " " . $_POST['initial_alt'] ." " . (float)$_POST['ascent'] . " " . $_POST['drag']*1.1045 . " " . $_POST['burst'] . " " . $timestamp . " " . $_POST['float_time']); if (substr_count($output, "ok") != 1) { echo "

Landing prediction returned with a (possibly cryptic) error:

"; echo "

" . nl2br($output) . "

"; footer(); unlink("lock"); exit(1); } $fp = fopen("valid_model_run", "r"); $gribyear = fread($fp, 4); $gribmonth = fread($fp, 2); $gribday = fread($fp, 2); $gribhour = fread($fp, 2); echo "

Using GRIB data from the " . $gribyear . "/" . $gribmonth . "/" . $gribday . " " . $gribhour . ":00 GMT model

"; $file = fopen("flight_path.csv", "r"); while (($data = fgetcsv($file)) != FALSE) { //print_r($data); $gmapsdata .= ",new GLatLng(" . $data[1] . "," . $data[2] . ")\n"; //print $data[1] . " " . $data[2] . " " . $data[3] . "
"; $land_timestamp = (float)$data[0]; $land_lat = $data[1]; $land_lon = $data[2]; if ((int)$data[3] > $maxalt) { $maxalt = (int)$data[3]; $apogee_lat = $data[1]; $apogee_lon = $data[2]; $burst_timestamp = (float)$data[0]; } } fclose($file); unlink("lock"); $lat1 = deg2rad($initial_lat); $lat2 = deg2rad($land_lat); $lon1 = deg2rad($initial_lon); $lon2 = deg2rad($land_lon); //$dist = 2*asin(sqrt((sin(($lat1-$lat2)/2))^2 + cos($lat1)*cos($lat2)*(sin(($lon1-$lon2)/2))^2)); $distkm = 6366.71 * acos(sin($lat1)*sin($lat2)+cos($lat1)*cos($lat2)*cos($lon1-$lon2)); $map_lat = ((float)$_POST['lat'] + (float)$land_lat)/2; $map_lon = ((float)$_POST['lon'] + (float)$land_lon)/2; $launchdate = gmstrftime("%b %d %Y %H:%M", $timestamp); $launchtime = gmstrftime("%H:%M", $timestamp); $landdate = gmstrftime("%b %d %Y %H:%M", $land_timestamp); $landtime = gmstrftime("%H:%M", $land_timestamp); $bursttime = gmstrftime("%H:%M", $burst_timestamp); $duration = gmstrftime("%H:%M", $land_timestamp - $timestamp); $time_into_model = (int)(($burst_timestamp - mktime($gribhour, 0, 0, $gribmonth, $gribday, $gribyear)) / 3600); $time_into_model = $time_into_model - ($time_into_model % 3); ?>

Launch: " . $initial_lat . ", " . $initial_lon . " - " . $launchdate; ?> GMT
Landing: " . $land_lat . ", " . $land_lon . " - " . $landdate; ?> GMT
Duration:
Distance:

KML File

GFS wind speed data overlay (knots):
mBar (approx. altitude):