Index: fact/tools/pyscripts/pyfact/plotters.py
===================================================================
--- fact/tools/pyscripts/pyfact/plotters.py	(revision 13076)
+++ fact/tools/pyscripts/pyfact/plotters.py	(revision 13080)
@@ -84,5 +84,5 @@
             print 'not able to find file:', map_file_path
             sys.exit(-2)
-            
+        
         self.name  = name
         if ion:
@@ -103,5 +103,6 @@
         self.vmax = vmax
         
-    def __call__(self, data):
+    def __call__(self, data, mask=None):
+        # define some shortcuts
         xe = self.xe
         ye = self.ye
@@ -112,4 +113,7 @@
         vmax = self.vmax
 
+        # get the figure, clean it, and set it up nicely.
+        # maybe cleaning is not necessary and takes long, but
+        # I've got no time to test it at the moment.
         plt.figure(self.fig_id)
         plt.clf()
@@ -119,8 +123,111 @@
         self.ax.grid(grid)
         
-        result = self.ax.scatter(xe,ye,s=25,alpha=1, c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
-        self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
-
-        plt.draw()
+        # throw data into numpy array for simplicity
+        data = np.array(data)
+        
+        #handle masked case specially
+        if mask!= None:
+            if mask.dtype == bool and data.ndim ==1 and len(mask)==1440:
+                length = mask.sum()
+                mask = np.where(mask)
+                mxe = np.empty( length )
+                mye = np.empty( length )
+                mdata = np.empty( length )
+                for i,chid in enumerate(mask):
+                    mxe[i] = xe[chid]
+                    mye[i] = ye[chid]
+                    mdata[i] = data[chid]
+
+                self.ax.axis([-22,22,-22,22])
+                self.ax.set_title(name)
+                self.ax.grid(grid)
+                # the next line is a stupid hack
+                # I plot invisible pixels, so that the axes show look ok.
+                # this must be possible differently, but I don't know how...
+                self.ax.scatter(xe,ye,s=25,alpha=0,marker=H)
+                
+                result = self.ax.scatter(mxe,mye,s=25,alpha=1.,
+                            c=mdata, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
+                self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
+                plt.draw()
+
+
+            if mask.dtype == int  and data.ndim ==1:
+                length = len(mask)
+                mxe = np.empty( length )
+                mye = np.empty( length )
+                mdata = np.empty( length )
+                for i,chid in enumerate(mask):
+                    mxe[i] = xe[chid]
+                    mye[i] = ye[chid]
+                    mdata[i] = data[chid]
+
+                self.ax.axis([-22,22,-22,22])
+                self.ax.set_title(name)
+                self.ax.grid(grid)
+                # the next line is a stupid hack
+                # I plot invisible pixels, so that the axes show look ok.
+                # this must be possible differently, but I don't know how...
+                self.ax.scatter(xe,ye,s=25,alpha=0,marker=H)
+                
+                result = self.ax.scatter(mxe,mye,s=25,alpha=1.,
+                            c=mdata, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
+                self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
+                plt.draw()
+                
+        else: # i.e. when mask is None
+        # handle 1D and 2D case differently
+        if data.ndim == 1 and len(data)==1440:
+            result = self.ax.scatter(xe,ye,s=25,alpha=1,
+                        c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
+            self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
+            plt.draw()
+            
+        elif data.ndim == 2 and data.shape[0] == 2 and data.shape[1] <=1440:
+            # I assume the first row of data, contains the CHIDs 
+            # and the 2nd row contains the actual data.
+            chids = data[0]
+            # check if there are double chids in chids
+            if len(chids)!=len(set(chids)):
+                print 'warning: there are doubled chids in input data',
+                print 'you might want to plot something else, but I plot it anyway...'
+                print chids
+            data = data[1]
+            # now I have to mask the xe, and ye vectors accordingly
+            mxe = np.empty( len(chids) )
+            mye = np.empty( len(chids) )
+            for i,chid in enumerate(chids):
+                mxe[i] = xe[chid]
+                mye[i] = ye[chid]
+            
+            # check if I did it right
+            if len(mxe)!=len(data) or len(mye)!=len(data):
+                print 'the masking did not work:'
+                print 'len(mxe)', len(mxe)
+                print 'len(mye)', len(mye)
+                print 'len(data)', len(data)
+            
+            self.ax.axis([-22,22,-22,22])
+            self.ax.set_title(name)
+            self.ax.grid(grid)
+            # the next line is a stupid hack
+            # I plot invisible pixels, so that the axes show look ok.
+            # this must be possible differently, but I don't know how...
+            self.ax.scatter(xe,ye,s=25,alpha=0,marker=H)
+            
+            result = self.ax.scatter(mxe,mye,s=25,alpha=1.,
+                        c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
+            self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
+            plt.draw()
+            
+        else:
+            print 'CamPlotter call input data has bad format'
+            print 'data.ndim', data.ndim
+            print 'data.shape', data.shape
+            print 'data:----------------------------------'
+            print data
+        
+        
+        
 
 class HistPlotter(object):
@@ -196,10 +303,16 @@
     """ test of CamPlotter """
     
-    c1 = np.random.randn(1440)
+    c1 = np.array(range(20))
+    chids1 = np.empty( len(c1) , dtype=int)
+    for i in range(len(chids1)-2):
+        chids1[i] = np.random.randint(1440)
+    chids1[-1] = 15
+    chids1[-2] = 15
+    
     c2 = np.linspace(0., 1., num=1440)
     plot1 = CamPlotter('plot1')
     plot2 = CamPlotter('plot2')
     
-    plot1(c1)
+    plot1( (chids1,c1) )
     plot2(c2)
     raw_input('next')
@@ -217,5 +330,5 @@
 if __name__ == '__main__':
     """ test the class """
-    _test_Plotter()
+    #_test_Plotter()
     _test_CamPlotter()
-    _test_HistPlotter()
+    #_test_HistPlotter()
