コード例 #1
0
    def _trace_from_string(cls, srcstr):
        parser = ply.yacc.yacc(tabmodule='tracestring_parsetab',
                                outputdir=LocMgr.ensure_dir_exists('/tmp/parsetabs/'),
                                debug=SettingsMgr.get_ply_yacc_debug_flag())

        (unit, trace_prototypes) = parser.parse(srcstr, lexer=l)

        # Copy accross the start values:
        start_value = 0
        for prototype in trace_prototypes:
            prototype.start_value = start_value
            piece = prototype.toTracePiece()
            start_value = piece.get_end_value()

        # Convert to pieces
        pieces = [trace_prototype.toTracePiece() for trace_prototype in trace_prototypes]
        trace = TracePiecewise(pieces=pieces, comment='Src: %s' % srcstr)
        trace = trace * (1.0 * unit)
        return trace
コード例 #2
0
    def _trace_from_string(cls, s):
        parser = ply.yacc.yacc( tabmodule='tracestring_parsetab', 
                                outputdir=LocMgr.EnsureMakeDirs('/tmp/parsetabs/'),
                                debug=SettingsMgr.getPLYYaccDebugFlag() )

        unit, tracePrototypes = parser.parse( t, lexer=l )

        # Copy accross the start values:
        v=0
        for prototype in tracePrototypes:
            prototype.start_value = v
            piece = prototype.toTracePiece()
            v = piece.getEndValue()


        # Convert to pieces
        pieces = [ tracePrototype.toTracePiece()  for tracePrototype in tracePrototypes]
        tr = Trace_Piecewise(pieces=pieces)
        tr = tr * (1.0*unit)
        return tr
コード例 #3
0
    def _trace_from_string(cls, srcstr):
        parser = ply.yacc.yacc(
            tabmodule='tracestring_parsetab',
            outputdir=LocMgr.ensure_dir_exists('/tmp/parsetabs/'),
            debug=SettingsMgr.get_ply_yacc_debug_flag())

        (unit, trace_prototypes) = parser.parse(srcstr, lexer=l)

        # Copy accross the start values:
        start_value = 0
        for prototype in trace_prototypes:
            prototype.start_value = start_value
            piece = prototype.toTracePiece()
            start_value = piece.get_end_value()

        # Convert to pieces
        pieces = [
            trace_prototype.toTracePiece()
            for trace_prototype in trace_prototypes
        ]
        trace = TracePiecewise(pieces=pieces, comment='Src: %s' % srcstr)
        trace = trace * (1.0 * unit)
        return trace
コード例 #4
0
    
def p_unit_simple(p):
    'unit : ID'
    p[0] = unit_from_string( p[1] )
    

def p_unit_simplenumber(p):
    'unit : ID NUMBER'
    u = unit_from_string( p[1] )
    p[0] = np.power(u, p[2] )


def p_error(p):
    print "Syntax error in input!"
    assert False
    


parser = yacc.yacc(tabmodule = 'unitsparser_parsetab.py', outputdir=LocMgr.getPLYParseTabLocation('unitsparser'), debug=SettingsMgr.getPLYYaccDebugFlag()  )


def parse(s):
    r = parser.parse(s, lexer=lexer, )
    return r


 
                   


コード例 #5
0
ファイル: mytagviewer.py プロジェクト: mpelko/neurovivo
    def Render(self):
        from morphforge.core import pylab_wrapper
        self.fig = pylab_wrapper.mpl.figure(figsize=self.figsize)
        
        print "Time Ranges:", self.timeranges
        
        nGraphs = len(self.tags)
        nTimeRanges = len(self.timeranges)
        print self.colors 
        
        print self.tags
        
        for i, tags in enumerate(self.tags):
            for iT, timeRange in enumerate(self.timeranges):
                subfigIndex = (i) * nTimeRanges + iT + 1
                print nGraphs, nTimeRanges, subfigIndex, i
                s = self.fig.add_subplot(nGraphs, nTimeRanges, subfigIndex)
                self.subfigs.append((s))
                i = 0
                # Find Traces with the relevant tags - start with complete list then slowly remove:
                spMax = None
                spMin = None
                for result in self.results:
                    validTraces = result.traces
                    for tag in tags:
                        validTraces = [ trc for trc in validTraces if tag in trc.tags ]
                    
                    traceList =sorted(validTraces, key=lambda t:t.name) if self.sorttraces else validTraces 
                    print tags, validTraces
                    currentUnit = traceList[0]._data.units
                    for trc in traceList:
                        spMin, spMax = self.getPlotMinMax(trc._data, trc._time, spMin, spMax)
                        jitterFactor = float(i) * self.jitter
                        i = i + 1.0
                        print jitterFactor
                        
                        label = Template(self.legendlabel, [{"trace":trc, "result":result}]).respond()

                        if self.colors != None:
                            self.tracecolour = self.colors[ int(i)-1 ]
                        
                        if self.tracecolour != None:
                            pylab_wrapper.mpl.plot(trc._time, trc._data.rescale(currentUnit).magnitude + jitterFactor, color=self.tracecolour, label=label)
                        else:
                            pylab_wrapper.mpl.plot(trc._time, trc._data.rescale(currentUnit).magnitude,  label=label)
                        
                
                pylab_wrapper.mpl.xlabel("Time (ms)")
                pylab_wrapper.mpl.ylabel("-".join(tags) + " (%s)"%currentUnit.dimensionality.string )
                pylab_wrapper.mpl.grid("on")
                
                rg = spMax - spMin 
                pylab_wrapper.mpl.ylim((spMin - rg * self.axisPadding, spMax + rg * self.axisPadding))

                if timeRange:
                    pylab_wrapper.mpl.xlim(timeRange)

                if self.haslegend:
                  pylab_wrapper.mpl.legend()
       
        if self.filename:
            self.fig.savefig(self.filename)
            if SettingsMgr.showAllPlots(): pylab_wrapper.mpl.show()
        else:
            pass