def interlude2( view ): val = [ moose.getField( i, view.mooField, "double" ) * view.mooScale for i in view.mooObj ] view.mooGroup.set("color", val, view.mapper) view.yaw( rotation ) if moose.element("/clock").currentTime >= runtime: view.stop()
def interlude( view ): moose.start( moogliDt ) val = [ moose.getField( i, view.mooField, "double" ) * view.mooScale for i in view.mooObj ] view.mooGroup.set("color", val, view.mapper) view.yaw( rotation ) #print moogliDt, len( val ), runtime if moose.element("/clock").currentTime >= runtime: view.stop()
def interlude2(view): val = [ moose.getField(i, view.mooField, "double") * view.mooScale for i in view.mooObj ] view.mooGroup.set("color", val, view.mapper) view.yaw(rotation) if moose.element("/clock").currentTime >= runtime: view.stop()
def interlude(view): moose.start(moogliDt) val = [ moose.getField(i, view.mooField, "double") * view.mooScale for i in view.mooObj ] view.mooGroup.set("color", val, view.mapper) view.yaw(rotation) #print moogliDt, len( val ), runtime if moose.element("/clock").currentTime >= runtime: view.stop()
def updateValues( self ): ''' Obtains values from the associated cell''' self.val = np.array([moose.getField( i, self.field, 'double' ) for i in self.activeObjs]) * self.fieldScale cmap = plt.get_cmap( self.colormap ) if self.autoscale: valMin = min( self.val ) valMax = max( self.val ) else: valMin = self.valMin valMax = self.valMax scaleVal = (self.val - valMin) / (valMax - valMin) self.rgba = [ cmap(i) for i in scaleVal ] self.segments.set_color( self.rgba ) return
def updateValues(self, simTime): ''' Obtains values from the associated cell''' self.val = np.array( [moose.getField(i, self.field) for i in self.activeObjs]) * self.fieldScale if self.autoscale: valMin = min(self.val) valMax = max(self.val) else: valMin = self.valMin valMax = self.valMax scaleVal = NUM_CMAP * (self.val - valMin) / (valMax - valMin) #indices = scaleVal.ndarray.astype( int ) indices = np.maximum(np.minimum(scaleVal, NUM_CMAP - 0.5), 0.0).astype(int) self.snapshot.append([simTime, indices]) self.displayValues(indices)
def test_finfos(): s = moose.SimpleSynHandler('synh') s.numSynapses = 10 assert s.numSynapses == 10 syns = s.synapse.vec print(s.synapse, '111') s8a = s.synapse[8] s8b = s.synapse[-2] assert s8a == s8b, (s8a, s8b) # negative indexing. assert syns[-2] == syns[len(syns) - 2] assert len(syns) == 10 for i, s in enumerate(syns): s.weight = 9.0 for s in syns: assert s.weight == 9.0 # this is a shorthand for above for loop. syns.weight = 11.121 assert np.allclose(syns.weight, 11.121), syns.weight # try: # print(syns[11]) # except Exception as e: # print(e, "Great. We must got an exception here") # else: # print(syns[11]) # raise Exception("This should have failed") a = moose.Pool('x13213') a.concInit = 0.1 assert 0.1 == moose.getField(a, 'concInit') # Now get some finfos. a = moose.element('/classes/Compartment')
def extract_ftype_doc(cinfo, finfotype, docio): """Extract field documentation for all fields of type `finfotype` in class `cinfo` into `docio`. Parameters ---------- cinfo: moose.Cinfo class info object in MOOSE. finfotype: str finfo type (valueFinfo/srcFinfo/destFinfo/lookupFinfo/sharedFinfo docio: StringIO IO object to write the documentation into """ numfinfo = moose.getField(cinfo, 'num_'+finfotype, 'unsigned') finfo = moose.ematrix('%s/%s' % (cinfo.path, finfotype)) data = [] inf = float( 'Inf' ) max_width_name = -inf max_width_type = -inf for ii in range(numfinfo): fid = moose.melement(finfo, 0, ii, 0) if finfotype == 'destFinfo' and (fid.name.startswith('get_') or fid.name.startswith('set_')): continue dtype = type_mangling_regex.sub('', fid.type) name = '**`{0}`**'.format( fid.name ) dtype = '`{0}`'.format( dtype ) doc = fid.docs data.append( [ name, dtype, doc ] ) if len( name ) > max_width_name: max_width_name = len( name ) if len( dtype ) > max_width_type: max_width_type = len( dtype ) if len( data ) == 0: return padding = 2 format_string = '{{0: <{width}}}' format_strings = ( format_string.format( width = max_width_name + padding ), format_string.format( width = max_width_type + padding ), '{0}' ) col3_alignment = format_strings[0].format('') + format_strings[1].format('') for row in data: row[2] = row[2].replace( '\n', '\n' + col3_alignment ) column_headings = ( 'Field', 'Type', 'Description' ) docio.write( '\n' ) for ( column_heading, format_string ) in zip( column_headings, format_strings ): docio.write( format_string.format( column_heading ) ) docio.write( '\n' ) for format_string in format_strings: docio.write( format_string.format( '----' ) ) docio.write( '\n' ) for row in data: for ( field, format_string ) in zip( row, format_strings ): docio.write( format_string.format( field ) ) docio.write( '\n' )