Changeset 151
- Timestamp:
- 09/21/2009 09:13:56 AM (14 years ago)
- Location:
- SHX/trunk/src/SeismicHandler
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
SHX/trunk/src/SeismicHandler/core/modules/Trace.py
r146 r151 270 270 return self.tracedata[self.traces[number-1]] 271 271 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 272 328 if __name__ == "__main__": 273 329 t = Traces() 274 330 from SeismicHandler.core.commands import Run 275 from SeismicHandler.core.modules.Graphics import pylab276 331 277 332 EventManager.block(Event(EventManager.REDRAW)) … … 283 338 284 339 Run("sum all") 285 286 340 EventManager.unblock(Event(EventManager.REDRAW)) 287 341 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 165 165 fct(trc, ientry, value, C.byref(status)) 166 166 167 EventManager.trigger(Event(EventManager.TRACEUPDATE)) 167 168 if status.value: 168 169 logger.error("could not set info entry '%s'" % name) -
SHX/trunk/src/SeismicHandler/startup.py
r146 r151 38 38 from SeismicHandler.core.modules.Variables import System, Symbol 39 39 from SeismicHandler.core.modules.Trace import Traces as xTraces 40 from SeismicHandler.core.modules import Tools 41 from SeismicHandler.core.modules.Events import Event, EventManager 40 42 41 43 # access to traces … … 54 56 try: 55 57 Run(options.args[0]) 58 # After running script from command line, update trace information. 59 EventManager.trigger(Event(EventManager.TRACEUPDATE)) 56 60 except IndexError: 57 61 pass -
SHX/trunk/src/SeismicHandler/tests/test_commands.py
r149 r151 484 484 Run("@READF/FMT=5 %s ALL" % convertFilename("data/GRF_031102_0225.GSE")) 485 485 self.assertEqual(int(System.tottrcs), 19) 486 # self.traces.plot() 486 487 487 488 def testReads(self): -
SHX/trunk/src/SeismicHandler/tests/test_traces.py
r144 r151 118 118 def testInfoEntriesPy(self): 119 119 # set values via python 120 EventManager.block(Event(EventManager.TRACEUPDATE)) 120 121 self.trace.station = "FOOBAR" 121 122 self.trace.chan1 = "E" … … 124 125 self.trace.comment = "comment with blanks" 125 126 self.trace.zoom = 5 126 127 EventManager.trigger(Event(EventManager.REDRAW)) 127 EventManager.unblock(Event(EventManager.TRACEUPDATE)) 128 128 129 129 self.assertEqual(self.trace.alloc, 1000)
Note: See TracChangeset
for help on using the changeset viewer.