'; } ?> '; $doDebug = false; // Enable Debugging $standAlone = false; // Displays outside Saratoga template $sector = 'car'; // Default sector type is set here $sector = 'umv'; // Default sector type is set here /* USE ONE of THESE for $sector! "pnw" is Pacific Northwest "nr" is Northern Rockies "umv" is Upper Mississippi Valley "cgl" is Great Lakes "ne" is Northeast "psw" is Pacific Southwest "sr" is Southern Rockies "sp" is Southern Plains "smv" is Southern Mississippi Valley "se" is Southeast "pr" is Puerto Rico The below $sectors WILL NOT WORK in the 'index.php' display: "CONUS" is Continental US "FD" is Full Disk "taw" is Tropical Atlantic-Wide "gm" is Gulf of Mexico "car" is Caribbean "eus" is U.S. Atlantic Coast "cam" is Central America "eep" is Equatorial Eastern Pacific "eus" is Eastern US "mex" is Mexico "nsa" is Northern South America "ssa" is Southern South America */ $satBand = 'GEOCOLOR'; // IMPORTAMT!!! Default image type is set here $satBandisNumeric = ($satBand!='GEOCOLOR'&&$satBand!='AirMass'&&$satBand!='Sandwich'&&$satBand!='DayCloudPhase'&&$satBand!='NightMicrophysics')?true:false; $satBand = $satBandisNumeric?($satBand<10?('0'.intval($satBand)):$satBand):$satBand; // $autoRefresh = true; // Use Autorefresh? true or false -- Determines whether AutoRefresh even appears // $autoRefreshTime = 10; // Number of minutes between autorefreshes. IMPORTANT: use 2, 3, 4, 5, 6, 8, 10, 15, 20, or 30 ONLY!!! // $autoRefreshOff = false; // Begin with Autorefresh Off? true or false -- 'OFF' or 'ON" $bgndColor = 'silver'; // Set HAniS Background Color Here $btnColor = 'darkslategray'; // Set Button Color here $btnTextColor = 'white'; // Set Button Text Color here $pauseSeconds = 2; // Pause on last image, in seconds $animRate = 25; // Frame Rate of animation: 5 is glacial, 10 is slow, 15 is leisurely, 20 is good, and 50 is fast - set with integer $numbImages = 20; // Number of Radar Images to Animate - 3 to around 25 $smoothingOn = true; // Enable image smoothing - new in HAniS 2.5 $checkFiles = false; // Check images before adding them to the filename list? $addTime = false; // Add date & time to images $addTimePixels = 70; // Add height for image date/times $wideScreen = false; $restrictWidth = true; // Width restriction is in effect $maxWidth = 1205; // Maximum width allowed /************************ End Parameters for 'Index.php' Embedding ********************/ $sectorTypes = array('standard', 'FD', 'CONUS','gm-eus-eep-cam-mex-car','taw-nsa-ssa','can'); // Pointers to the various possible image dimensions if ($sector=='FD') $ourSectorType = $sectorTypes[1]; // Logic to select our array of dimensions else if ($sector=='CONUS') $ourSectorType = $sectorTypes[2]; else if ($sector=='cam'||$sector=='eus'||$sector=='car'||$sector=='eep'||$sector=='gm'||$sector=='mex') $ourSectorType = $sectorTypes[3]; else if ($sector=='taw'||$sector=='nsa'||$sector=='ssa') $ourSectorType = $sectorTypes[4]; else if ($sector=='can') $ourSectorType = $sectorTypes[5]; else $ourSectorType = $sectorTypes[0]; $sectorDimensions = array('width','height'); $satBandSectors = array( // Array of arrays of possible image dimensions 'standard'=>array( // The US Regional Image Dimensions 'widthA'=>1200, 'iframeWidthA'=>1242, 'heightA'=>1200, 'iframeHeightA'=>1200, 'widthB'=>300, 'iframeWidthB'=>320, 'heightB'=>300, 'iframeHeightB'=>240), 'FD'=>array( // The Full Disk Dimensions 'widthA'=>678, 'iframeWidthA'=>678, 'heightA'=>678, 'iframeHeightA'=>678, 'widthB'=>339, 'iframeWidthB'=>339, 'heightB'=>339, 'iframeHeightB'=>339), 'CONUS'=>array( // The Continental US Image Dimensions 'widthA'=>1250, 'iframeWidthA'=>1292, 'heightA'=>750, 'iframeHeightA'=>750, 'widthB'=>625, 'iframeWidthB'=>625, 'heightB'=>375, 'iframeHeightB'=>375), 'gm-eus-eep-cam-mex-car'=>array( // The Gulf of Mexico, Caribbean, Eastern US Image Dimensions 'widthA'=>1000, 'iframeWidthA'=>1042, 'heightA'=>1000, 'iframeHeightA'=>1000, 'widthB'=>500, 'iframeWidthB'=>500, 'heightB'=>500, 'iframeHeightB'=>500), 'taw-nsa-ssa'=>array( // The Tropical Atlantic - Wide Dimensions 'widthA'=>900, 'iframeWidthA'=>942, 'heightA'=>540, 'iframeHeightA'=>540, 'widthB'=>450, 'iframeWidthB'=>450, 'heightB'=>270, 'iframeHeightB'=>270), 'can'=>array( // Canadian Dimensions 'widthA'=>1125, 'iframeWidthA'=>1167, 'heightA'=>560, 'iframeHeightA'=>602, 'widthB'=>560, 'iframeWidthB'=>602, 'heightB'=>280, 'iframeHeightB'=>322) ); /* Debug Code */ if ($doDebug) { var_dump($satBandSectors); var_dump($satBandSectors['standard']['iframeHeightB']); foreach ($satBandSectors as $key1=>$value1) { foreach ($value1 as $key=>$value) echo '$key1: '.$key1.'=> '.$key.': '.$value.'
'; } echo '$ourSectorType: '.$ourSectorType.'
'; var_dump($satBandSectors[$ourSectorType]['iframeHeightB']); // exit; } /* End Debug Code */ $imageWidth = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'widthA':'widthB']; $iframeWidth = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'iframeWidthA':'iframeWidthB']; $imageHeight = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'heightA':'heightB']; $iframeHeight = $satBandSectors[$ourSectorType][($wideScreen||$standAlone)?'iframeHeightA':'iframeHeightB']; $ratioAdjust = 1; $ratioAdjust2 = 1; $maxHeight = $imageHeight; if (240<$imageHeight) { $ratioAdjust = $iframeHeight/$imageHeight; $iframeHeight = ceil($iframeHeight*$ratioAdjust); } if (320<$imageWidth) { $ratioAdjust2 = $iframeWidth/$imageWidth; $iframeWidth = ceil($iframeWidth*$ratioAdjust2); } /* Debug Code */ if ($doDebug) { $debugText .= '$satBand: '.$satBand.', $sector: '.$sector.', $ourSectorType: '.$ourSectorType.'
'; $debugText .= '$imageWidth: '.$imageWidth.', $iframeWidth: '.$iframeWidth.', $imageHeight: '.$imageHeight.', $iframeHeight: '.$iframeHeight.', $ratioAdjust: '.$ratioAdjust.', $ratioAdjust2: '.$ratioAdjust2.'
'; // exit; } /* End Debug Code */ ?> Starting \'handiv\' declaration
'; } $fileNameList = ''; $fileTimes = ''; get_file_names($sector,', ',$imageWidth,$imageHeight); if ($doDebug) $debugText .= '
Raw FilenameList:
'.$fileNameList.'
'; $fileNames = $fileNameList.' '; if ($doDebug) { $debugText .= '
Filenames:
'.$fileNames.'
'; $debugText .= 'Filetimes: '.$fileTimes.'
'; } if ($fileNames=='Satellite Images Currently Unavailable!'||$fileNames=='Too Many Images Requested') { print ('
'.$fileNames.'
'); exit; } $iframeHeight += $addTime?$addTimePixels:45; ?> ';?>
';?> 100) { list($jImageBase,$jFilenames,$JSONerrorMessage) = decode_GOES_json($rawJSON,$image_Width,$image_Height,$numbImages); } else { list($jImageBase,$jFilenames,$JSONerrorMessage) = array('',array(),''); } # end- use JSON for images filename list $imageNumber = count($jFilenames); if ($imageNumber<$numbImages) { if ( $imageNumber==0) { $fileNameList = 'Satellite Images Currently Unavailable!'; return ; } else if ($imageNumber<$numbImages) { $fileNameList = 'Too Many Images Requested'; return; } } else { $imageFile = array(); $imageFile = $jFilenames; $image_base = $jImageBase; for ($i=0; $i<$numbImages; $i++) { # changed to start at 0 $image = $imageFile[$i].($i<($numbImages-1)?$separator:' '); $timeString = substr($imageFile[$i],0,11); $ourYear = substr($timeString,0,4); $dayofYear = (substr($timeString,4,3)); $minutes = substr($timeString,7,2); $seconds = substr($timeString,9,2); $date2epoch =mktime(0, 0, 0, 1, 1, $ourYear); // Find the seconds from 1/1/1970 to the current year if ($doDebug) { $debugText .= '$date2epoch: '.$date2epoch.'
'; } // The PHP Day of the year is one less than the nesdis.noaa day of year - PHP begins with day 0, nesdis.noaa begins with day 1 $imageTime = $date2epoch+(($dayofYear-1)*86400)+($minutes*60)+$seconds; // Add the year + the day of the year + minutes + seconds $ourDayMonth = date("M_j,",$imageTime); $hourMinute = substr($timeString,7,4); if ($doDebug) { $debugText.= '$timeString: '.$timeString.', $imageTime: '.$imageTime.', $ourYear: '.$ourYear.', $ourDayMonth: '.$ourDayMonth.', $hourMinute: '.$hourMinute.'
'; $debugText .= 'date("M j, Y",$imageTime): '.date("M j, Y",$imageTime).'
'; } $fileTimes .= ($addTime?(date("j M Y",$imageTime).' '.$hourMinute.' Zulu,'):''); $fileNameList .= $image; if ($doDebug) { $debugText .= $image; } } } } /* end get_file_names */ // ------------------------------------------------------------------ /* Begin Function get_data */ function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't verify peer certificate curl_setopt($ch, CURLOPT_TIMEOUT, 8); // data timeout curl_setopt($ch, CURLOPT_NOBODY, false); // set nobody curl_setopt($ch, CURLOPT_HEADER, true); // include header information curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (US Satellites/1.1, www.gwwilkins.org)'); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } /* End Function get_data */ // ------------------------------------------------------------------ function checkExternalFile($url) { global $doDebug; global $debugText; $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FAILONERROR,true); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true); // catch output (do NOT print!) curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); $response = curl_exec($ch); $badCURL = curl_error($ch); $retCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($doDebug) { print curl_error($ch); $debugText .= '$CURL: '.($badCURL?$badCURL:'good').', $response: '.($response!==false?'true':'false').', $retCode: '.$retCode.'-File '.($retCode==200?'exists':'is absent').'
'; } curl_close($ch); return $retCode; } // ------------------------------------------------------------------ /* Begin get_JSON_filename */ function get_JSON_filename($theSector,$satBand) { # code by K. True - saratoga-weather.org # produce the JSON filename to use based on the sector and band # $JF = 'https://cdn.star.nesdis.noaa.gov/GOES16/catalogs/GOES16/'; /* base for GOES17 JSON files. */ if($theSector == 'CONUS') { $JF .= 'CONUS_'.(string)$satBand.'_catalog.json'; } elseif($theSector == 'FD') { $JF .= 'FD_'.(string)$satBand.'_catalog.json'; } else { $JF .= 'SECTOR_'.(string)$satBand.'_'.(string)$theSector.'_catalog.json'; } return($JF); } // end get_JSON_filename // ------------------------------------------------------------------ /* Begin decode_GOES_json */ function decode_GOES_json($rawJSON,$width,$height,$numImages) { # code by K. True - saratoga-weather.org # decode the JSON data for base URL and array of last numImages available # $tImageBase = ''; $tFilenames = array(); $JSON = json_decode($rawJSON,true); // decode to array, not object $tError = json_last_error_msg(); if(!isset($JSON['meta']['location']['folder'])) { return(array($tImageBase,$tFilenames,$tError .' and no meta in JSON')); // empty return as not the JSON we want } else { $tImageBase = $JSON['meta']['location']['folder']; // base URL for images } if(isset($JSON['images'][$width.'x'.$height][0]) ) { // got images. $tArray = $JSON['images'][$width.'x'.$height]; $tFilenames = array_slice($tArray,-$numImages); } return(array($tImageBase,$tFilenames,$tError)); } // end decode_GOES_json // ------------------------------------------------------------------ /* Begin rfile_exists - In Reserve - Not Currently Used */ function rfile_exists($address) { global $doDebug; global $debugText; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$address); curl_setopt($ch,CURLOPT_NOBODY,1); curl_setopt($ch,CURLOPT_FAILONERROR,1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $fileExists = curl_exec($ch); if ($doDebug) { $debugText .= '$fileExists-r: '.($fileExists?'absent':'exists').'
'; } if($fileExists !== FALSE) { curl_close($ch); return true; } curl_close($ch); return false; } /* End rfile_exists */ // ------------------------------------------------------------------ ?>