Public Member Functions | Public Attributes | Private Attributes | List of all members
wirecell.img.clusters.ClusterMap Class Reference
Inheritance diagram for wirecell.img.clusters.ClusterMap:

Public Member Functions

def __init__ (self, gr)
 
def channel (self, key)
 
def wire_chanseg (self, chan, seg)
 
def wire_wip (self, wpid, wip)
 
def wire_wid (self, wpid, wid)
 
def find (self, typecode=None, kwds)
 
def nodes_oftype (self, typecode)
 
def neighbors_oftype (self, node, typecode)
 

Public Attributes

 gr
 

Private Attributes

 _id2ch
 
 _pi2ch
 
 _cs2wire
 
 _wip2wire
 
 _wid2wire
 

Detailed Description

Add some indexing and lookups to meta data on cluster graph vertices

Definition at line 20 of file clusters.py.

Constructor & Destructor Documentation

def wirecell.img.clusters.ClusterMap.__init__ (   self,
  gr 
)

Definition at line 25 of file clusters.py.

25  def __init__(self, gr):
26  self.gr = gr
27  self._id2ch = dict()
28  self._pi2ch = dict()
29  self._cs2wire = dict()
30  self._wip2wire = dict()
31  self._wid2wire = dict()
32 
33  for node, data in gr.nodes.data():
34  if data['code'] == 'c':
35  self._id2ch[data['ident']] = node
36  self._pi2ch[(data['wpid'], data['index'])] = node;
37  continue;
38  if data['code'] == 'w':
39  self._cs2wire[(data['chid'], data['seg'])] = node
40  self._wip2wire[(data['wpid'], data['index'])] = node;
41  self._wid2wire[(data['wpid'], data['ident'])] = node;
42  continue
43 

Member Function Documentation

def wirecell.img.clusters.ClusterMap.channel (   self,
  key 
)
Return a channel node by a key.  If key is scalar it is a
channel ident number, else assumed to be a pair of (wpid,
index).

Definition at line 44 of file clusters.py.

44  def channel(self, key):
45  '''
46  Return a channel node by a key. If key is scalar it is a
47  channel ident number, else assumed to be a pair of (wpid,
48  index).
49  '''
50  if type(key) == tuple:
51  return self._pi2ch[key];
52  return self._id2ch[key];
53 
def wirecell.img.clusters.ClusterMap.find (   self,
  typecode = None,
  kwds 
)
Return nodes with data matching kwds.  If typecode is given,
only consider nodes of that type.

Definition at line 73 of file clusters.py.

73  def find(self, typecode=None, **kwds):
74  '''
75  Return nodes with data matching kwds. If typecode is given,
76  only consider nodes of that type.
77  '''
78  ret = list()
79  for node,data in self.gr.nodes.data():
80  if typecode and self.gr.nodes[node]['code'] != typecode:
81  continue;
82  if not match_dict(data,kwds):
83  continue
84  ret.append(node)
85  return ret
86 
87 
def find(self, typecode=None, kwds)
Definition: clusters.py:73
def match_dict(have, want)
Definition: clusters.py:9
def wirecell.img.clusters.ClusterMap.neighbors_oftype (   self,
  node,
  typecode 
)
Return all connected nodes of the given node and given type.

Definition at line 94 of file clusters.py.

94  def neighbors_oftype(self, node, typecode):
95  '''
96  Return all connected nodes of the given node and given type.
97  '''
98  ret = list()
99  for nn in self.gr[node]:
100  if self.gr.nodes[nn]['code'] == typecode:
101  ret.append(nn)
102  return ret
103 
def neighbors_oftype(self, node, typecode)
Definition: clusters.py:94
def wirecell.img.clusters.ClusterMap.nodes_oftype (   self,
  typecode 
)
Return a list of nodes of given type code

Definition at line 88 of file clusters.py.

88  def nodes_oftype(self, typecode):
89  '''
90  Return a list of nodes of given type code
91  '''
92  return [n for n,d in self.gr.nodes.data() if d['code'] == typecode]
93 
def nodes_oftype(self, typecode)
Definition: clusters.py:88
def wirecell.img.clusters.ClusterMap.wire_chanseg (   self,
  chan,
  seg 
)
Return a wire node by its channel and segment

Definition at line 54 of file clusters.py.

54  def wire_chanseg(self, chan, seg):
55  '''
56  Return a wire node by its channel and segment
57  '''
58  return self._cs2wire[(chan,seg)]
59 
def wire_chanseg(self, chan, seg)
Definition: clusters.py:54
def wirecell.img.clusters.ClusterMap.wire_wid (   self,
  wpid,
  wid 
)
Return a wire node by its wire-ident and wire-plane ID.

Definition at line 66 of file clusters.py.

66  def wire_wid(self, wpid, wid):
67  '''
68  Return a wire node by its wire-ident and wire-plane ID.
69  '''
70  return self._wid2wire[(wpid, wip)];
71 
72 
def wire_wid(self, wpid, wid)
Definition: clusters.py:66
def wirecell.img.clusters.ClusterMap.wire_wip (   self,
  wpid,
  wip 
)
Return a wire node by its wire-in-plane number in the given wire-plane ID

Definition at line 60 of file clusters.py.

60  def wire_wip(self, wpid, wip):
61  '''
62  Return a wire node by its wire-in-plane number in the given wire-plane ID
63  '''
64  return self._wip2wire[(wpid, wip)];
65 
def wire_wip(self, wpid, wip)
Definition: clusters.py:60

Member Data Documentation

wirecell.img.clusters.ClusterMap._cs2wire
private

Definition at line 29 of file clusters.py.

wirecell.img.clusters.ClusterMap._id2ch
private

Definition at line 27 of file clusters.py.

wirecell.img.clusters.ClusterMap._pi2ch
private

Definition at line 28 of file clusters.py.

wirecell.img.clusters.ClusterMap._wid2wire
private

Definition at line 31 of file clusters.py.

wirecell.img.clusters.ClusterMap._wip2wire
private

Definition at line 30 of file clusters.py.

wirecell.img.clusters.ClusterMap.gr

Definition at line 26 of file clusters.py.


The documentation for this class was generated from the following file: