Index: /branches/sj_branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
===================================================================
--- /branches/sj_branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py	(revision 24068)
+++ /branches/sj_branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py	(revision 24069)
@@ -52,10 +52,16 @@
 #   ranges are the same.
 #
-# - second tlist for summary plots (same or different plot routine?)
-#
 # - towards generality, want to read these things and colname_hash and
 #   label_l from config files
 #
-# Convention: for scatter, plot second against first; for histogram, plot both histograms
+# - perhaps via the RO package and RO.DS9, add diagnostic features via
+#   its ability to talk to ds9. E.g. load the fpC image in ds9,
+#   overlay SDSS objects in one colour, psphot in another, have
+#   different symbols for point vs extended source, etc. Maybe also
+#   use the CDS Aladin API (if one is available) to be able to click
+#   on object in image to pull up photometry. In fact, stilts should
+#   be able to talk to the aladin tool via PLASTIC. See "Starlink User
+#   Note 253" - somewhere on the web as sun253.html
+# 
 
 
@@ -67,5 +73,5 @@
 # (and that's probably quite enough anyway).
 
-# Look at extended flag in PS1 vs. SDSS!!!
+# Looking at the extended flag in PS1 vs. SDSS is done via d_pointsource.
 
 # os.chdir('/disk1/jester/IPP/data/SDSS/stripe82/coadd/compare')
@@ -73,4 +79,17 @@
 # h1,h2=compIPPphoto('test.fits','new',workdir='/IPP/data/SDSS/stripe82/coadd/compare',runlist=[1056,1755])
 
+# Here follow two specially formatted lists governing which plots are
+# made. The first is for plots being done on a field-by-field basis,
+# giving [x vector(s)],[y vector(s)], 'scatter' plot or
+# 'histogram. The second is for "summary" plots that plot aggregate
+# statistics for the entire list of fields supplied, e.g. the number
+# of PS1 sources in a field vs. the number of SDSS sources in a field.
+#
+# Some columns come from copyfields_list; which columns get d_
+# difference columns is set by colname_hash ( see help text for
+# compIPPphoto() )
+#
+# The convention is: for scatter, plot second against first; for
+# histogram, plot both histograms
 plotcol_1frame_tlist = [
     (['x_psf','objc_colc'],['y_psf','objc_rowc'],'scatter')
@@ -127,8 +146,42 @@
                      runlist=[1056,1755,3388,3434,3465,4145,4192,4203,4247,4263,5052],\
                      copyfields_list = ['RUN','RERUN','CAMCOL','FIELD','FILTER','FWHM_MAJ','FWHM_MIN'],\
-                     skip=True):
-    """summaryTable: .fits table for output
-    mode: new or append for creating summaryTable new or appending current run's output to it.
-
+                     skipMatch=True):
+    """Match a .cmf file against the corresponding fpObjc file,
+    compute statistics (e.g. median difference of some pair of
+    columns), plot these statistics field-by-field or aggregate
+    basis. Which columns are subtracted from each other is hardcoded
+    into colname_hash in computeStatistics(); the todo list for this
+    source file includes passing colname_hash around as parameter and
+    allowing it to be read from a config file.
+
+    summaryTable: .fits table for output
+
+    mode: new or append for creating summaryTable new or appending
+    current run's output to it.
+
+    plotcol_1frame_tlist: list specifying which plots should be made
+    frame-by-frame (see top of source file)
+
+    plotcol_summary_tlist: which plots should be made for aggregate
+    quantities for the entire list of fields
+
+    cmfDir: where psphot output is found; location of SDSS files is
+    currently hardcoded in makePlan
+
+    workdir: where results are stored (matched-up fits tables, plots)
+
+    runlist: which SDSS runs to look at
+
+    copyfields_list: which header fields to copy from the input tables
+       (via the match table) to the output fields, so that we can plot
+       them in the aggregate output. CAUTION: the corresponding fields
+       need to be copied from the input cmf / fpObjc files in
+       matchSdssPs1() - search for ps1copyfields_hash in the source -
+       should probably split this into PS1copyfields and
+       SDSScopyfields and then pass these down to matchSdssPs1()
+
+    skipMatch: if True, assume cmf / fpObjc matching has already been
+    done, don't repeat it, and only produce statistics and plots
+    
     Steps:
 
@@ -159,5 +212,5 @@
     bandindex_hash = {}
     for chipfile,fpObjc in zip(chipfile_l,fpObjc_l):
-        matchtable,filter_name,bandindex = matchSdssPs1(fpObjc,chipfile,skip=skip)
+        matchtable,filter_name,bandindex = matchSdssPs1(fpObjc,chipfile,skipMatch=skipMatch)
         if filter_name not in filters:
             filters.append(filter_name)
@@ -614,5 +667,5 @@
     return array(good1_l),array(good2_l),array(good3_l)
     
-def matchSdssPs1(SDSSfpObjc,PS1cmf,xoff=0.5,yoff=0.5,matchrad=0.7,skip=False):
+def matchSdssPs1(SDSSfpObjc,PS1cmf,xoff=0.5,yoff=0.5,matchrad=0.7,skipMatch=False):
     """Call matchByPos to match an SDSS fpObjc.fits and a PS1 bla.cmf
     file."""
@@ -645,5 +698,5 @@
     bandindex = filters.index(sdssbandstr)
     outname = getOutname(SDSSfpObjc,PS1cmf,sdssbandstr)
-    if skip:
+    if skipMatch:
         return outname,sdssbandstr,bandindex
         
