STEREO/SEPT Data Pages
STEREO/SEPT Pitch Angle Distribution -  IEAP - CAU Kiel (Germany)                    TEST VERSION
\"Plot

"; $couvi=webcounter('./wdata/countervi.txt',"0"); $cou=webcounter('./wdata/counter.txt',1); //AND the plot counter is NOT increased: } else { $couvi=webcounter('./wdata/countervi.txt',1); $cou=webcounter('./wdata/counter.txt',0); //the plot counter is increased //prepare the final command line arguments (if the formular has been called already using plot button) if ($particle=="ele") { $b1=$bin1e; $b2=$bin2e; } else{ $b1=$bin1i; $b2=$bin2i; } //echo "bins are".$b1.",".$b2; if ($b1==$b2) { //only one bin is a special case $bins=$b1; } else{ if ($b1<=$b2) { //valid bin choice $bins=$b1; $b0=$b1+1; for ($i = $b0; $i<=$b2 ; $i++) { $bins=$bins.'_'.$i; } }else{ //invalid bin choice $error="Invalid energy bin choice"; } } //echo "final bins are ".$bins; //$bins='5_6_7'; $date1=$year1.'-'.$month1.'-'.$day1.' '.$hour1.':'.$min1; $date2=$year2.'-'.$month2.'-'.$day2.' '.$hour2.':'.$min2; $stamp1=validatedate($year1,$month1,$day1,$hour1,$min1,$valid1); $stamp2=validatedate($year2,$month2,$day2,$hour2,$min2,$valid2); $interval=($stamp2-$stamp1)/86400.; $minu=1./1440.; if ($interval < $minu) {$error="Time interval too small (at least 1 minute required)";}; if ($interval > 3) {$error="Time interval too long (maximum 3 days)";}; if ($valid1==false) {$error="Invalid start time stamp";}; if ($valid2==false) {$error="Invalid final time stamp";}; if ($error<>false) { echo $error; } else { //PARAMETERS PASSED ARE OK=>PROCEED TO CALL IDL AND SHOW THE RESULT //first we prepare the command line arguments in a suitable form for idl routine //WRONG FORMAT:$filename=$date1.'_'.$date2.'_'.$spacecraft.'_'.$particle.'_'.$normalization.'_'.$noxerrorbars.'_'.$bins.'_'.$kindofplot.'_'.$onlycenters_passed.'_'.$noextrapolation.'_'.$nbinsx.'_'.$plainhistogram; $key=time(); $filename=$year1.$month1.$day1."_k".$key; if ($xerrorbars=='1') {$noxerrorbars='0';} else {$noxerrorbars='1';}; //$args=escapeshellcmd($date1.' '.$date2.' '.$spacecraft.' '.$particle.' '.$normalization.' '.$noxerrorbars.' '.$bins.' '.$filename.' '.$kindofplot.' '.$onlycenters_passed.' '.$noextrapolation.' '.$nbinsx.' '.$plainhistogram.' ').$datapath; $args=$date1.' '.$date2.' '.$spacecraft.' '.$particle.' '.$normalization.' '.$noxerrorbars.' '.$bins.' '.$filename.' '.$kindofplot.' '.$onlycenters_passed.' '.$noextrapolation.' '.$nbinsx.' '.$plainhistogram.' '.$datapath; //the command escapeshellcmd is only used as saftety filter (anti-escape commands) //$args='2010-08-01 01:00 2010-08-01 13:01 A ele 0 0 5_6_7 output 0 0 1 8 0 D:\htdocs\stereo\data\sept'; //echo "

Command line arguments are: $args

"; echo "

Processing data, please wait......"; echo str_pad('',4096)."\n"; flush(); //sleep(2); //INVOKE IDL //$idl='@C:\ITT\IDL70\bin\bin.x86\idlrt.exe padsweb.sav -novm'; $idl='/usr/local/bin/idl -rt=padsweb.sav -novm'; $executed = exec("$idl -args $args",$outp,$retval); echo "Ready

"; if ($kindofplot==0) { $sufix="_padcolor.png"; $sufixps="_padcolor.eps"; } else { if ($kindofplot==1) { $sufix="_padseries.png"; $sufixps="_padseries.ps"; } else { if ($kindofplot==2) { $sufix="_padcumul.png"; $sufixps="_padcumul.eps"; } } } //echo "

$outp

";echo "

$retval

"; //echo $filename; $asciifile='output/'.$filename.'.dat'; $pngfile='output/'.$filename.$sufix; $psfile='output/'.$filename.$sufixps; $aaa=file_exists($asciifile); //echo "checking output".$aaa; if (file_exists($asciifile)) { echo "

