Skip to content

Commit

Permalink
STY: remove cryptic stats
Browse files Browse the repository at this point in the history
Remove neigh_meanDistToCentroid, neigh_centroidToEventDist,
neigh_meanDepthDistToCentroid and neigh_centroidToEventDepthDist
  • Loading branch information
luca-s committed Oct 9, 2021
1 parent 1c42da1 commit 6ad0c65
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 90 deletions.
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ Details of the solutions for each iteration of the solver

### 6.3 Relocation statistics

`scrtdd` adds two comments to each relocated origin: `scrtddSourceOrigin` and `scrtddRelocationReport`. They can be both visualized in `scolv` (see official SeisComP documentation on how to do so), or they can be seen on the logs.
`scrtdd` adds two comments to each relocated origin: `scrtddSourceOrigin` and `scrtddRelocationReport`. They can be both visualized in `scolv` (see official SeisComP documentation on how to visualize comments as additional columns), or they can be seen on the logs.

`scrtddSourceOrigin` contains the id of the origin that triggered the relocation. `scrtddRelocationReport` contains a summary of the relocation process. E.g.

Expand All @@ -914,34 +914,20 @@ Origin changes: location=0.23[km] depth=1.40[km] time=-0.147[sec]
Rms change [sec]: -0.153 (before/after 0.502/0.349)
Neighbours=80 Used Phases: P=37 S=16
Stations distance [km]: min=15.9 median=57.0 max=99.8
Neighbours mean distace to centroid [km]: location=5.11 depth=5.06
Origin distace to neighbours centroid [km]: location=1.30 depth=3.01
DD observations: 687 (CC P/S 141/47 TT P/S 375/124)
DD observations residuals [msec]: before=-106+/-21.6 after=9+/-26.2
```

To allow a comparison of the RMS before and after the relocation `scrtdd` computes the RMS before and after the relocation. Without that it would be hard to compare the RMSs. Each locator (scautoloc, scanloc, screloc, nonlinloc, scrtdd, etc) computes the RMS with a certain travel time table, that might not be the same as `scrtdd`. Moreover, a locator might apply a specific logic on the RMS computation that prevents a comparison between different locators. For example NonLinLoc locator weighs the residuals by each pick weight and the wighting scheme is decided by NonLinLoc.
`scrtdd` computes the RMS after but also before the relocation, to allow for a comparison of the RMS change. The computation of the initial RMS is required for a sensible comparison. It is not possible to look at the RMS of the starting origin, since each locator (scautoloc, scanloc, screloc, nonlinloc, scrtdd, etc) computes the RMS with a travel time table that might not be the same as `scrtdd`. Moreover, a locator might apply a specific logic to the RMS computation, which prevents a comparison between RMS computed by different locators. For example NonLinLoc locator weighs the residuals used in the RMS by each pick weight and the wighting scheme is decided by NonLinLoc. That makes the RMS unsuitable for cross-locator comparisons.

The following two lines can be a little cryptic to interpret:
```
Neighbours mean distace to centroid [km]: location=5.11 depth=5.06
Origin distace to neighbours centroid [km]: location=1.30 depth=3.01
```

Their intent is to highlight how far the relocated event is to the neighbours centroid. The idea is that an event that falls within a cluster has a better chance to be properly relocated than an event that is far away from the neighbouring events.

The above information is also stored in the output files (events.csv,phases.csv,station,csv) of the multi-event relocation and it can be used to compute useful statistics for an entire catalog. Those are the column names containing the information:
All the above information is also stored in the output files (events.csv,phases.csv,station,csv) of the multi-event relocation and it can be used to compute useful statistics for an entire catalog. Those are the column names containing the information:

```
startRms
locChange
depthChange
timeChange
numNeighbours
neigh_meanDistToCentroid
neigh_centroidToEventDist
neigh_meanDepthDistToCentroid
neigh_centroidToEventDepthDist
ph_usedP
ph_usedS
ph_stationDistMin
Expand Down
26 changes: 5 additions & 21 deletions libs/hdd/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,7 @@ Catalog::Catalog(const string &stationFile,
ev.relocInfo.locChange = std::stod(row.at("locChange"));
ev.relocInfo.depthChange = std::stod(row.at("depthChange"));
ev.relocInfo.timeChange = std::stod(row.at("timeChange"));
ev.relocInfo.neighbours.amount = std::stoul(row.at("numNeighbours"));
ev.relocInfo.neighbours.meanDistToCentroid =
std::stod(row.at("neigh_meanDistToCentroid"));
ev.relocInfo.neighbours.meanDepthDistToCentroid =
std::stod(row.at("neigh_meanDepthDistToCentroid"));
ev.relocInfo.neighbours.eventDistToCentroid =
std::stod(row.at("neigh_centroidToEventDist"));
ev.relocInfo.neighbours.eventDepthDistToCentroid =
std::stod(row.at("neigh_centroidToEventDepthDist"));
ev.relocInfo.numNeighbours = std::stoul(row.at("numNeighbours"));
ev.relocInfo.phases.usedP = std::stoul(row.at("ph_usedP"));
ev.relocInfo.phases.usedS = std::stoul(row.at("ph_usedS"));
ev.relocInfo.phases.stationDistMin =
Expand Down Expand Up @@ -471,10 +463,7 @@ void Catalog::writeToFile(string eventFile,
evStreamReloc
<< evStreamNoReloc.str()
<< ",relocated,startRms,locChange,depthChange,timeChange,numNeighbours,"
"neigh_meanDistToCentroid,neigh_centroidToEventDist,"
"neigh_meanDepthDistToCentroid,neigh_centroidToEventDepthDist,"
"ph_usedP,ph_usedS,"
"ph_stationDistMin,ph_stationDistMedian,ph_stationDistMax,"
"ph_usedP,ph_usedS,ph_stationDistMin,ph_stationDistMedian,ph_stationDistMax,"
"ddObs_numTTp,ddObs_numTTs,ddObs_numCCp,ddObs_numCCs,"
"ddObs_startResidualMedian,ddObs_startResidualMAD,"
"ddObs_finalResidualMedian,ddObs_finalResidualMAD"
Expand All @@ -496,21 +485,16 @@ void Catalog::writeToFile(string eventFile,

if (!ev.relocInfo.isRelocated)
{
evStreamReloc << ",false,,,,,,,,,,,,,,,,,,,,,,";
evStreamReloc << ",false,,,,,,,,,,,,,,,,,,";
}
else
{
relocInfo = true;
evStreamReloc << stringify(
",true,%.3f,%.3f,%.3f,%.3f,%u,%.3f,%.3f,%.3f,%.3f,"
"%u,%u,%.3f,%.3f,%.3f,%u,%u,%u,%u,%.4f,%.4f,%.4f,%.4f",
",true,%.3f,%.3f,%.3f,%.3f,%u,%u,%u,%.3f,%.3f,%.3f,%u,%u,%u,%u,%.4f,%.4f,%.4f,%.4f",
ev.relocInfo.startRms, ev.relocInfo.locChange,
ev.relocInfo.depthChange, ev.relocInfo.timeChange,
ev.relocInfo.neighbours.amount,
ev.relocInfo.neighbours.meanDistToCentroid,
ev.relocInfo.neighbours.eventDistToCentroid,
ev.relocInfo.neighbours.meanDepthDistToCentroid,
ev.relocInfo.neighbours.eventDepthDistToCentroid,
ev.relocInfo.numNeighbours,
ev.relocInfo.phases.usedP, ev.relocInfo.phases.usedS,
ev.relocInfo.phases.stationDistMin,
ev.relocInfo.phases.stationDistMedian,
Expand Down
10 changes: 1 addition & 9 deletions libs/hdd/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ class Catalog : public Core::BaseObject
double locChange;
double depthChange;
double timeChange;

struct
{
unsigned amount;
double meanDistToCentroid;
double meanDepthDistToCentroid;
double eventDistToCentroid;
double eventDepthDistToCentroid;
} neighbours;
unsigned numNeighbours;

struct
{
Expand Down
46 changes: 3 additions & 43 deletions libs/hdd/hypodd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,21 +696,15 @@ string HypoDD::relocationReport(const CatalogCPtr &relocatedEv)
"Rms change [sec]: %.3f (before/after %.3f/%.3f) "
"Neighbours=%u Used Phases: P=%u S=%u "
"Stations distance [km]: min=%.1f median=%.1f max=%.1f "
"Neighbours mean distace to centroid [km]: location=%.2f depth=%.2f "
"Origin distace to neighbours centroid [km]: location=%.2f depth=%.2f "
"DD observations: %u (CC P/S %u/%u TT P/S %u/%u) "
"DD observations residuals [msec]: before=%.f+/-%.1f after=%.f+/-%.1f",
event.relocInfo.locChange, event.relocInfo.depthChange,
event.relocInfo.timeChange, (event.rms - event.relocInfo.startRms),
event.relocInfo.startRms, event.rms, event.relocInfo.neighbours.amount,
event.relocInfo.startRms, event.rms, event.relocInfo.numNeighbours,
event.relocInfo.phases.usedP, event.relocInfo.phases.usedS,
event.relocInfo.phases.stationDistMin,
event.relocInfo.phases.stationDistMedian,
event.relocInfo.phases.stationDistMax,
event.relocInfo.neighbours.meanDistToCentroid,
event.relocInfo.neighbours.meanDepthDistToCentroid,
event.relocInfo.neighbours.eventDistToCentroid,
event.relocInfo.neighbours.eventDepthDistToCentroid,
(event.relocInfo.ddObs.numCCp + event.relocInfo.ddObs.numCCs +
event.relocInfo.ddObs.numTTp + event.relocInfo.ddObs.numTTs),
event.relocInfo.ddObs.numCCp, event.relocInfo.ddObs.numCCs,
Expand Down Expand Up @@ -940,8 +934,8 @@ CatalogPtr HypoDD::updateRelocatedEvents(
event.time += Core::TimeSpan(deltaTT);
event.rms = 0;
event.relocInfo.isRelocated = true;
event.relocInfo.numNeighbours = 0;
event.relocInfo.phases = {0};
event.relocInfo.neighbours = {0};
event.relocInfo.ddObs.numTTp = 0;
event.relocInfo.ddObs.numTTs = 0;
event.relocInfo.ddObs.numCCp = 0;
Expand Down Expand Up @@ -1033,7 +1027,7 @@ CatalogPtr HypoDD::updateRelocatedEvents(
event.relocInfo.ddObs.finalResidualMedian = residualMedian;
event.relocInfo.ddObs.finalResidualMAD = residualMAD;

event.relocInfo.neighbours.amount = finalNeighbours->numNeighbours();
event.relocInfo.numNeighbours = finalNeighbours->numNeighbours();
finalNeighCluster[finalNeighbours->refEvId] = finalNeighbours;
}

Expand Down Expand Up @@ -1154,40 +1148,6 @@ CatalogPtr HypoDD::updateRelocatedEventsFinalStats(
finalEvent.relocInfo.phases.stationDistMin = *min_max.first;
finalEvent.relocInfo.phases.stationDistMax = *min_max.second;

//
// compute starting neighbours to starting event distance
//
vector<double> latDiff, lonDiff, depthDiff;
for (unsigned neighEvId : neighbours->ids)
{
const Event &neighEv = startCatalog->getEvents().at(neighEvId);
latDiff.push_back(startEvent.latitude - neighEv.latitude);
lonDiff.push_back(startEvent.longitude - neighEv.longitude);
depthDiff.push_back(startEvent.depth - neighEv.depth);
}
double meanLatDiff = computeMean(latDiff);
double meanLonDiff = computeMean(lonDiff);
double meanDepthDiff = computeMean(depthDiff);
double centroidLat = startEvent.latitude + meanLatDiff;
double centroidLon = startEvent.longitude + meanLonDiff;
// double centroidDepth = startEvent.depth + meanDepthDiff; not used

finalEvent.relocInfo.neighbours.eventDistToCentroid = computeDistance(
startEvent.latitude, startEvent.longitude, centroidLat, centroidLon);
finalEvent.relocInfo.neighbours.eventDepthDistToCentroid = meanDepthDiff;
finalEvent.relocInfo.neighbours.meanDepthDistToCentroid =
computeMeanAbsoluteDeviation(depthDiff, meanDepthDiff);

finalEvent.relocInfo.neighbours.meanDistToCentroid = 0;
for (unsigned neighEvId : neighbours->ids)
{
const Event &neighEv = startCatalog->getEvents().at(neighEvId);
finalEvent.relocInfo.neighbours.meanDistToCentroid += computeDistance(
neighEv.latitude, neighEv.longitude, centroidLat, centroidLon);
}
finalEvent.relocInfo.neighbours.meanDistToCentroid /=
neighbours->numNeighbours();

tmpCat->updateEvent(finalEvent, false);
catalogToReturn->add(finalEvent.id, *tmpCat, true);
}
Expand Down

0 comments on commit 6ad0c65

Please sign in to comment.