Skip to content

Make Mwp amplitude and magnitude parameters configurable#197

Open
comoglu wants to merge 11 commits into
SeisComP:mainfrom
comoglu:mwp-configurable-params
Open

Make Mwp amplitude and magnitude parameters configurable#197
comoglu wants to merge 11 commits into
SeisComP:mainfrom
comoglu:mwp-configurable-params

Conversation

@comoglu
Copy link
Copy Markdown
Contributor

@comoglu comoglu commented May 8, 2026

Summary

  • amplitudes.Mwp.useFirstPeak (boolean, default false) — option to use the first local maximum of the doubly-integrated displacement after the P arrival, as specified in the original Tsuboi et al. (1995) algorithm, instead of the global maximum. Default false preserves backward compatibility. The global maximum can be inflated by later arrivals (PP, pP, surface reflections) for large events, contributing to Mwp saturation at M > 7.5.

  • magnitudes.Mwp.estimateMw.a/b/stdError (double) — the Mw(Mwp) linear correction coefficients from Whitmore et al. (2002) (a=1.186, b=-1.222, stdError=0.4) were hardcoded with a // Fixme comment. They are now readable from global.cfg, allowing operators to apply updated calibrations from larger or more recent datasets without recompiling. Defaults are unchanged.

  • global_Mwp.xml — new description file exposes useFirstPeak and estimateMw.* in scconfig.

Backward compatibility

This PR is purely additive. Without any configuration changes the processor output is identical to the previous implementation in all cases.

References

  • Tsuboi et al. (1995, 1999) — Mwp algorithm
  • Whitmore et al. (2002) — Mw(Mwp) correction, Science of Tsunami Hazards 20(4), 187–193

Test plan

  • Build passes against SeisComP main source tree
  • Build passes against SeisComP v7 source tree
  • amplitudes.Mwp.useFirstPeak = true confirmed via scamp debug log: + useFirstPeak = true
  • global_Mwp.xml parameters visible in scconfig

comoglu added 9 commits May 8, 2026 17:00
Two new options for controlling the map view when an event arrives,
applied in priority order:

1. display.lonmin/max/latmin/max (already existing) — if set, the map
   is anchored to that region on every event popup, regardless of where
   the event is located. Useful for regional networks monitoring a fixed
   area (e.g. an scesv alias per region).

2. display.defaultEventRadius — configurable radius in degrees, centred
   on the event epicentre (mirrors olv.map.event.defaultRadius in scolv).
   A negative value (default) restores the original automatic behaviour
   of using the maximum arrival distance capped at 30 degrees.

If neither option is set the existing behaviour is fully preserved.
Extends the City<T> template class with three new optional attributes
to carry richer location metadata sourced from GeoNames and Natural Earth:

  type      — location type, e.g. "city", "town", "village", "suburb"
  state     — ISO 3166-2 alphabetic subdivision abbreviation, e.g. "NSW", "CA"
               Only present for countries that use alphabetic codes.
  stateFull — full administrative region name, e.g. "New South Wales"

All three fields are serialized as XML attributes (NAMED_OBJECT),
consistent with the existing countryID and category fields. They default
to empty strings and are fully backwards-compatible — existing cities.xml
files without these attributes parse without error.

This allows applications such as scolv to display type and state
information via SCApp->cities() without requiring a separate supplementary
locations file.
- City<T>: add country() / setCountry() serialised as <country> child element
- City<T>: replace state/stateFull strings with AdminRegion { abbr, name }
  serialised as <state abbr="NSW"><name>New South Wales</name></state>
- Document fixed type values: city, town, village, suburb
- Regenerate cities.xml with country names (Natural Earth), admin region
  (ISO 3166-2 abbreviation + full name via NE admin1 shapefile), and type
  (GeoNames feature codes); 70242 country names, 71654 states, 56860 types
Replace the manual enum class and custom string conversion with
MAKEENUM as suggested by @gempa-jabe. The archive now handles
string serialization automatically.
std::string members default to empty so the explicit reset is redundant
and would corrupt data on write.
CityType and AdminRegion are optional in cities.xml; using plain
types caused the archive to mark the entire City object invalid
when those attributes/elements were absent, silently dropping all
cities.  Wrap both fields in OPT() (std::optional) so the archive
skips missing fields gracefully.

type() and adminRegion() return safe defaults when the optional is
not set.
Replace British spellings: honoured→honored, unrecognised→unrecognized,
centre→center.
Three independent improvements to the Mwp processor:

1. amplitudes.Mwp.useFirstPeak (boolean, default false)
   Adds a configurable option to use the first local maximum of the
   doubly-integrated displacement after the P arrival, as described
   in the original Tsuboi et al. (1995) algorithm, instead of the
   global maximum in the signal window. Default false preserves
   backward compatibility. Later arrivals (PP, pP, surface reflections)
   can inflate the global maximum for large events and contribute to
   Mwp saturation.

2. magnitudes.Mwp.estimateMw.a/b/stdError (double, Whitmore 2002 defaults)
   The Mw(Mwp) linear correction coefficients a=1.186, b=-1.222 and
   stdError=0.4 were previously hardcoded with a "Fixme" comment.
   They are now configurable from global.cfg, allowing operators to
   apply updated calibrations from larger or more recent datasets
   without recompiling.

3. PREM depth-dependent P-wave velocity and density
   computeMagnitude() now uses a PREM lookup table (Dziewonski &
   Anderson 1981) to select alpha and rho at the source depth instead
   of hardcoded mantle values (alpha=7900 m/s, rho=3400 kg/m3).
   This corrects a systematic depth-dependent bias: shallow crustal
   events (alpha~6400 m/s) were previously underestimated and
   deep mantle events (alpha~11000 m/s) overestimated.

All changes are backward compatible. Without configuration overrides
the processor behaves identically to the previous implementation
except for the PREM depth correction which is always active.

New description XML global_Mwp.xml exposes the configurable parameters
in scconfig.
@cla-bot cla-bot Bot added the cla-signed The CLA has been signed by all contributors label May 8, 2026
Comment thread libs/seiscomp/processing/amplitudes/Mwp.cpp Outdated
Comment thread libs/seiscomp/processing/amplitudes/Mwp.cpp Outdated
Comment thread libs/seiscomp/processing/magnitudes/Mwp.cpp Outdated
Per gempa-jabe review on PR SeisComP#197:
- Remove module.trunk. fallback from both setup() functions; localConfiguration
  reads bare keys directly and the module.trunk. prefix is an internal bindings
  mechanism that should never be constructed manually
- Add whitespace around * in amplitude expression (1.E9 * Mwp_...)
@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented May 8, 2026

I need to exclude one of the change which is not backward compatible. Coming up.

The PREM α/ρ lookup changes compute_Mwp output by up to 0.24 mag for
shallow events — a backward-incompatible behaviour change that belongs
in a separate, follow-on PR together with the depth-stratified
regression coefficients calibrated against it.

This PR is now purely additive: useFirstPeak and the estimateMw
coefficients are configurable but default values are unchanged from
the original SeisComP behaviour.
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.

2 participants