Index: /branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
===================================================================
--- /branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py	(revision 19801)
+++ /branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py	(revision 19802)
@@ -34,4 +34,42 @@
 #     + histograms of everything - recovery fractions, means, medians, quartiles
 #     + Trends with field number, seeing etc.
+
+def smdefaults():
+    # Will these be persistent across multiple imports and going out
+    # of scope? Perhaps only if I do a global 'import sm'. Or it
+    # should work if called from something where sm is in scope?
+    sm.expand(1.8)
+    sm.lweight(5)
+
+# Plotting convention will be like in sm: you need to open a file,
+# then you plot to it with one or multiple commands, then you close it
+# to write the file. 
+
+def scatterplot(x,y,ptype,xlab,ylab,xrange='',yrange='',append=False,close=True,dev='x11'):
+    """Make an sm scatter plot on current device."""
+    import sm
+    sm.expand(1.8)
+    sm.lweight(5)
+    # Silently ignore any problems with plot generation
+    try:
+        if not append:
+            sm.device(dev)
+            sm.erase()
+            if xrange == '':
+                xrange = x
+            if yrange == '':
+                yrange = y
+            sm.limits(x,y)
+            sm.box()
+            sm.xlabel(xlab)
+            sm.ylabel(ylab)
+        sm.ptype(ptype)
+        sm.points(x,y)
+        # Close active device - maybe add flag to skip this so plot
+        # remains appendable, or use meta? but can't use colour in meta...
+        if close:
+            sm.device('nodevice')
+    except:
+        pass
 
 def compIPPphoto(summaryTable,mode):
@@ -178,9 +216,9 @@
         'd_x':['colc','x_psf']
         ,'d_y':['rowc','y_psf']
-        ,'d_mag':['psfcounts','PSF_INST_MAG']
-        ,'d_magerr':['psfcountserr','PSF_INST_MAG_SIG']
         ,'d_sky':['sky_sdss','SKY_ps1']
         ,'d_skyerr':['skyErr','SKY_SIGMA']
         ,'d_pointsource':['prob_psf','pointsource_ps1']
+        ,'d_mag':['psfcounts','PSF_INST_MAG']
+        ,'d_magerr':['psfcountserr','PSF_INST_MAG_SIG']
         }
 
@@ -216,4 +254,9 @@
             SDSScol_good,PS1col_good,SDSScounts_good = filterGoodVal3(SDSScol,PS1col,SDSScounts)
             SDSScol_good = 2.5/log(10.)*SDSScol_good/SDSScounts_good
+            scatterplot(PS1col_good,SDSScol_good,43,'PS1 inst mag','SDSS inst mag',dev='postfile test.eps',append=True,close=True)
+        if outcol == 'd_x':
+            scatterplot(PS1col_good,SDSScol_good,43,'PS1 inst mag','SDSS inst mag',dev='postfile test.eps',append=False,close=False)
+        else:
+            scatterplot(PS1col_good,SDSScol_good,43,'PS1 inst mag','SDSS inst mag',dev='postfile test.eps',append=True,close=False)            
         delta = SDSScol_good - PS1col_good
         avg = delta.mean()
