Plot Object Positions on the extended WHDF
<%
if(!$_POST[submit])
{
%>
<%
}
else
{
if($_POST[rmag_max]=="") $_POST[rmag_max]=26.3;
if($_POST[rmag_min]=="") $_POST[rmag_min]=10.0; if($_POST[types]==1)
$type_select=""; if($_POST[types]==2) $type_select="and (kn=2 or kn=0)";
if($_POST[types]==3) $type_select="and (kn=5 or kn=7 or kn=10)";
if($_POST[types]==4) $type_select="and kn=0";
if($_POST[types]==5) $type_select="and kn=2";
if($_POST[types]==6) $type_select="and kn=7";
if($_POST[types]==7) $type_select="and (kn=5 or kn=10)";
if($_POST[xray]=="y") $type_select=$type_select." and xray=1 ";
if($_POST[z_low]=="") $_POST[z_low]=-99.;
if($_POST[z_high]=="") $_POST[z_high]=99.;
if($_POST[z_show]=="y") $zextra="and redshift!=-1";
$z_select="and (redshift>$_POST[z_low] and redshift<$_POST[z_high] $zextra) ";
if($_POST[umr_blue]=="") $_POST[umr_blue]=-99.99;
if($_POST[umr_red]=="") $_POST[umr_red]=99.;
if($_POST[umr_x]=="y") $umrx="or umr=99.99";
if($_POST[bmr_blue]=="") $_POST[bmr_blue]=-99.99;
if($_POST[bmr_red]=="") $_POST[bmr_red]=99.;
if($_POST[bmr_x]=="y") $bmrx="or bmr=99.99";
if($_POST[rmi_blue]=="") $_POST[rmi_blue]=-99.99;
if($_POST[rmi_red]=="") $_POST[rmi_red]=99.;
if($_POST[rmi_x]=="y") $rmix="or rmi=99.99";
if($_POST[rmz_blue]=="") $_POST[rmz_blue]=-99.99;
if($_POST[rmz_red]=="") $_POST[rmz_red]=99.;
if($_POST[rmz_x]=="y") $rmzx="or rmz=99.99";
if($_POST[rmh_blue]=="") $_POST[rmh_blue]=-99.99;
if($_POST[rmh_red]=="") $_POST[rmh_red]=99.;
if($_POST[rmh_x]=="y") $rmhx="or rmh=99.99";
$umr_select="and ((umr>$_POST[umr_blue] and umr<$_POST[umr_red]) $umrx) ";
$bmr_select="and ((bmr>$_POST[bmr_blue] and bmr<$_POST[bmr_red]) $bmrx) ";
$rmi_select="and ((rmi>$_POST[rmi_blue] and rmi<$_POST[rmi_red]) $rmix) ";
$rmz_select="and ((rmz>$_POST[rmz_blue] and rmz<$_POST[rmz_red]) $rmzx)";
$rmh_select="and ((rmh>$_POST[rmh_blue] and rmh<$_POST[rmh_red]) $rmhx)";
$username="nm";
$password="Nigel's DB";
$connect=mysql_connect("asts2.phyast.dur.ac.uk:3306",$username,$password);
print mysql_error();
$database="nm";
$query=mysql_db_query($database,"select * from whdfwide where rmag>$_POST[rmag_min] and rmag<$_POST[rmag_max] $z_select $type_select $umr_select $bmr_select $rmi_select $rmz_select $rmh_select order by rmag",$connect);
print mysql_error();
print "Number of objects plotted: ".mysql_num_rows($query);
print "
";
print "
";
$x=1024;$y=1024;
$margin=25;
$im=imagecreatetruecolor($x,$y);
$im2=imagecreatetruecolor($x,$y);
$textfont=4;
$numberfont=3;
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$background_color2 = ImageColorAllocate ($im2, 255,255,255);
imagefill($im,0,0,$background_color);
$line_color = ImageColorAllocate($im, 50, 50, 50);
$fill_color = ImageColorAllocate ($im, 100, 100,75);
$gal_color = ImageColorAllocate ($im, 200, 100,75);
$star_color = ImageColorAllocate ($im, 0, 0,255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
# ImageString ($im, $textfont, 0.2*$xwid+25, 0.025*$ywid+25, "Type = ".$_POST[types], $text_color);
imageline($im,$margin,$margin,$margin,$y-$margin,$line_color);
imageline($im,$margin,$margin,$x-$margin,$margin,$line_color);
imageline($im,$x-$margin,$margin,$x-$margin,$y-$margin,$line_color);
imageline($im,$margin,$y-$margin,$x-$margin,$y-$margin,$line_color);
if($_POST[submit]=="Show XY plot")
{
print "X v Y (pixels)
";
$querymax=mysql_db_query($database,"select max(x) as xmax, max(y) as ymax from whdfwide",$connect);
$rowmax=mysql_fetch_assoc($querymax);
$xmax=$rowmax[xmax];
$ymax=$rowmax[ymax];
$xstart=0;
$ystart=0;
while($row=mysql_fetch_assoc($query))
{
$xc=$margin+($x-2*$margin)*$row[x]/$xmax;
$yc=$margin+($y-2*$margin)*$row[y]/$ymax;
$fill_color=$gal_color;
if($row[kn]<3) $fill_color=$star_color;
imagefilledellipse($im,$xc,$yc,5,5,$fill_color);
}
$overlay=imagecreatefromjpeg("wide_bri_rot.jpg");
if(!$overlay) print "Error reading image";
$dim=getimagesize("wide_bri.jpg");
# imagecopyresampled($im2,$overlay,25,25,0,0,$x-50,$y-50,$dim[0],$dim[1]);
imagecopyresampled($im2,$overlay,23,22,$dim[0],0,$x-42,$y-35,-$dim[0],$dim[1]);
imagecopymerge($im,$im2,0,0,0,0,$x,$y,40);
} else
if($_POST[submit]=="Show BRI plot")
{
print "R-I v B-R
";
$xstart=-2;$xmax=3.5;$ymax=4.5;$ystart=-1;
while($row=mysql_fetch_assoc($query))
{
$xc=$margin+($x-2*$margin)*($row[rmi]-$xstart)/($xmax-$xstart);
$yc=($y-$margin)-($y-2*$margin)*($row[bmr]-$ystart)/($ymax-$ystart);
$fill_color=$gal_color;
if($row[kn]<3) $fill_color=$star_color;
imagefilledellipse($im,$xc,$yc,5,5,$fill_color);
}
} else
if($_POST[submit]=="Show UBR plot")
{
print "U-B v B-R
";
$xstart=-2.5;$xmax=3;$ymax=4.5;$ystart=-1;
while($row=mysql_fetch_assoc($query))
{
$xc=$margin+($x-2*$margin)*(($row[umr]-$row[bmr])-$xstart)/($xmax-$xstart);
$yc=($y-$margin)-($y-2*$margin)*($row[bmr]-$ystart)/($ymax-$ystart);
$fill_color=$gal_color;
if($row[kn]<3) $fill_color=$star_color;
imagefilledellipse($im,$xc,$yc,5,5,$fill_color);
}
} else
if($_POST[submit]=="Show BRH plot")
{
print "B-R v R-H
";
$xstart=-1;$xmax=4.5;$ymax=5.5;$ystart=0;
while($row=mysql_fetch_assoc($query))
{
$xc=$margin+($x-2*$margin)*($row[bmr]-$xstart)/($xmax-$xstart);
$yc=($y-$margin)-($y-2*$margin)*($row[rmh]-$ystart)/($ymax-$ystart);
$fill_color=$gal_color;
if($row[kn]<3) $fill_color=$star_color;
imagefilledellipse($im,$xc,$yc,5,5,$fill_color);
}
} else
if($_POST[submit]=="Show RIH plot")
{
print "R-I v I-H
";
$xstart=-2;$xmax=3.5;$ymax=4.5;$ystart=-1;
while($row=mysql_fetch_assoc($query))
{
$xc=$margin+($x-2*$margin)*($row[rmi]-$xstart)/($xmax-$xstart);
$yc=($y-$margin)-($y-2*$margin)*($row[rmh]-$row[rmi]-$ystart)/($ymax-$ystart);
$fill_color=$gal_color;
if($row[kn]<3) $fill_color=$star_color;
imagefilledellipse($im,$xc,$yc,5,5,$fill_color);
}
}
# x axis
$textfont=2;
for($i=$xstart;$i<=$xmax;$i++)
{
if($_POST[submit]=="Show XY plot"&&$i%250!=0) continue;
$xc=($i-$xstart)*($x-2*$margin)/($xmax-$xstart)+$margin;
# $i=sprintf('%s.0',$i);
imageline($im,$xc,$y-$margin,$xc,$y-$margin-5,$line_color);
ImageString ($im, $textfont, $xc-7, $y-$margin+2, $i, $text_color);
}
# y axis
for($i=$ystart;$i<=$ymax;$i++)
{
if($_POST[submit]=="Show XY plot"&&$i%250!=0) continue;
$yc=$y-(($i-$ystart)*($y-2*$margin)/($ymax-$ystart)+$margin);
imageline($im,$margin,$yc,$margin+5,$yc,$line_color);
ImageString ($im, $textfont, 0, $yc-5, $i, $text_color);
}
# imagefilledellipse($im,256,256,50,50,$fill_color);
$flag=imagejpeg($im,"/cos/d/nm/pubhtml/herschel/temp/test.jpg");
# print "F=".$flag;
# print "Completed";
print "
";
print "
\n";
}
%>