24 hours of e-VLBI/Demo
This page displays cumulative on-the-fly generated plots of the selected type.
Approximately every 5 minutes a new image is generated, incorporating all the data
collected so far; they are being being built up as the experiment progresses.
// we have a basic 'schedule' - a mapping
// of which source is observed at which UT
include 'schedule.php';
function curPageName() {
return "./".substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
function greytext($t) {
return "$t";
}
// replaces funny characters in sourcenames to not-so-funny-characters
// so it can be used in regexes
function escape_chars($s) {
$s1 = ereg_replace("\+", "\\+", $s);
$s2 = ereg_replace("\-", "\\-", $s1);
return $s2;
}
$sched = new Schedule;
// for now basedate is fixed:
// the schedule starts on Jan. 14th 2009, 08:00UT
// Note: we compress it as much as we can - as long as
// we keep finding the last source we keep adding to
// the end-time
$compute_time = create_function('$h, $m',"return gmmktime(\$h, \$m, 0, 1, 1, 1970);");
$actsrc = null;
$actstart = null;
$actlen = 0;
if( ($sf = file("./SCHEDULE"))!=false ) {
foreach ($sf as $lnum => $line) {
// check if it's a refdate line
list($day, $month, $year) = sscanf($line,"RDATE %d/%d/%d");
if( isset($day) && isset($month) && isset($year) ) {
//echo "Set REFDATE to $day/$month/$year\n";
// Create the new time-computer
$compute_time =
create_function('$h, $m',
"return gmmktime(\$h,\$m,0,$month,$day,$year);");
continue;
}
// it may be a "scandefinition"
list($h, $m, $src) = sscanf($line, "%02d:%02d %s");
// if it's not, bugrit!
if( !(isset($h) && isset($m) && isset($src)) )
continue;
// Ok, it certainly looks like one.
// Compute the actual time and see if we need to
// initialize
$thistime = $compute_time($h, $m);
if( !$actsrc ) {
// not initialized yet - do it and move on
$actsrc = $src;
$actstart = $thistime;
continue;
}
// we can unconditionally do this.
// the current time acts both as endtime
// for the previous as well as start of the
// new scan, if a scan-change is detected.
$actlen = $thistime - $actstart;
// if src hasn't changed, we move on
if( $src==$actsrc )
continue;
// Found new source. First process old one ...
$sched->addScan( new Scan('IYA09C', $actsrc, $actstart, $actlen) );
// now, reset current scan
$actsrc = $src;
$actstart = $thistime;
$actlen = 0;
}
}
// If, after processing, a scan is left,
// process it. this could be handled more
// elegantly ... but it would require to associate
// a scanid to a scan so we can modify one that's
// already been added to the schedule [keeping
// a 'pointer' to the current scan and updating
// it's end-time as we find successive equal scans]
if( $actsrc && $actstart && $actlen )
$sched->addScan( new Scan('IYA09C', $actsrc, $actstart, $actlen) );
// dummy scan ...
if( isset($us) )
$sched->addScan( new Scan('IYA09C', 'dummy', gmmktime(), 10) );
//$sched->addScan( new Scan('IYA09C', '0234+285', gmmktime(), 10) );
if( isset($dbg) )
$sched->show(true);
if( isset($dbg) )
echo "GMT: ".date(DATE_RFC822, gmmktime())."\n"; // Find current scan based on current GMT time $scan = $sched->findScan( gmmktime() ); // Which hour of the experiment? // we only show images of the current source if( isset($hr) ) $actual_hour = (int)$hr; if( !isset($actual_hour) || $actual_hour<0 || $actual_hour>23 ) $actual_hour = 0; // the image types we support. default to "uv" //$types = array("uv", "map", "iuv", "imap"); $types = array("uv", "beam", "cal"); // the searchstrings to look for for a particular type $searchtp = array("uv" => "-uv-", "beam" => "-imap-", "-iuv-" => "-iuv-", "imap" => "-map-", "cal" => "ICLN" ); $defaulttype = $types[0]; $type = $defaulttype; // some explanation of the types // call with "tp=<>" to change from default // that is: if it's a recognized (searchable) type! //if( isset($tp) && in_array($tp, $types) ) if( isset($tp) && array_key_exists($tp, $searchtp) ) $type = $tp; // this is where the otf images go $dirname = sprintf("/www/evlbi.org/evlbi/otf-map/%02d", $actual_hour); // this is the url under which they can be reached $imgbaseurl = sprintf("http://www.evlbi.org/evlbi/otf-map/%02d", $actual_hour); // the images found will be stuffed in here $imgs = array(); $usrsrc = null; // check to see if the directory exists if( is_dir($dirname) && $scan ) { // Inform usr about the "metadata" if( isset($us) && strcasecmp($scan->source,$us) ) $usrsrc = $us; echo "
\n";
echo "";
echo "$type";
echo " for ".($usrsrc?$usrsrc:$scan->source)." in $scan->experiment";
echo "";
echo "";
// other types?
$n = 0;
$othertp = curPageName()."?hr=${actual_hour}";
if( $usrsrc )
$othertp .= "&us=$usrsrc";
for($tpcnt=0; $tpcnt$otp";
}
echo $str;
$n++;
}
echo " ";
echo "";
echo "
\n";
// set the prev/nxt buttons
$baseurl = curPageName()."?";
$baseurl .= (($type!=$defaulttype)?("tp=$type&"):(""));
if( $usrsrc )
$baseurl .= "us=$usrsrc&";
$baseurl .= "hr=";
$begin = greytext("|<");
$prevest = greytext("<<");
$previmg = greytext("<");
$nextimg = greytext(">");
$nextest = greytext(">>");
$end = greytext(">|");
if( $actual_hour>2 )
$begin = "|<";
if( $actual_hour>1 )
$prevest = "<<";
if( $actual_hour>0 )
$previmg = "<";
if( $actual_hour<23 )
$nextimg = ">";
if( $actual_hour<22 )
$nextest = ">>";
if( $actual_hour<21 )
$end = ">|";
?>
echo $begin;?> | echo $prevest;?> | echo $previmg;?> | printf("%02d", $actual_hour);?>:00 to printf("%02d", $actual_hour+1);?>:00 | echo $nextest;?> | echo $end;?> |
$tptext[$type]
";
?>
// cool! examine its contents!
$srch_src = ($usrsrc?$usrsrc:$scan->source);
$srch_tp = "invalid";
if( array_key_exists($type, $searchtp) )
$srch_tp = $searchtp[$type];
$d = opendir($dirname);
while( ($f=readdir($d))!=false ) {
// if it seems to be of the current source and the
// requested type, append it's name to the list
//if( ereg($srch_src, $f) && ereg($srch_tp, $f) ) {
if( stripos($f, $srch_src)!==false && stripos($f, $srch_tp)!==false )
$imgs[] = $f;
}
}
// sort the array in our own order .. *gah*
// the last four digits of the name is the time of the
// image.
$simgs = array();
foreach($imgs as $im) {
$dotpos = strrpos($im, '.');
if( $dotpos===false || $dotpos<4 )
continue;
$tmstr = substr($im, $dotpos-4, 4);
list($h, $m) = sscanf($tmstr, "%02d%02d");
$simgs[$h*60+$m] = $im;
}
ksort($simgs, SORT_NUMERIC);
$imgs = $simgs;
//sort($imgs, SORT_NUMERIC);
?>
$tm \n"; echo ""; echo ""; echo "\n"; echo " | \n";
}
// close row if there was one
if( count($imgs) )
echo "