@@ -465,8 +465,7 @@ HypoDD::relocate(CatalogPtr& catalog,
465
465
//
466
466
for (const NeighboursPtr& neighbours : neighbourCats)
467
467
{
468
- catalog = addObservations (solver, catalog, neighbours, keepNeighboursFixed,
469
- xcorr, obsparams);
468
+ addObservations (solver, catalog, neighbours, keepNeighboursFixed, xcorr, obsparams);
470
469
}
471
470
obsparams.addToSolver (solver);
472
471
@@ -493,6 +492,12 @@ HypoDD::relocate(CatalogPtr& catalog,
493
492
//
494
493
// solve the system
495
494
//
495
+ SEISCOMP_INFO (" Solving iteration %lu num events %u (dampingFactor %.2f "
496
+ " downWeightingByResidual %.2f meanShiftConstrainWeight %.2f,%.2f,%.2f,%.2f)" ,
497
+ iteration, neighbourCats.size (), dampingFactor, downWeightingByResidual,
498
+ meanLonShiftConstraint, meanLatShiftConstraint,
499
+ meanDepthShiftConstraint, meanTTShiftConstraint);
500
+
496
501
try {
497
502
solver.solve (_cfg.solver .solverIterations , dampingFactor,
498
503
downWeightingByResidual, meanLonShiftConstraint,
@@ -508,22 +513,6 @@ HypoDD::relocate(CatalogPtr& catalog,
508
513
509
514
// update event parameters
510
515
catalog = updateRelocatedEvents (solver, catalog, neighbourCats, obsparams);
511
-
512
- vector<double > rms;
513
- for (const NeighboursPtr& neighbours : neighbourCats)
514
- {
515
- const Event& ev = catalog->getEvents ().at (neighbours->refEvId );
516
- if ( ev.relocInfo .isRelocated ) rms.push_back (ev.rms );
517
- }
518
- SEISCOMP_INFO (" Iteration %u dampingFactor %.2f downWeightingByResidual %.2f "
519
- " meanShiftConstrainWeight %.2f,%.2f,%.2f,%.2f" ,
520
- iteration, dampingFactor, downWeightingByResidual,
521
- meanLonShiftConstraint, meanLatShiftConstraint,
522
- meanDepthShiftConstraint, meanTTShiftConstraint);
523
- const double median = computeMedian (rms);
524
- const double MAD = computeMedianAbsoluteDeviation (rms, median);
525
- SEISCOMP_INFO (" Events Rms: median %.4f median absolute deviation %.4f" ,
526
- median*1000 , MAD*1000 );
527
516
}
528
517
529
518
// build the relocated catalog from the results of relocations
@@ -547,13 +536,15 @@ string HypoDD::relocationReport(const CatalogCPtr& relocatedEv)
547
536
if ( ! event.relocInfo .isRelocated )
548
537
return " Event not relocated" ;
549
538
550
- return stringify (" Rms residual %.3f [sec]. Neighboring events %u "
551
- " Num observations: initial %u (avg. weight %.2f) final %u (avg. weight %.2f). "
552
- " Num cross-correlated observations: P phases %u S phases %u. "
539
+ return stringify (" Rms residual %.3f [sec]. Neighboring events %u used P %u used S %u. "
540
+ " Num observations: %u (avg. a priory weight %.2f final weight %.2f). "
541
+ " Num xcross observations: P phases %u S phases %u. "
553
542
" Num absolute TT diff observations: P phases %u S phases %u" ,
554
- event.rms , event.relocInfo .numNeighbours ,
555
- event.relocInfo .numObservs , event.relocInfo .meanObsWeight ,
556
- event.relocInfo .numFinalObservs , event.relocInfo .meanFinalObsWeight ,
543
+ event.rms , event.relocInfo .numNeighbours ,
544
+ event.relocInfo .usedP , event.relocInfo .usedS ,
545
+ (event.relocInfo .numCCp +event.relocInfo .numCCs +
546
+ event.relocInfo .numCTp +event.relocInfo .numCTs ),
547
+ event.relocInfo .meanObsWeight , event.relocInfo .meanFinalObsWeight ,
557
548
event.relocInfo .numCCp , event.relocInfo .numCCs ,
558
549
event.relocInfo .numCTp , event.relocInfo .numCTs );
559
550
}
@@ -564,17 +555,13 @@ string HypoDD::relocationReport(const CatalogCPtr& relocatedEv)
564
555
* differential travel times from cross correlation for pairs of
565
556
* earthquakes
566
557
*/
567
- CatalogPtr
558
+ void
568
559
HypoDD::addObservations (Solver& solver, const CatalogCPtr& catalog, const NeighboursPtr& neighbours,
569
560
bool keepNeighboursFixed, const XCorrCache& xcorr,
570
561
ObservationParams& obsparams ) const
571
562
{
572
563
// copy event because we'll update it
573
- Event refEv = catalog->getEvents ().at (neighbours->refEvId );
574
- refEv.relocInfo .numCCp = 0 ;
575
- refEv.relocInfo .numCCs = 0 ;
576
- refEv.relocInfo .numCTp = 0 ;
577
- refEv.relocInfo .numCTs = 0 ;
564
+ const Event& refEv = catalog->getEvents ().at (neighbours->refEvId );
578
565
579
566
//
580
567
// loop through reference event phases
@@ -634,6 +621,7 @@ HypoDD::addObservations(Solver& solver, const CatalogCPtr& catalog, const Neighb
634
621
double weight = _cfg.solver .usePickUncertainty
635
622
? (refPhase.procInfo .weight + phase.procInfo .weight ) / 2.0
636
623
: 1.0 ;
624
+ bool isXcorr = false ;
637
625
//
638
626
// Check if we have xcorr results for current event/refEvent pair at station/phase
639
627
// and use those instead
@@ -644,25 +632,17 @@ HypoDD::addObservations(Solver& solver, const CatalogCPtr& catalog, const Neighb
644
632
const auto & xcdata = xcorr.get (refEv.id , event.id , refPhase.stationId , refPhase.procInfo .type );
645
633
diffTime -= xcdata.lag ;
646
634
weight *= _cfg.solver .xcorrObsWeight ;
647
- if (refPhase.procInfo .type == Phase::Type::P) refEv.relocInfo .numCCp ++;
648
- if (refPhase.procInfo .type == Phase::Type::S) refEv.relocInfo .numCCs ++;
635
+ isXcorr = true ;
649
636
}
650
637
else
651
638
{
652
639
weight *= _cfg.solver .absTTDiffObsWeight ;
653
- if (refPhase.procInfo .type == Phase::Type::P) refEv.relocInfo .numCTp ++;
654
- if (refPhase.procInfo .type == Phase::Type::S) refEv.relocInfo .numCTs ++;
655
640
}
656
641
657
642
solver.addObservation (refEv.id , event.id , refPhase.stationId , phaseTypeAsChar,
658
- diffTime, weight, true , !keepNeighboursFixed);
643
+ diffTime, weight, true , !keepNeighboursFixed, isXcorr );
659
644
}
660
645
}
661
-
662
- // save back the computed refEv.relocInfo.numCC/CT P/S information
663
- CatalogPtr returnCat (new Catalog (*catalog) );
664
- returnCat->updateEvent (refEv);
665
- return returnCat;
666
646
}
667
647
668
648
void
@@ -710,6 +690,7 @@ HypoDD::updateRelocatedEvents(const Solver& solver,
710
690
unordered_map<string,Station> stations = catalog->getStations ();
711
691
map<unsigned ,Event> events = catalog->getEvents ();
712
692
unordered_multimap<unsigned ,Phase> phases = catalog->getPhases ();
693
+ unsigned relocatedEvs = 0 ;
713
694
714
695
for (const NeighboursPtr& neighbours : neighbourCats)
715
696
{
@@ -728,19 +709,26 @@ HypoDD::updateRelocatedEvents(const Solver& solver,
728
709
continue ;
729
710
}
730
711
712
+ relocatedEvs++;
713
+
731
714
event.latitude += deltaLat;
732
715
event.longitude += deltaLon;
733
716
event.depth += deltaDepth;
734
717
event.time += Core::TimeSpan (deltaTT);
735
718
event.relocInfo .isRelocated = true ;
736
719
event.relocInfo .numNeighbours = neighbours->numNeighbours ;
737
720
738
- event.rms = 0 .;
739
- event.relocInfo .numObservs = 0 ;
740
- event.relocInfo .numFinalObservs = 0 ;
721
+ event.relocInfo .usedP = 0 ;
722
+ event.relocInfo .usedS = 0 ;
723
+ event.relocInfo .numCCp = 0 ;
724
+ event.relocInfo .numCCs = 0 ;
725
+ event.relocInfo .numCTp = 0 ;
726
+ event.relocInfo .numCTs = 0 ;
741
727
event.relocInfo .meanObsWeight = 0 ;
742
728
event.relocInfo .meanFinalObsWeight = 0 ;
729
+ event.rms = 0 .;
743
730
731
+ unsigned rmsCount = 0 ;
744
732
unsigned pCount = 0 ;
745
733
auto eqlrng = phases.equal_range (event.id );
746
734
for (auto it = eqlrng.first ; it != eqlrng.second ; ++it)
@@ -751,52 +739,64 @@ HypoDD::updateRelocatedEvents(const Solver& solver,
751
739
752
740
phase.relocInfo .isRelocated = false ;
753
741
754
- unsigned startingObservations, finalObservations ;
755
- double totalAPrioriWeight, totalFinalWeight ;
742
+ unsigned startingObservations, startingXcorrObservations, totalFinalObservations ;
743
+ double meanAPrioriWeight, meanFinalWeight ;
756
744
if ( ! solver.getObservationParamsChanges (event.id , station.id , phaseTypeAsChar,
757
- startingObservations, finalObservations,
758
- totalAPrioriWeight, totalFinalWeight) )
745
+ startingObservations,
746
+ startingXcorrObservations,
747
+ totalFinalObservations,
748
+ meanAPrioriWeight,
749
+ meanFinalWeight) )
759
750
{
760
751
continue ;
761
752
}
762
753
763
- if ( finalObservations == 0 )
764
- continue ;
754
+ event.relocInfo .meanObsWeight += meanAPrioriWeight;
755
+ event.relocInfo .meanFinalObsWeight += meanFinalWeight;
756
+ ++pCount;
757
+
758
+ if ( meanFinalWeight == 0 || totalFinalObservations == 0 )
759
+ continue ;
765
760
766
761
phase.relocInfo .isRelocated = true ;
767
- phase.relocInfo .finalWeight = phase.procInfo .weight * totalFinalWeight / totalAPrioriWeight ;
768
- phase.relocInfo .numObservs = startingObservations;
769
- phase.relocInfo .numFinalObservs = finalObservations ;
770
- phase.relocInfo .meanObsWeight = totalAPrioriWeight / startingObservations ;
771
- phase.relocInfo .meanFinalObsWeight = totalFinalWeight / finalObservations ;
762
+ phase.relocInfo .finalWeight = phase.procInfo .weight * meanFinalWeight / meanAPrioriWeight ;
763
+ phase.relocInfo .numObservs = startingObservations;
764
+ phase.relocInfo .numXcorrObservs = startingXcorrObservations ;
765
+ phase.relocInfo .meanObsWeight = meanAPrioriWeight ;
766
+ phase.relocInfo .meanFinalObsWeight = meanFinalWeight ;
772
767
773
768
try {
774
769
obsparams.add (_ttt, event, station, phaseTypeAsChar);
775
- } catch ( exception &e ) {
776
- SEISCOMP_DEBUG (" Skipping observation parameter (ev %u sta %s phase %c): %s" ,
777
- event.id , station.id .c_str (), phaseTypeAsChar, e.what ());
778
- continue ;
779
- }
780
-
781
- double travelTime = obsparams.get (event.id , station.id , phaseTypeAsChar).travelTime ;
782
- phase.relocInfo .residual = travelTime - (phase.time - event.time ).length ();
770
+ double travelTime = obsparams.get (event.id , station.id , phaseTypeAsChar).travelTime ;
771
+ phase.relocInfo .residual = travelTime - (phase.time - event.time ).length ();
772
+ rmsCount++;
773
+ } catch ( exception &e ) { }
783
774
784
775
event.rms += (phase.relocInfo .residual * phase.relocInfo .residual );
785
- event.relocInfo .numObservs += phase.relocInfo .numObservs ;
786
- event.relocInfo .numFinalObservs += phase.relocInfo .numFinalObservs ;
787
- event.relocInfo .meanObsWeight += phase.relocInfo .meanObsWeight ;
788
- event.relocInfo .meanFinalObsWeight += phase.relocInfo .meanFinalObsWeight ;
789
- ++pCount;
776
+ if ( phase.procInfo .type == Phase::Type::P )
777
+ {
778
+ event.relocInfo .usedP ++;
779
+ event.relocInfo .numCCp += phase.relocInfo .numXcorrObservs ;
780
+ event.relocInfo .numCTp += phase.relocInfo .numObservs ;
781
+ }
782
+ if ( phase.procInfo .type == Phase::Type::S )
783
+ {
784
+ event.relocInfo .usedS ++;
785
+ event.relocInfo .numCCs += phase.relocInfo .numXcorrObservs ;
786
+ event.relocInfo .numCTs += phase.relocInfo .numObservs ;
787
+ }
790
788
}
791
789
790
+ if ( rmsCount > 0 ) event.rms = std::sqrt (event.rms / rmsCount);
792
791
if ( pCount > 0 )
793
792
{
794
- event.rms = std::sqrt (event.rms / pCount);
795
793
event.relocInfo .meanObsWeight /= pCount;
796
794
event.relocInfo .meanFinalObsWeight /= pCount;
797
795
}
798
796
}
799
797
798
+ SEISCOMP_INFO (" Successfully relocated %u events" , relocatedEvs);
799
+
800
800
return new Catalog (stations, events, phases);
801
801
}
802
802
0 commit comments