Changeset 13090 for fact/tools


Ignore:
Timestamp:
03/13/12 19:34:47 (13 years ago)
Author:
neise
Message:
debugged CamPlotter class ... wrong identation as some point
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/pyfact/plotters.py

    r13080 r13090  
    128128        #handle masked case specially
    129129        if mask!= None:
     130            if len(mask)==0:
     131                return
     132           
    130133            if mask.dtype == bool and data.ndim ==1 and len(mask)==1440:
    131134                length = mask.sum()
     
    178181        else: # i.e. when mask is None
    179182        # handle 1D and 2D case differently
    180         if data.ndim == 1 and len(data)==1440:
    181             result = self.ax.scatter(xe,ye,s=25,alpha=1,
    182                         c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
    183             self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
    184             plt.draw()
    185            
    186         elif data.ndim == 2 and data.shape[0] == 2 and data.shape[1] <=1440:
    187             # I assume the first row of data, contains the CHIDs
    188             # and the 2nd row contains the actual data.
    189             chids = data[0]
    190             # check if there are double chids in chids
    191             if len(chids)!=len(set(chids)):
    192                 print 'warning: there are doubled chids in input data',
    193                 print 'you might want to plot something else, but I plot it anyway...'
    194                 print chids
    195             data = data[1]
    196             # now I have to mask the xe, and ye vectors accordingly
    197             mxe = np.empty( len(chids) )
    198             mye = np.empty( len(chids) )
    199             for i,chid in enumerate(chids):
    200                 mxe[i] = xe[chid]
    201                 mye[i] = ye[chid]
    202            
    203             # check if I did it right
    204             if len(mxe)!=len(data) or len(mye)!=len(data):
    205                 print 'the masking did not work:'
    206                 print 'len(mxe)', len(mxe)
    207                 print 'len(mye)', len(mye)
    208                 print 'len(data)', len(data)
    209            
    210             self.ax.axis([-22,22,-22,22])
    211             self.ax.set_title(name)
    212             self.ax.grid(grid)
    213             # the next line is a stupid hack
    214             # I plot invisible pixels, so that the axes show look ok.
    215             # this must be possible differently, but I don't know how...
    216             self.ax.scatter(xe,ye,s=25,alpha=0,marker=H)
    217            
    218             result = self.ax.scatter(mxe,mye,s=25,alpha=1.,
    219                         c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
    220             self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
    221             plt.draw()
    222            
    223         else:
    224             print 'CamPlotter call input data has bad format'
    225             print 'data.ndim', data.ndim
    226             print 'data.shape', data.shape
    227             print 'data:----------------------------------'
    228             print data
     183            if data.ndim == 1 and len(data)==1440:
     184                result = self.ax.scatter(xe,ye,s=25,alpha=1,
     185                            c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
     186                self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
     187                plt.draw()
     188               
     189            elif data.ndim == 2 and data.shape[0] == 2 and data.shape[1] <=1440:
     190                # I assume the first row of data, contains the CHIDs
     191                # and the 2nd row contains the actual data.
     192                chids = data[0]
     193                # check if there are double chids in chids
     194                if len(chids)!=len(set(chids)):
     195                    print 'warning: there are doubled chids in input data',
     196                    print 'you might want to plot something else, but I plot it anyway...'
     197                    print chids
     198                data = data[1]
     199                # now I have to mask the xe, and ye vectors accordingly
     200                mxe = np.empty( len(chids) )
     201                mye = np.empty( len(chids) )
     202                for i,chid in enumerate(chids):
     203                    mxe[i] = xe[chid]
     204                    mye[i] = ye[chid]
     205               
     206                # check if I did it right
     207                if len(mxe)!=len(data) or len(mye)!=len(data):
     208                    print 'the masking did not work:'
     209                    print 'len(mxe)', len(mxe)
     210                    print 'len(mye)', len(mye)
     211                    print 'len(data)', len(data)
     212               
     213                self.ax.axis([-22,22,-22,22])
     214                self.ax.set_title(name)
     215                self.ax.grid(grid)
     216                # the next line is a stupid hack
     217                # I plot invisible pixels, so that the axes show look ok.
     218                # this must be possible differently, but I don't know how...
     219                self.ax.scatter(xe,ye,s=25,alpha=0,marker=H)
     220               
     221                result = self.ax.scatter(mxe,mye,s=25,alpha=1.,
     222                            c=data, marker=H, linewidths=0., vmin=vmin, vmax=vmax)
     223                self.figure.colorbar( result, shrink=0.8, pad=-0.04 )
     224                plt.draw()
     225               
     226            else:
     227                print 'CamPlotter call input data has bad format'
     228                print 'data.ndim', data.ndim
     229                print 'data.shape', data.shape
     230                print 'data:----------------------------------'
     231                print data
    229232       
    230233       
Note: See TracChangeset for help on using the changeset viewer.