click here to download a p.a.d. ASCII file corresponding to this period

"; } else { echo "

Warning: problem creating ASCII file. Please check input parameters and data availability

"; } if (file_exists($psfile)) { echo "

click here to download the plot in postscript format

"; } else { echo "

Warning: problem creating postscript file. Please check input parameters and data availability

"; } if (file_exists($pngfile)) { $twelvemin=12./1440; if (($kindofplot==1) and ($interval > $twelvemin)){ echo "

Warning: More than 12 minutes requested, the image below shows only the last page. For the complete series of p.a.d. plots, please download the ps file (multiple pages)

"; } //echo "
"; echo "
\"Plot
"; echo "
Results are in the spacecraft frame
"; } else { echo "

Warning: problem creating image file. Please check input parameters and data availability

"; } } } //$executed = exec("C:\ITT\IDL70\bin\bin.x86\idlrt.exe padsweb.sav -novm -args 2010-08-18 10:00 2010-08-18 20:00 A ele 0 0 5_6_7 output 0 0 1 8 0 D:\htdocs\stereo\data\sept",$output,$retval); ?>
Raúl Gómez-Herrero  Nominal data coverage starts on Jan 17, 2007.  Data available through March 2012
"; ?>
CAU          IEAP          ETPH          STEREO Science Center          PLASTIC          IMPACT Data Portal          MAG          SEP Suite          SEPT Home

