Skip to content

[python] Add scoriginquality: automatic A/B/C/D origin quality grading#117

Closed
comoglu wants to merge 6 commits intoSeisComP:mainfrom
comoglu:feature/scoriginquality
Closed

[python] Add scoriginquality: automatic A/B/C/D origin quality grading#117
comoglu wants to merge 6 commits intoSeisComP:mainfrom
comoglu:feature/scoriginquality

Conversation

@comoglu
Copy link
Copy Markdown
Contributor

@comoglu comoglu commented Apr 18, 2026

Summary

Adds scoriginquality, a new SeisComP Python module that automatically assigns
an A/B/C/D quality grade to each origin using a worst-of rule, and writes the
result back as an origin Comment visible in scolv and scesv without any
additional configuration.

Grading inputs

Two categories of information are combined:

Network geometry (statistical proxies for constraint quality):

  • Azimuthal gap
  • Secondary azimuthal gap
  • Used station count
  • Minimum station distance

Direct locator output (from OriginQuality / OriginUncertainty):

  • Travel-time RMS residual (standardError)
  • Horizontal uncertainty — semi-major axis, km (maxHorizontalUncertainty, populated by LOCSAT, iLoc)
  • Depth uncertainty — km (depthUncertainty, populated by iLoc, stdloc)
  • iLoc ground truth level — GT0–GT25 (groundTruthLevel)

Parameters not present in the data are silently skipped, so the module
degrades gracefully when a locator does not populate all fields.

Default thresholds

Grade Gap Sec.Gap RMS Stations Min.Dist HorizUnc DepUnc
A ≤90° ≤135° ≤0.15s ≥10 ≤30° ≤5 km ≤5 km
B ≤135° ≤180° ≤0.30s ≥6 ≤60° ≤10 km ≤15 km
C ≤180° ≤210° ≤0.50s ≥4 ≤90° ≤20 km ≤30 km
D anything worse than C

All thresholds are fully configurable via the SeisComP config system
(quality.A.*, quality.B.*, quality.C.*).

Comment format

The comment text is multi-line — grade letter on line 1, one parameter
breakdown per line after:

B
Az. Gap: 76.3° → A
Sec. Gap: 115.1° → B
RMS: 0.937 s → D
Stations: 12 → A
Min. Dist: 18.2° → A
Horiz. Unc.: 7.4 km → B

The GUI splits on the first \n: the label shows the grade letter, the
tooltip shows the full breakdown on hover. This requires the companion PR
in common (feature/eventsummaryview-quality).

Modes of operation

Mode Flag Description
Live (default) Subscribe to LOCATION messages, grade each incoming origin
Single event --event <id> Grade preferred origin of one DB event and exit
XML file --ep <file> Grade all origins in a SeisComP XML file
All DB events --all Regrade every event in the database in one run

The --all mode is useful for backfilling grades after deployment or after
changing thresholds.

Related PRs

  • Companion GUI changes (scolv + scesv): comoglu/common:feature/eventsummaryview-quality

Test plan

  • Start scoriginquality in live mode; locate an event; confirm grade appears in scesv hypocenter panel
  • Hover grade label in scesv — confirm per-parameter breakdown tooltip
  • Run scoriginquality --event <id>; confirm comment written to DB
  • Run scoriginquality --all; confirm all events regraded (finished — graded N, skipped 0)
  • Run scoriginquality --ep file.xml; confirm grades written
  • Change a threshold in config; confirm grade changes accordingly

comoglu added 6 commits April 18, 2026 15:29
…ity grading

Subscribes to LOCATION messages and assigns a quality grade (A/B/C/D)
to each incoming origin using a worst-of rule on OriginQuality fields:
azimuthal gap, secondary azimuthal gap, RMS, used station count, and
minimum distance. The grade is written back as an origin Comment so it
is visible in scolv and other GUIs without additional configuration.
All thresholds are configurable via the SeisComP config system.
--event <id>  grades the preferred origin of a single event from the
              database and writes the comment back via messaging, then
              exits. Uses loadObject() to resolve both event and origin
              by publicID, and syncOutbox() to flush before disconnect.

--ep <file>   grades all origins in a SeisComP XML file.

