|
//
// this function prints out an address and a last modifed line to the open file
// specified by giving the pointer $fp
//
// Variables needed:
// $fp: valid file handle to a file open in write mode
//
// Written by Suzanne Aigrain on 15-Dec-2000
function address_date($fp)
{
$pagemaker="Cambridge XMMSSC team";
$email="wmy@ast.cam.ac.uk";
$st=fputs($fp,"
$pagemaker <$email>\n");
// $filemod = filemtime("~xmmssc/public_html/xidops/fields_status.txt");
$filemod = filemtime("/home/xmmssc/public_html/xidops/fields_status_new.txt");
$filemodtime = date("F j Y h:i:s A", $filemod);
$st=fputs($fp,"Based on: \"~xmmssc/public_html/xidops/fields_status.txt\", last modified $filemodtime \n");
}
?>
// This routine creates a link to the file $file from the file handled by $pt
// checking first if $file exists and if it doesnt it creates it
// with the message: Data not yet processed. etc...
// Returns true if sucessful (ie file was there or copying worked, false
// otherwise
//
// Inputs:
// $full_path: name of file to check (to access it from the program calling
// the links routine)
// $rel_path: path to same file but from the file the link is placed into
// $pt: valid file handle to a file open for writing
// $text: string, containing linked text
//
// Calls:
// ch_page_exists.php
//
// Written by Suzanne Aigrain on 05-Jan-2001
function links($pt,$full_path,$rel_path,$text)
{
// include($PHP_MYLIB."ch_page_exist.php");
if (ch_page_exist($full_path))
{
$try=fputs($pt,"".$text."");
}
else
{
$try=fputs($pt,"".$text."");
}
return $try;
}
// This routine checks if a file exists and if it doesnt it creates it
// with the message: Data not yet processed. etc...
// Returns true if sucessfule (ie file was there or copying worked, false
// otherwise
//
// Inputs:
// $name: name of file to check (full path if required)
//
function ch_page_exist($name)
{
if (! (file_exists($name)))
{
$try=is_numeric("ab");
}
else
{
$try=is_numeric(1.0);
}
return $try;
}
?>
// This function creates an index according to the value of its input
// (sorts by Right Ascension, Field name or WFC data status)
// If sorting by Field name, use alphabetical order. Fields that start with
// numerical characters come before letters.
// If sorting by RA, use 1st four characters (hh mm) to create integer between
// 0000 and 2359, and sort by increasing RA. If 2 fields have the same use
// field name.
// If sorting by WFC status, give 1 per band with data exisiting - gives
// integer between 0 and 5. Then give 1 if merged data, 0 if not
// Inputs:
// $sort: what to sort on
// $ra: string array with ra of field centre in hh mm ss.s
// $field: string array with field names
// $wfc: multidimensional array containing info about wfc data
//
// Written by Suzanne Aigrain on 05-Jan-2001
// Modified on 07-Feb-2001 to sort by increasing RA
function srt_fields($sort,$ra,$field,$wfc)
{
// get rid of 1st line which contains headers
$line1=array_shift($ra);
$line1=array_shift($field);
$line1=array_shift($wfc);
// We calculate integer arrays which will be used to do the sorting
foreach($ra as $rak => $ran)
{
// calculate scores for WFC data
$wfcnow=$wfc[$rak];
$me=0;
$sc=0;
if ($sort === "WFC data status")
{
if (strpos($wfcnow[0],"N")!==0)
{
if (strpos($wfcnow[0],"S")!==0) $me+=2;
else $me+=1;
}
if (strpos($wfcnow[1],"N")!==0)
{
if (strpos($wfcnow[1],"S")!==0) $sc+=2;
else $sc+=1;
}
if (strpos($wfcnow[2],"N")!==0)
{
if (strpos($wfcnow[2],"S")!==0) $sc+=2;
else $sc+=1;
}
if (strpos($wfcnow[3],"N")!==0)
{
if (strpos($wfcnow[3],"S")!==0) $sc+=2;
else $sc+=1;
}
if (strpos($wfcnow[4],"N")!==0)
{
if (strpos($wfcnow[4],"S")!==0) $sc+=2;
else $sc+=1;
}
if (strpos($wfcnow[5],"N")!==0)
{
if (strpos($wfcnow[5],"S")!==0) $sc+=2;
else $sc+=1;
}
$first=$me+$sc*10;
// use RA as second order sorting
$second=substr($ran,0,2)*60.0*15 + substr($ran,3,2);
// specify ascending or descending, numeric or string
$so1=SORT_DESC;
$st1=SORT_NUMERIC;
$so2=SORT_ASC;
$st2=SORT_NUMERIC;
}
elseif($sort === "Field name")
{
$first=$field;
$second=0;
// specify ascending or descending, numeric or string
$so1=SORT_ASC;
$st1=SORT_STRING;
$so2=SORT_ASC;
$st2=SORT_NUMERIC;
}
// default is RA
else
{
// get ra hh, mm, don't use seconds for sorting
$first=substr($ran,0,2)*60.0*15 + substr($ran,3,2);
// use field name as second
$second=$field[$rak];
// specify ascending or descending, numeric or string
$so1=SORT_ASC;
$st1=SORT_NUMERIC;
$so2=SORT_ASC;
$st2=SORT_STRING;
}
$ff[]=$first;
$ss[]=$second;
$list[]=$rak+1;
}
// Use array_multisort to sort it by 1st, second, and to order the keys
// accordingly, i.e. the $list array is included so that it is rearranged too
array_multisort($ff,$so1,$st1,$ss,$so2,$st2,$list,SORT_NUMERIC,SORT_ASC);
return $list;
}
Based on: /home/xmmssc/public_html/xidops/fields_status.txt , last modified September 17 2002 11:00:05 AM