Changeset 149
- Timestamp:
- 09/09/2009 04:26:54 PM (13 years ago)
- Location:
- SHX/trunk/src/SeismicHandler
- Files:
-
- 9 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
SHX/trunk/src/SeismicHandler/core/shheaders.py
r139 r149 3 3 # Copyright (C) 2008-2010 Marcus Walther (walther@szgrf.bgr.de) 4 4 # 5 # This file is part of Seismic Handler eXtended (SHX) 5 # This file is part of Seismic Handler eXtended (SHX) 6 6 # Full details can be found at project website http://www.seismic-handler.org/ 7 # 7 # 8 8 # SHX is free software; you can redistribute it and/or modify 9 9 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by … … 53 53 "char": 40, 54 54 "time": 15, 55 "pointer": 8 55 "pointer": 8 56 56 } 57 57 58 58 class PARAM(C.Structure): 59 59 """Command parameter structure 60 60 61 61 originally defined in cpusrdef.h as 62 62 … … 64 64 #define CPC_MAXQUAL 5 65 65 #define CPC_LINELTH 2048 66 66 67 67 typedef struct param { 68 68 int pno; /* number of parameters */ … … 85 85 class TIME(C.Structure): 86 86 """Time structure 87 87 88 88 originally defined in tcusrdef.h as 89 89 90 90 typedef struct timblc { 91 91 unsigned long hi; 92 92 unsigned int lo; 93 93 } TIME;""" 94 94 95 95 _fields_ = [ 96 96 ("hi", C.c_ulong), -
SHX/trunk/src/SeismicHandler/core/shlib.py
r146 r149 146 146 "flag": "db_setf", # XXX 147 147 "pointer": "db_setp", # XXX not needed (still unchangeable) 148 "time": "db_sett", # XXX148 "time": "db_sett", 149 149 } 150 150 … … 160 160 value = vmap(value) 161 161 162 fct(trc, ientry, value, C.byref(status)) 162 if dattype == "time": 163 fct(trc, ientry, C.byref(value), C.byref(status)) 164 else: 165 fct(trc, ientry, value, C.byref(status)) 163 166 164 167 if status.value: -
SHX/trunk/src/SeismicHandler/tests/test_commands.py
r148 r149 6 6 from SeismicHandler.core.modules.Tools import convertFilename 7 7 from SeismicHandler.core.commands import Run 8 from SeismicHandler.core.shheaders import TIME 8 9 9 10 import pickle … … 292 293 # self.traces[1].plot() 293 294 self.checkTraceData(self.traces[1], cmpindex="fft") 294 295 295 296 def testFilter(self): 296 297 Run("create spike 0.05 50 20 20") 297 298 Run("fili f BP_2S_10HZ_4") 298 299 Run("filter f 1") 299 300 300 301 self.checkTraceData(self.traces[1], cmpindex="filter", digits=5) 301 302 302 303 testFili = testFilter 303 304 304 305 def testFold(self): 305 Run("cresharp") 306 Run("cresharp") 307 Run("fold 1 10 20 2") 308 306 Run("cresharp") 307 Run("cresharp") 308 Run("fold 1 10 20 2") 309 309 310 self.checkTraceData(self.traces[2], cmpindex="fold", digits=5) 310 311 311 312 def testGoto(self): 312 313 # This command is already replaced by python 313 314 pass 314 315 315 316 def testHc(self): 316 317 # This function is not useful in python context. 317 318 pass 318 319 319 320 def testHelp(self): 320 321 # This function is not useful in python context. 321 322 pass 322 323 323 324 def testHide(self): 324 325 # XXX Commands for visualisation are not tested yet. 325 326 pass 326 327 327 328 def testIf(self): 328 329 # This command is already replaced by python 329 330 pass 330 331 331 332 def testInt(self): 332 333 Run("cresharp") 333 334 Run("int 1") 334 335 335 336 self.checkTraceData(self.traces[1], cmpindex="int", digits=5) 336 337 337 338 def testLocate(self): 338 # XXX not tested since it depends on AL command 339 pass 340 339 # XXX not tested since it depends on AL command 340 pass 341 341 342 def testMark(self): 342 343 # XXX Commands for visualisation are not tested yet. 343 344 pass 344 345 345 346 def testMaxAmpl(self): 346 347 Run("cresharp") … … 348 349 Run("maxampl 1 35") 349 350 self.checkTraceData(self.traces[0], cmpindex="maxampl", digits=5) 350 351 351 352 def testMaximum(self): 352 353 Run("cresharp") … … 356 357 self.checkTraceData(self.traces[2], cmpindex="maximum1") 357 358 self.checkTraceData(self.traces[3], cmpindex="maximum2") 358 359 def test 2Mdir(self):360 for iin range(3):359 360 def testMdir(self): 361 for _ in range(3): 361 362 Run("cresharp") 362 363 363 364 Run("mirror 2") 364 365 365 366 Symbol.azi = 0. 366 367 Symbol.inci = 0. 367 368 368 369 Run("mdir 1,2 10. 20. &azi") 369 370 self.assertAlmostEqual(Symbol.azi, 6.271768) 370 371 371 372 Run("mdir 1-3 10. 20. &azi &inci") 372 373 self.assertAlmostEqual(Symbol.azi, 263.763123, 4) 373 374 self.assertAlmostEqual(Symbol.inci, 45.170059, 5) 374 375 375 376 Symbol.azi = None 376 Symbol.inci = None 377 377 Symbol.inci = None 378 379 def testMend(self): 380 Run("cresharp") 381 Run("mend 1 6 10 30") 382 self.checkTraceData(self.traces[0], cmpindex="mend") 383 384 def testMerge(self): 385 Run("cresharp") 386 Run("cresharp") 387 388 # shift trace #2 by 21 seconds 389 t = TIME() 390 t.hi = self.traces[1].start.hi + 21 391 t.lo = 0 392 self.traces[1].start = t 393 394 Run("merge 2 1") 395 396 self.checkTraceData(self.traces[2], cmpindex="merge") 397 398 def testMergePair(self): 399 # create three traces of which two are "mergeable" (identical source) 400 for _ in range(3): 401 Run("cresharp") 402 403 trc1 = self.traces.get(1) 404 trc2 = self.traces.get(2) 405 trc3 = self.traces.get(3) 406 407 trc1.comp = trc2.comp = trc3.comp = "Z" 408 trc1.station = trc3.station = "TST" 409 trc2.station = "TTT" 410 trc1.chan1 = trc2.chan1 = trc3.chan1 = "B" 411 trc1.chan2 = trc2.chan2 = trc3.chan2 = "H" 412 413 Symbol.one = 0 414 Symbol.two = 0 415 416 Run("merge_pair &one &two") 417 418 self.assertEqual(Symbol.one, 1) 419 self.assertEqual(Symbol.two, 3) 420 421 def testMirror(self): 422 Run("cresharp") 423 Run("mirror 1") 424 425 check = self.loadCompare("cresharp")[::-1] 426 self.checkTraceData(self.traces[0], cmp=check) 427 428 def testNorm(self): 429 # XXX Commands for visualisation are not tested yet. 430 pass 431 432 def testNr(self): 433 # XXX Commands for visualisation are not tested yet. 434 pass 435 436 def testOverlay(self): 437 # XXX Commands for visualisation are not tested yet. 438 pass 439 378 440 def testPick(self): 379 441 # read real world data (@ = don't convert case of this command) … … 381 443 # create symbol 382 444 Symbol.x = "" 383 445 384 446 Run("pick 1 0 200 &x") 385 447 self.assertEqual(Symbol.x, " 2-NOV-2003_02:26:43.500") 386 448 387 449 # delete symbol 388 450 Symbol.x = None 389 451 452 def testPmch(self): 453 # XXX Commands for visualisation are not tested yet. 454 pass 455 456 def testPm(self): 457 # XXX Commands for visualisation are not tested yet. 458 pass 459 460 def testPolFil(self): 461 self.fail("no test case created") 462 463 def testQuit(self): 464 # no need to test this 465 pass 466 467 def testRd(self): 468 # XXX Commands for visualisation are not tested yet. 469 pass 470 471 def testRead(self): 472 Run("@READ %s 1" % convertFilename("data/cresharp")) 473 self.checkTraceData(self.traces[0], cmpindex="cresharp") 474 475 def testReada(self): 476 Run("@READA %s" % convertFilename("data/CRESHARP.asc")) 477 self.checkTraceData(self.traces[0], cmpindex="cresharp") 478 479 # I set a comment containing recipe how the trace was compiled. 480 self.assertEqual(self.traces[0].comment, "CRESHARP") 481 482 def testReadf(self): 483 # Just test for GSE2 format 484 Run("@READF/FMT=5 %s ALL" % convertFilename("data/GRF_031102_0225.GSE")) 485 self.assertEqual(int(System.tottrcs), 19) 486 487 def testReads(self): 488 self.fail("no test created yet!") 489 490 def testResample(self): 491 Run("cresharp") 492 Run("resample 1 .01") 493 494 # resample does not trigger redraw 495 EventManager.trigger(Event(EventManager.TRACEUPDATE)) 496 497 self.assertAlmostEqual(self.traces[-1].delta, 0.01) 498 self.assertAlmostEqual(self.traces[-1].length, 5000) 499 self.assertAlmostEqual(self.traces[-1].alloc, 5000) 500 501 def testReturn(self): 502 # This function is not useful in python context. 503 pass 504 505 def testRms(self): 506 Run("cresharp") 507 Symbol.rms = 0. 508 Run("rms 1 ;;; &rms") 509 510 self.assertAlmostEqual(Symbol.rms, 0.2942311) 511 512 Symbol.rms = None 513 514 def testRot(self): 515 Run("cresharp") 516 Run("cresharp") 517 Run("rot 1,2 45") 518 519 # Trace 3 now contains only zeros, while trace 4 holds all energy. 520 self.checkTraceData(self.traces[2], cmp=[0.]*self.traces[-2].length) 521 self.checkTraceData(self.traces[3], cmpindex="rot", digits=6) 522 523 def testSdef(self): 524 # This function is not useful in python context. 525 pass 526 527 def testSdel(self): 528 # This function is not useful in python context. 529 pass 530 531 def testSet(self): 532 # This function is not useful in python context. 533 pass 534 535 def testShift(self): 536 # XXX Commands for visualisation are not tested yet. 537 pass 538 539 def testSpecDiv(self): 540 self.fail("no test created!") 541 542 def testSpectrogram(self): 543 import tempfile 544 tmp = tempfile.mktemp() 545 del tempfile 546 547 Run("cresharp") 548 Run("@SPECTROGRAM 1 ;;; 128 2 %s" % convertFilename(tmp)) 549 550 self.assertEqual(open(tmp).readlines(), open("data/spectrogram.out").readlines()) 551 552 os.remove(tmp) 553 554 def testSpectrum(self): 555 self.fail("no test created!") 556 390 557 def testSum(self): 391 558 # this test fails for some reason … … 399 566 400 567 # create 2 identical synthetics with "seconds" length, 1/"delta" Hz 401 for iin xrange(2):568 for _ in xrange(2): 402 569 Run("CREATE SHARP %.2f %u 1. 15. .1 .5" % (delta, seconds)) 403 570
Note: See TracChangeset
for help on using the changeset viewer.