Also enables database by default so batch modes have a DB connection,
and consolidates the config/threshold loop to reduce repetition.
Comment text is now multi-line: grade on line 1, one parameter per line
after (e.g. "Az. Gap: 76.3° → A"). The GUI splits on the first newline —
label shows the grade letter, tooltip shows the full breakdown.
Incorporates direct locator output alongside network geometry proxies:
  - maxHorizontalUncertainty (semi-major axis, km) from OriginUncertainty
  - depthUncertainty (km) from OriginUncertainty
  - groundTruthLevel (GT0-GT25) from OriginQuality, populated by iLoc

Default thresholds: horizUnc A≤5/B≤10/C≤20 km, depUnc A≤5/B≤15/C≤30 km.
GT0/GT1→A, GT2/GT5→B, GT10/GT25→C. All configurable.

Updates XML description with new parameters and clarifies that grading
combines both network geometry proxies and direct locator quality output.
@cla-bot cla-bot Bot added the cla-signed The CLA has been signed by all contributors label Apr 18, 2026
@gempa-jabe
Copy link
Copy Markdown
Contributor

Hi @comoglu, I don't think that we will merge this new application which assigns a quality which is specific to your particular needs. I think that such a module is better suited for a private repository which you can use in your particular setup. Maybe other users can also test it and if that could be defined as kind of standard, we can think about adding that to SeisComP. What do you think?

@jsaul
Copy link
Copy Markdown
Contributor

jsaul commented Apr 20, 2026

The contribution by @comoglu is highly appreciated but I second @gempa-jabe's view that (at this point) this is too specific to be included in main. How about some (offline) brainstorming in the forum and/or via email? I am sure there are others with broadly similar requirements for summary quality ratings and a discussion might result in a more generic module.

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 20, 2026

Hi @gempa-jabe,
thanks for the feedback, this is actually still a draft PR, so there are things not yet finalised on our end. Your comment is useful motivation to get there. :)

A few points worth considering:

It's not network-specific. All thresholds are configurable via the SeisComP config system (quality.A., quality.B., quality.C.*), and the grade labels themselves are also configurable — users could substitute numbers, roman numerals, or any custom scheme if preferred. Parameters that the locator doesn't populate are silently skipped, so it degrades gracefully with LOCSAT, iLoc, or stdloc, or any implementation through LocExt.

There's a companion GUI PR (SeisComP/common#194) that adds quality grade display with tooltip breakdown to both the scolv Location tab and the scesv hypocenter panel, no config required. I think it can be useful for anyone who would like to use it.

As it is still in progress, I'd like to finalise both PRs together before asking for a proper review. I'll update once ready and would welcome feedback at that point on whether the approach could be considered more broadly.

@gempa-jabe
Copy link
Copy Markdown
Contributor

OK, I will sit and wait until the draft flag has been removed. As we do not get so many PRs, it is OK right now to keep yours active here. But imagine the situation with many PRs which are all draft but active. I get notifications all the time and I am alert to do something although it is not required at this stage. So it would make sense to me if you tell us where you are implementing something interesting (a branch in your repo) and we could comment. Once you are satisfied and ready with your implementation, you can issue the PR to let us check after discussions have happened.

There's a companion GUI PR (SeisComP/common#194) that adds quality grade display with tooltip breakdown to both the scolv Location tab and the scesv hypocenter panel, no config required. I think it can be useful for anyone who would like to use it.

As this is fully generic, it adds optional functionality not tight to a particular method. As it is in draft state as well, I stay silent ;).

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 20, 2026

Hi @jsaul @gempa-jabe ,
Thank you both. Fair points. :)

One thing I'd like to understand: how should quality information like this be displayed in scolv and scesv if this feature is outside of the main branch? I imagine once the actual product is ready I can create a separate PR for that specific feature.

@gempa-jabe
Copy link
Copy Markdown
Contributor

how should quality information like this be displayed in scolv and scesv if this feature is outside of the main branch?

Isn't that part of SeisComP/common#194?

The changes in common will allow to show any arbitrary comments according to your implementation. How and if at all those comments are populated is up to the user. She could use your tool or another one. Is that what you were asking?

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 20, 2026

Yes, exactly!
Let me remove the hardcoded, specific tooltips as I am working on them.
Thank you.

@comoglu comoglu closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The CLA has been signed by all contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants