Changeset 151


Ignore:
Timestamp:
09/21/2009 09:13:56 AM (14 years ago)
Author:
marcus
Message:
  • setting trace info entry fires TRACEUPDATE event
  • debug plotting routine for traces
Location:
SHX/trunk/src/SeismicHandler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/src/SeismicHandler/core/modules/Trace.py

    r146 r151  
    270270        return self.tracedata[self.traces[number-1]] 
    271271 
     272    def plot(self, share=False, save=None): 
     273        """debug plot""" 
     274 
     275        if not len(self): 
     276            raise Exception("no traces available") 
     277 
     278        from SeismicHandler.core.modules.Graphics import pylab 
     279 
     280        fig = pylab.figure() 
     281        fig.canvas.set_window_title("SHX - plot of %u traces" % len(self)) 
     282        pylab.subplots_adjust(hspace=0.1, wspace=20, left=0.1, right=0.95, bottom=0.05, top=0.95) 
     283 
     284        fig.set_facecolor('w') 
     285 
     286        for i, trc in enumerate(self): 
     287            # link x axis if more than one trace 
     288            if len(fig.axes) and share: 
     289                ax = pylab.subplot(len(self), 1, i+1, sharex=fig.axes[0]) 
     290            else: 
     291                ax = pylab.subplot(len(self), 1, i+1) 
     292 
     293            # no frame 
     294            ax.set_frame_on(False) 
     295 
     296            # no y ticks 
     297            ax.yaxis.set_major_locator(pylab.NullLocator()) 
     298 
     299            # build label from station ... 
     300            if trc.station: 
     301                label = trc.station 
     302            # ... and component name 
     303            if trc.comp: 
     304                label += " " + trc.comp 
     305 
     306            try: 
     307                ax.set_ylabel(label, rotation='horizontal') 
     308            except: 
     309                pass 
     310 
     311            # no ticks for upper traces 
     312            if i < len(self)-1: 
     313                ax.xaxis.set_major_locator(pylab.NullLocator()) 
     314            else: 
     315                ax.xaxis.tick_bottom() 
     316 
     317            pylab.plot(np.arange(0, trc.delta * trc.length, trc.delta), trc.fetchData(), "k", linewidth=.5) 
     318 
     319            # add some extra space around traces 
     320            limit = abs(max(pylab.ylim(), key=abs)) * 1.1 
     321            pylab.ylim(-limit, limit) 
     322 
     323        if save: 
     324            pass 
     325        else: 
     326            pylab.show() 
     327 
    272328if __name__ == "__main__": 
    273329    t = Traces() 
    274330    from SeismicHandler.core.commands import Run 
    275     from SeismicHandler.core.modules.Graphics import pylab 
    276331 
    277332    EventManager.block(Event(EventManager.REDRAW)) 
     
    283338 
    284339    Run("sum all") 
    285  
    286340    EventManager.unblock(Event(EventManager.REDRAW)) 
    287341 
    288     fig = pylab.figure() 
    289     pylab.subplots_adjust(hspace=0.00001,wspace=20) 
    290  
    291     for i, trc in enumerate(t): 
    292         trc.station = "TST%u" % i 
    293         trc.zoom = 5.5 
    294         trc.comment = "Tell me what you think of me #%u" % i 
    295         trc.chan1 = "B" 
    296         trc.chan2 = "H" 
    297         trc.comp = "N" 
    298  
    299         EventManager.trigger(Event(EventManager.REDRAW)) 
    300  
    301 #        trc.listInfo() 
    302  
    303         ax = pylab.subplot(len(t),1,i+1) 
    304  
    305         # don't show axis ticks except for last one 
    306         if i < len(t)-1: 
    307             ax.xaxis.set_major_locator(pylab.NullLocator()) 
    308  
    309         pylab.plot(np.arange(0, trc.delta * trc.length, trc.delta), trc.fetchData(), "k") 
    310 #        trc.plot() 
    311  
    312     pylab.show() 
     342    t.plot(True) 
  • SHX/trunk/src/SeismicHandler/core/shlib.py

    r149 r151  
    165165            fct(trc, ientry, value, C.byref(status)) 
    166166 
     167        EventManager.trigger(Event(EventManager.TRACEUPDATE)) 
    167168        if status.value: 
    168169            logger.error("could not set info entry '%s'" % name) 
  • SHX/trunk/src/SeismicHandler/startup.py

    r146 r151  
    3838from SeismicHandler.core.modules.Variables import System, Symbol 
    3939from SeismicHandler.core.modules.Trace import Traces as xTraces 
     40from SeismicHandler.core.modules import Tools 
     41from SeismicHandler.core.modules.Events import Event, EventManager 
    4042 
    4143# access to traces 
     
    5456        try: 
    5557            Run(options.args[0]) 
     58            # After running script from command line, update trace information.  
     59            EventManager.trigger(Event(EventManager.TRACEUPDATE)) 
    5660        except IndexError: 
    5761            pass 
  • SHX/trunk/src/SeismicHandler/tests/test_commands.py

    r149 r151  
    484484        Run("@READF/FMT=5 %s ALL" % convertFilename("data/GRF_031102_0225.GSE")) 
    485485        self.assertEqual(int(System.tottrcs), 19) 
     486#        self.traces.plot() 
    486487 
    487488    def testReads(self): 
  • SHX/trunk/src/SeismicHandler/tests/test_traces.py

    r144 r151  
    118118    def testInfoEntriesPy(self): 
    119119        # set values via python 
     120        EventManager.block(Event(EventManager.TRACEUPDATE)) 
    120121        self.trace.station = "FOOBAR" 
    121122        self.trace.chan1 = "E" 
     
    124125        self.trace.comment = "comment with blanks" 
    125126        self.trace.zoom = 5 
    126  
    127         EventManager.trigger(Event(EventManager.REDRAW)) 
     127        EventManager.unblock(Event(EventManager.TRACEUPDATE)) 
    128128 
    129129        self.assertEqual(self.trace.alloc, 1000) 
Note: See TracChangeset for help on using the changeset viewer.