def element(self, elist, setname='default', daterange=None, seqlist=None): ''' create list of Conn instance and add to connlist list -- connectivity information of the elements [[n11,n12,..1n], [n21,n22,..2n]] sequence will be automatically added based on the increment from current max seq of elements ''' # get current max seq ne = self.connlist.get_seqmax() tempelem = [] tempelemseqlist = [] ne_seq = -1 #t0 = time.time() for item in elist: ne += 1 ne_seq += 1 # try convert to desired numpy array try: if daterange == None: item = np.array(item, dtype=int) else: item = np.array(item[daterange[0]:daterange[1]], dtype=int) except: raise ValueError, ('input element connectivity', item, 'can not convert to numpy int array') if seqlist == None: tempelem.append(conn(item, seq=ne)) else: tempelem.append(conn(item, seq=seqlist[ne_seq])) tempelemseqlist.append(ne) #t1 = time.time() - t0 #print 'time to create elements %s ' % str(t1) #t0 = time.time() self.connlist.addbylist(tempelem) #t1 = time.time() - t0 #print 'time to add elements %s ' % str(t1) #t0 = time.time() if setname not in self.setlist.keys(): self.elemset(setname, {'elemlist': tempelemseqlist}) else: self.setlist[setname].addelem(tempelemseqlist) #t1 = time.time() - t0 #print 'time to add elements to set%s ' % str(t1) return tempelemseqlist
def element(self,elist,setname='default',daterange=None,seqlist=None): ''' create list of Conn instance and add to connlist list -- connectivity information of the elements [[n11,n12,..1n], [n21,n22,..2n]] sequence will be automatically added based on the increment from current max seq of elements ''' # get current max seq ne = self.connlist.get_seqmax() tempelem = [] tempelemseqlist = [] ne_seq = -1 #t0 = time.time() for item in elist: ne += 1 ne_seq += 1 # try convert to desired numpy array try: if daterange == None: item = np.array(item,dtype=int) else: item = np.array(item[daterange[0]:daterange[1]],dtype=int) except: raise ValueError,('input element connectivity',item, 'can not convert to numpy int array') if seqlist == None: tempelem.append(conn(item,seq=ne)) else: tempelem.append(conn(item,seq=seqlist[ne_seq])) tempelemseqlist.append(ne) #t1 = time.time() - t0 #print 'time to create elements %s ' % str(t1) #t0 = time.time() self.connlist.addbylist(tempelem) #t1 = time.time() - t0 #print 'time to add elements %s ' % str(t1) #t0 = time.time() if setname not in self.setlist.keys(): self.elemset(setname,{'elemlist':tempelemseqlist}) else: self.setlist[setname].addelem(tempelemseqlist) #t1 = time.time() - t0 #print 'time to add elements to set%s ' % str(t1) return tempelemseqlist
def add_element(self, item, setname=None): ne = self.connlist.get_seqmax() # try convert to desired numpy array try: item = np.array(item, dtype=int) except: raise ValueError, ('input element connectivity', item, 'can not convert to numpy int array') tempelem = conn(item, seq=ne + 1) # add to connnlist self.connlist.add(tempelem) if setname != None: self.add_to_set(setname, [ne + 1], settype='element') return tempelem
def add_element(self,item,setname=None): ne = self.connlist.get_seqmax() # try convert to desired numpy array try: item = np.array(item,dtype=int) except: raise ValueError,('input element connectivity',item, 'can not convert to numpy int array') tempelem = conn(item,seq=ne+1) # add to connnlist self.connlist.add(tempelem) if setname != None: self.add_to_set(setname,[ne+1],settype='element') return tempelem