Index: trunk/ippMonitor/raw/warpProcessedExp_Images.php
===================================================================
--- trunk/ippMonitor/raw/warpProcessedExp_Images.php	(revision 28718)
+++ trunk/ippMonitor/raw/warpProcessedExp_Images.php	(revision 32366)
@@ -77,12 +77,10 @@
 
 if ($restricted == 0) {
-  if ("none" != "none") {
-    $WHERE = "$WHERE none";
-  }
+   $WHERE = "WHERE 0=1";
 }
 
 // get the result table count
 if (basic == "basic") {
-  $sql = "SELECT count(*) FROM fakeRun,camRun,chipRun,rawExp,warpRun LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE";
+  $sql = "SELECT count(*) FROM rawExp JOIN chipRun USING(exp_id) JOIN camRun USING (chip_id) JOIN fakeRun USING(cam_id) JOIN warpRun USING(fake_id) LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE";
 }
 
@@ -111,5 +109,5 @@
 // query the database
 if (basic == "basic") {
-  $sql = "SELECT rawExp.exp_name,rawExp.exp_id,chipRun.chip_id,camRun.cam_id,fakeRun.fake_id,warpRun.warp_id,warpRun.state,warpRun.label,warpRun.data_group,warpRun.dist_group,rawExp.telescope,rawExp.camera,rawExp.dateobs,rawExp.ra,rawExp.decl,rawExp.object,rawExp.filter,rawExp.exp_time,rawExp.airmass,rawExp.bg,rawExp.bg_stdev,rawExp.comment,ifnull(warpSummary.path_base,'noimage'),ifnull(warpSummary.projection_cell,'noimage') FROM fakeRun,camRun,chipRun,rawExp,warpRun LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE LIMIT $dTABLE OFFSET $rowStart";
+  $sql = "SELECT rawExp.exp_name,rawExp.exp_id,chipRun.chip_id,camRun.cam_id,fakeRun.fake_id,warpRun.warp_id,warpRun.state,warpRun.label,warpRun.data_group,warpRun.dist_group,rawExp.telescope,rawExp.camera,rawExp.dateobs,rawExp.ra,rawExp.decl,rawExp.object,rawExp.filter,rawExp.exp_time,rawExp.airmass,rawExp.bg,rawExp.bg_stdev,rawExp.comment,ifnull(warpSummary.path_base,'noimage'),ifnull(warpSummary.projection_cell,'noimage'),warpRun.tess_id FROM rawExp JOIN chipRun USING(exp_id) JOIN camRun USING (chip_id) JOIN fakeRun USING(cam_id) JOIN warpRun USING(fake_id) LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE LIMIT $dTABLE OFFSET $rowStart";
 }
 
@@ -175,4 +173,5 @@
 $buttonLink = button_restrict_string ('warpSummary.path_base', $buttonLink);
 $buttonLink = button_restrict_string ('warpSummary.projection_cell', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.tess_id', $buttonLink);
 navigate_buttons ($rowStart, $rowLast, $dTABLE, 
 		  $rowTotal, $buttonLink, $ID, 'warpProcessedExp_Images.php');
@@ -210,4 +209,5 @@
 write_header_cell ("list", "stdev    ");
 write_header_cell ("list", "Comment");
+write_header_cell ("list", "TessId");
 echo "</tr>\n";
 echo "<tr><td></td>\n";
@@ -236,4 +236,5 @@
 write_sort_cell ("list", "rawExp.bg_stdev", $buttonLink, $ID, 'warpProcessedExp_Images.php');
 write_sort_cell ("list", "rawExp.comment", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "warpRun.tess_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
 echo "</tr>\n";
 // echo "</tr>\n";
@@ -268,4 +269,5 @@
 write_query_row ('rawExp.bg_stdev', 5, 'min');
 write_query_row ('rawExp.comment', 65, 'string');
+write_query_row ('warpRun.tess_id', 65, 'string');
 echo "</tr><tr><td>&le;</td>\n";
 echo "<td> &nbsp; </td>\n";
@@ -292,4 +294,5 @@
 write_query_row ('rawExp.bg_stdev', 5, 'max');
 echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
 echo "</tr>\n";
 // echo "</tr>\n";
@@ -312,13 +315,14 @@
   //Identify current warpId
   $warpId = $row[5];
-/*   echo "<tr><td>Number of elements in warpIdCollection: ".count($warpIdCollection)."</td></tr>\n"; */
-/*   echo "<tr><td>(warpId=$warpId)</td></tr>\n"; */
+  $tessId = $row[24];
+  /* echo "<tr><td>Number of elements in warpIdCollection: ".count($warpIdCollection)."</td></tr>\n"; */
+  /* echo "<tr><td>(warpId=$warpId)</td></tr>\n"; */
 
   if (!isSet($warpIdCollection[$warpId])) {
-/*     echo "<tr><td>$warpId not in warpIdCollection</td></tr>"; */
+    /* echo "<tr><td>$warpId not in warpIdCollection</td></tr>"; */
     $warpIdCollection[$warpId] = array();
     $skyCellValue = preg_replace("|skycell[.]|","",$row[23]);
     $warpIdCollection[$warpId]["12"] = $skyCellValue;
-/*     echo "<tr><td>Skycell is [$skyCellValue]</td></tr>"; */
+    /* echo "<tr><td>Skycell is [$skyCellValue]</td></tr>"; */
 
     echo "<tr>\n";
@@ -344,10 +348,10 @@
     echo "<td class=\"$class\">\n";
     echo "<table border=\"1\"><tr>\n";
-/*     echo "  <td class=\"ul3x2\" id=\"$warpId.00\">$noImageValue</td>\n"; */
+    /* echo "  <td class=\"ul3x2\" id=\"$warpId.00\">$noImageValue</td>\n"; */
     echo "  <td class=\"ul3x2\" id=\"$warpId.00\"></td>\n";
     echo "  <td class=\"uc3x2\" id=\"$warpId.01\">$noImageValue</td>\n";
     echo "  <td class=\"ur3x2\" id=\"$warpId.02\">$noImageValue</td>\n";
     echo "</tr><tr>\n";
-/*     echo "  <td class=\"ll3x2\" id=\"$warpId.10\">$noImageValue</td>\n"; */
+    /* echo "  <td class=\"ll3x2\" id=\"$warpId.10\">$noImageValue</td>\n"; */
     echo "  <td class=\"ll3x2\" id=\"$warpId.10\"></td>\n";
     echo "  <td class=\"lc3x2\" id=\"$warpId.11\">$noImageValue</td>\n";
@@ -364,10 +368,10 @@
     echo "<td class=\"$class\">\n";
     echo "<table border=\"1\"><tr>\n";
-/*     echo "  <td class=\"ul3x2\" id=\"t$warpId.00\">No image</td>\n"; */
+    /* echo "  <td class=\"ul3x2\" id=\"t$warpId.00\">No image</td>\n"; */
     echo "  <td class=\"ul3x2\" id=\"t$warpId.00\"></td>\n";
     echo "  <td class=\"uc3x2\" id=\"t$warpId.01\">No image</td>\n";
     echo "  <td class=\"ur3x2\" id=\"t$warpId.02\">No image</td>\n";
     echo "</tr><tr>\n";
-/*     echo "  <td class=\"ll3x2\" id=\"t$warpId.10\">No image</td>\n"; */
+    /* echo "  <td class=\"ll3x2\" id=\"t$warpId.10\">No image</td>\n"; */
     echo "  <td class=\"ll3x2\" id=\"t$warpId.10\"></td>\n";
     echo "  <td class=\"lc3x2\" id=\"t$warpId.11\">No image</td>\n";
@@ -376,9 +380,18 @@
     echo "</td>\n";
 
-    $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
-    echo "<script type=\"text/javascript\">changeCell(\"$warpId.12\", \"$cellContent\");</script>";
-    $imageNameValue = ($row[23]=="noimage" ?
-		       "No image" : $row[23]);
-    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.12\", \"$imageNameValue\");</script>";
+    if ($tessId != "RINGS.V3") {
+      $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
+      echo "<script type=\"text/javascript\">changeCell(\"$warpId.12\", \"$cellContent\");</script>";
+      $imageNameValue = ($row[23]=="noimage" ?
+		         "No image" : $row[23]);
+      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.12\", \"$imageNameValue\");</script>";
+    } else {
+      //The cell to update is the upper right one for new tessellation
+      $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
+      echo "<script type=\"text/javascript\">changeCell(\"$warpId.02\", \"$cellContent\");</script>";
+      $imageNameValue = ($row[23]=="noimage" ?
+		         "No image" : $row[23]);
+      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.02\", \"$imageNameValue\");</script>";
+    }
 
     //resume with "regular" columns
@@ -399,4 +412,5 @@
     write_table_cell ($class, '%.2f', "", $row[20]);
     write_table_cell ($class, '%s', "", $row[21]);
+    write_table_cell ($class, '%s', "", $row[24]);
     echo "</tr>\n";
 
@@ -415,36 +429,77 @@
     $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
 
-    if ($skyCellValue == $lrValue + 1) {
-      $warpIdCollection[$warpId]["11"] = $skyCellValue;
-      echo "<script type=\"text/javascript\">changeCell(\"$warpId.11\", \"$cellContent\");</script>";
-      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.11\", \"$row[23]\");</script>";
-    } else {
-      if ($skyCellValue == $lrValue + 2) {
-	$warpIdCollection[$warpId]["10"] = $skyCellValue;
-	echo "<script type=\"text/javascript\">changeCell(\"$warpId.10\", \"$cellContent\");</script>";
-	echo "<script type=\"text/javascript\">changeCell(\"t$warpId.10\", \"$row[23]\");</script>";
+    if ($tessId != "RINGS.V3") {
+      if ($skyCellValue == $lrValue + 1) {
+        $warpIdCollection[$warpId]["11"] = $skyCellValue;
+      	echo "<script type=\"text/javascript\">changeCell(\"$warpId.11\", \"$cellContent\");</script>";
+	echo "<script type=\"text/javascript\">changeCell(\"t$warpId.11\", \"$row[23]\");</script>";
       } else {
-	if (!isSet($warpIdCollection[$warpId]["02"])) {
-	  /* 	echo "<tr><td>Update UpperRight</td></tr>"; */
-	  $warpIdCollection[$warpId]["02"] = $skyCellValue;
-	  echo "<script type=\"text/javascript\">changeCell(\"$warpId.02\", \"$cellContent\");</script>";
-	  echo "<script type=\"text/javascript\">changeCell(\"t$warpId.02\", \"$row[23]\");</script>";
-	} else {
-	  $urValue = $warpIdCollection[$warpId]["02"];
-	  if ($urValue + 1 == $skyCellValue) {
-	    echo "<script type=\"text/javascript\">changeCell(\"$warpId.01\", \"$cellContent\");</script>";
-	    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.01\", \"$row[23]\");</script>";
+        if ($skyCellValue == $lrValue + 2) {
+	  $warpIdCollection[$warpId]["10"] = $skyCellValue;
+	  echo "<script type=\"text/javascript\">changeCell(\"$warpId.10\", \"$cellContent\");</script>";
+	  echo "<script type=\"text/javascript\">changeCell(\"t$warpId.10\", \"$row[23]\");</script>";
+        } else {
+	  if (!isSet($warpIdCollection[$warpId]["02"])) {
+	    /* echo "<tr><td>Update UpperRight</td></tr>"; */
+	    $warpIdCollection[$warpId]["02"] = $skyCellValue;
+	    echo "<script type=\"text/javascript\">changeCell(\"$warpId.02\", \"$cellContent\");</script>";
+	    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.02\", \"$row[23]\");</script>";
 	  } else {
-	    if ($urValue + 2 == $skyCellValue) {
-	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"$cellContent\");</script>";
-	      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.00\", \"$row[23]\");</script>";
+	    $urValue = $warpIdCollection[$warpId]["02"];
+	    if ($urValue + 1 == $skyCellValue) {
+	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.01\", \"$cellContent\");</script>";
+	      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.01\", \"$row[23]\");</script>";
 	    } else {
-	      $expected = $urValue + 1;
-	      $actual = $skyCellValue;
-	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"Problem in UpperLeft corner: expected $expected but was $actual\");</script>";
-	      echo "<tr><td>Problem in Upper part!</td></tr>";
-	    }
-	  } 
+	      if ($urValue + 2 == $skyCellValue) {
+	        echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"$cellContent\");</script>";
+	        echo "<script type=\"text/javascript\">changeCell(\"t$warpId.00\", \"$row[23]\");</script>";
+	      } else {
+	        $expected = $urValue + 1;
+	        $actual = $skyCellValue;
+	        echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"Problem in UpperLeft corner: expected $expected but was $actual\");</script>";
+	        echo "<tr><td>Problem in Upper part!</td></tr>";
+	      }
+	    } 
+	  }
 	}
+      }
+    } else { /* New tessellation */
+
+      /* echo "<p>$lrValue -  $skyCellValue</p>"; */
+
+      if ($skyCellValue == $lrValue + 1) {
+        $warpIdCollection[$warpId]["11"] = $skyCellValue;
+      	echo "<script type=\"text/javascript\">changeCell(\"$warpId.01\", \"$cellContent\");</script>";
+	echo "<script type=\"text/javascript\">changeCell(\"t$warpId.01\", \"$row[23]\");</script>";
+      } else {
+        if ($skyCellValue == $lrValue + 2) {
+	  $warpIdCollection[$warpId]["10"] = $skyCellValue;
+	  echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"$cellContent\");</script>";
+	  echo "<script type=\"text/javascript\">changeCell(\"t$warpId.00\", \"$row[23]\");</script>";
+        } else {
+	  if (!isSet($warpIdCollection[$warpId]["02"])) {
+	    /* echo "<tr><td>Update UpperRight</td></tr>"; */
+	    $warpIdCollection[$warpId]["02"] = $skyCellValue;
+	    echo "<script type=\"text/javascript\">changeCell(\"$warpId.12\", \"$cellContent\");</script>";
+	    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.12\", \"$row[23]\");</script>";
+	  } else {
+	    $urValue = $warpIdCollection[$warpId]["02"];
+	    if ($urValue + 1 == $skyCellValue) {
+	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.11\", \"$cellContent\");</script>";
+	      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.11\", \"$row[23]\");</script>";
+	    } else {
+	      if ($urValue + 2 == $skyCellValue) {
+	        echo "<script type=\"text/javascript\">changeCell(\"$warpId.10\", \"$cellContent\");</script>";
+	        echo "<script type=\"text/javascript\">changeCell(\"t$warpId.10\", \"$row[23]\");</script>";
+	      } else {
+	        $expected = $urValue + 1;
+	        $actual = $skyCellValue;
+	        echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"Problem in UpperLeft corner: expected $expected but was $actual\");</script>";
+	        echo "<tr><td>Problem in Upper part!</td></tr>";
+	      }
+	    } 
+	  }
+	}
+
       }
     }
