Package qubx :: Package fast :: Module clickmap
[hide private]
[frames] | no frames]

Source Code for Module qubx.fast.clickmap

 1  """Compiled routines for sampled data. 
 2   
 3  Copyright 2008-2011 Research Foundation State University of New York  
 4  This file is part of QUB Express.                                           
 5   
 6  QUB Express is free software; you can redistribute it and/or modify           
 7  it under the terms of the GNU General Public License as published by  
 8  the Free Software Foundation, either version 3 of the License, or     
 9  (at your option) any later version.                                   
10   
11  QUB Express is distributed in the hope that it will be useful,                
12  but WITHOUT ANY WARRANTY; without even the implied warranty of        
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
14  GNU General Public License for more details.                          
15   
16  You should have received a copy of the GNU General Public License,    
17  named LICENSE.txt, in the QUB Express program directory.  If not, see         
18  <http://www.gnu.org/licenses/>.                                       
19   
20  """ 
21  from qubx.fast.fast_utils import * 
22   
23  qubfast.qub_dotmap_create.argtypes = (c_int, c_float_p, c_float_p) 
24  qubfast.qub_dotmap_create.restype = c_void_p 
25  qubfast.qub_dotmap_free.argtypes = (c_void_p,) 
26  qubfast.qub_dotmap_free.restype = None 
27  qubfast.qub_dotmap_reset.argtypes = (c_void_p,) 
28  qubfast.qub_dotmap_reset.restype = None 
29  qubfast.qub_dotmap_find.argtypes = (c_void_p, c_float, c_float, c_float) 
30  qubfast.qub_dotmap_find.restype = c_int 
31  qubfast.qub_dotmap_in_rect.argtypes = (c_void_p, c_float, c_float, c_float, c_float, c_int_p) 
32  qubfast.qub_dotmap_in_rect.restype = c_int 
33   
34 -class DotMap(object):
35 - def __init__(self, xx=[], yy=[]):
36 xxf = numpy.array(xx, dtype='float32') 37 yyf = numpy.array(yy, dtype='float32') 38 self.obj = qubfast.qub_dotmap_create(len(xx), cdata(xxf, c_float_p), cdata(yyf, c_float_p)) 39 self.N = len(xx)
40 - def __del__(self):
41 qubfast.qub_dotmap_free(self.obj)
42 - def reset(self, xx, yy):
43 xxf = numpy.array(xx, dtype='float32') 44 yyf = numpy.array(yy, dtype='float32') 45 qubfast.qub_dotmap_reset(self.obj, len(xx), cdata(xxf, c_float_p), cdata(yyf, c_float_p)) 46 self.N = len(xx)
47 - def find(self, x, y, rad):
48 return qubfast.qub_dotmap_find(self.obj, x, y, rad)
49 - def in_rect(self, x0, y0, x1, y1):
50 indices = numpy.zeros(shape=(self.N,), dtype='int32') 51 count = qubfast.qub_dotmap_in_rect(self.obj, x0, y0, x1, y1, cdata(indices, c_int_p)) 52 return [indices[i] for i in xrange(count)]
53