$maxold) { //echo "deleting $file"; unlink($file); $number=$number+1; } } return $number; } //===================================================== function foot1() //===================================================== //dumps a simple foot to the page and exits { echo "

Generated on: ".date('Y-m-d')."

"; //echo "

<-- Back to the plot form

"; //echo "
"; //echo ""; //echo "
"; //$null=file_put_contents('log.txt',"\r\n".'Result: **ERROR 1**',FILE_APPEND); echo "

Plot created

"; //exit(); return; } //===================================================== function formatdate($dat,&$doy,&$year,$command) //===================================================== //this function returns (byreference) the doy and year //if dd-mm format is detected, then doy is calculated //The argument $doy must contain the original string //introduced by the user in the formular //the argument $year is used only to return the year // //In addition, the corresponding julian date is returned { //php 4 compatible $firstpos=strpos($dat,'-'); $lastpos=strrpos($dat,'-'); if (($firstpos === false) or ($lastpos === false)) { //case (a): wrong format $doy=-1; $year=-1; } elseif ($lastpos === $firstpos){ //case (b) format is doy-YYYY $year=substr($dat,$firstpos+1); $doy=substr($dat,0,$firstpos); } else { //case (c) format is mm-dd-yyyy $month=substr($dat,0,$firstpos); $day=substr($dat,$firstpos+1,$lastpos-$firstpos-1); $year=substr($dat,$lastpos+1); $doy=daytodoy($day,$month,$year); } if ($command === "next") { $doy=$doy+1; } else if ($command === "previous") { $doy=$doy-1; } else if ($command === "nextbigstep") { $doy=$doy+10; } else if ($command === "previousbigstep") { $doy=$doy-10; } //Finally we correct from inconsistencies like doy 367 or -1 or 366 on non-leap year //We achieve this adding doy to 1/1/year in julian dates and converting to gregorian and back again //echo "month,day,year,doy----first,last=".$month." ".$day." ".$year."---".$doy." ".$firstpos." ".$lastpos; $juli=gregoriantojd("01","01",$year)+$doy-1; $a=jdtogregorian($juli); list($mo,$da,$ye) = explode('/',$a,3); $doy=gregoriantojd($mo,$da,$ye)-gregoriantojd('01','01',$ye)+1; $year=$ye; return $juli; } //===================================================== function daytodoy($day,$month,$year) //===================================================== //conversion from day/month/year to day of the year //if something fails, the returned value is <0 and can be recognised later { $julian = gregoriantojd($month,$day,$year); $base = gregoriantojd('01','01',$year); $dayofyear=$julian-$base+1; return $dayofyear; } //===================================================== function totaldays($ye1,$do1,$ye2,$do2) //===================================================== //total number of days from start&end years and days of the year { $julian1 = gregoriantojd('01','01',$ye1)+$do1; $julian2 = gregoriantojd('01','01',$ye2)+$do2; $tota=$julian2-$julian1; // echo 'dayofyear'.$dayofyear; return $tota; } //===================================================== function webcounter($file,$whattodo) //===================================================== //Just a unefficient counter of visits //value is stored in a file called counter.txt //if the file does not exist, it will be created //the file simply stores: creation date#counter number //if there are exactly simultaneous file access, probably the counter //will be reset or one of them will not be counted!!(?)) //the param whattodo can be set to 1 if we want only to read the current value of the counter without changing anything { $counterstro=file_get_contents($file,FALSE); if (strlen($counterstro)<10){ $counter='1'; $counterdate=date('Y-m-d'); } else { $posi=strpos($counterstro,"#"); $counter=substr($counterstro,$posi+1); $counterdate=substr($counterstro,0,$posi); } if (($posi<=0) or ($posi>10)){ //Counter file corrupted???==>proceed in the same way than no file. This should never happen.... $counter='1'; $counterdate=date('Y-m-d'); } if ($whattodo === 1) { return $counter; } else { $counter=$counter+1; $counterstr=$counterdate."#".$counter; // This needs php5, replaced by open,write,close $null=file_put_contents('./wdata/counter.txt',$counterstr); $fd = fopen($file,"w+"); fwrite($fd,$counterstr); fclose($fd); return $counter; } } //===================================================== function logfile($file,$extra) //===================================================== //This fuction appends information to a logfile //If the file does not exit, it is created { $datt=date("m.d.y,H:i:s"); $logstr=$datt.' | '.'QUERY: '.$extra.' ||| Lang_'.$_SERVER["HTTP_ACCEPT_LANGUAGE"].' |Rem_Add_'.$_SERVER["REMOTE_ADDR"].' | Rem_host_'.$_SERVER["REMOTE_HOST"].' | Fwd_for_'.$_SERVER["HTTP_X_FORWARDED_FOR"].' | IP_'.$_SERVER["HTTP_CLIENT_IP"].' | Ref_'.$_SERVER["HTTP_REFERER"].' | host_'.$_SERVER["HTTP_HOST"].' | Agent_'.$_SERVER["HTTP_USER_AGENT"]."\r\n"; $fd = fopen($file,"a+"); fwrite($fd,$logstr); fclose($fd); return "OK"; } //===================================================== function createdroplist($listname,$values,$labels,$selectedvalue,$default,$title,$tama,$width) //===================================================== //creates an html form droplist //optionally, if an element with the value $selectedvalue is found, //it will be preselected { $lastelement=count($values)-1; if ((isset($selectedvalue) === false) or (strlen($selectedvalue) === 0)) { $selectedvalue=$default; } if (isset($tama) === false) { $sizz="1"; } else { //$sizz=count($values); $sizz=$tama; } //Extra string passed (e.g. to auto-submit when the droplist changes) //in this case we activate the 1) form is sent when the droplist changes. //2) the name of the control (droplist) sending the form is stored in a hidden field to restore the focus whe the new instance is loaded //$extra="onchange=\"document.septplots.wheretofocus.value ='".$listname."'; document.septplots.submit();\""; echo ""; return; } //===================================================== function createradiobuttons($listname,$values,$labels,$selectedvalue,$default,$title,$useless) //===================================================== //like createdroplist, but creates a set of radio buttons in the same line, { $lastelement=count($values)-1; if ((isset($selectedvalue) === false) or (strlen($selectedvalue) === 0)) { $selectedvalue=$default; } //Extra string passed (e.g. to auto-submit when the droplist changes) //in this case we activate the 1) form is sent when the droplist changes. //2) the name of the control (droplist) sending the form is stored in a hidden field to restore the focus whe the new instance is loaded //echo " $labels[$i]   "; } else { echo " $labels[$i]   ";} } return; } //===================================================== function checkvariable($postname,&$fail,$defaultvalue) //===================================================== { if (isset($_POST[$postname])) { $value=$_POST[$postname]; //fail remains unchanged (passed by ref) //echo "parameter $postname FOUND!!
"; } else { //echo "Failed to find parameter $postname
"; $fail="nopars"; $value=$defaultvalue; } return $value; } //===================================================== function checkoptionalvariable($postname,$defaultvalue) //===================================================== { if (isset($_POST[$postname])) { $value=$_POST[$postname]; //fail remains unchanged (passed by ref) //echo "parameter $postname FOUND!!
"; } else { //echo "Failed to find OPTIONAL parameter $postname
"; $value=$defaultvalue; } return $value; } //===================================================== function validatedate($year,$month,$day,$hour,$min,&$valid) //===================================================== { $date=$year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00'; $stamp=strtotime($date); $valid=checkdate($month,$day,$year); if (($hour<0) or ($hour>24)) {$valid=false;}; if (($min<0) or ($min>59)) {$valid=false;}; if ($year<2006){$valid=false;}; return $stamp; } //END //END ?>