Skip to content

Various feedback & revisions

Marcus Herrmann requested to merge mh-feedback into main

@pciturri As promised, I wanted to provide my modifications & feedback of pymock. Feel free to take what you need 🙂

Here is a summary:

pymock variants by introducing 3 new parameters

For creating an ensemble from pymock, I increased its dimensions:

  • lookback_days (dt_prev): the amount of days for which to calculate (a normalized) lambd
  • mag_compl: magnitude of completeness level for sampling magnitudes using the b-value; defaults to the minimum magnitude of the catalog;
  • apply_mc_to_lamb: whether to apply this (lower) mag_compl also to lambd ("recent seismicity"), and not only background seismicity (mu), otherwise keep mag_min (4.0 here).

I already added them to input/args.txt.

I also performed some slight renaming of variables. Hope you like it.

Predefine appropriate magnitude of completeness

Magnitude sampling via b-value should not blindly depend on the smallest magnitude in the catalog, but on a (reasonable) completeness magnitude (mag_compl from above). So I set the default value for mag_compl to a conservative 2.0 for ISIDE.

ATTENTION: Due to changing the default magnitude threshold, the filtered catalog from which synthetic events are sampled is now different. Hence, this change BREAKS REPRODUCIBILITY of prior forecast outputs (should not be a problem, though)! (Edit: irrelevant, see my second comment)

Speed up catalog sampling

Previously (before May 11, 2023), pymock contained a bug in the sampling of synthetic events: when sampling the same events repeatedly, it overwrote the catalog ID for all previous samples of that event. Hence most events in the forecast had a very high, if not the last, catalog ID assigned.

@pciturri addressed this issue by creating and working with deepcopy lists. Both this and the former behavior is/was slow (relevant when nsims is large and/or making heavy use of pymock variants for ensembling over long time periods). My suggestion is a one-liner that creates the the sampled event on-the-fly (and copies over the location). In addition, I outsourced some operations that are the same among nsims.

Minor revision of example case scripts (ex*_frompy.py)

  • tweak event plotting in ex1 (hope you like it!);
  • simplify avg_events calculation in ex2 & ex3;
  • create output dir ("forecasts") if not existing for ex2 (since write_forecast() is commented);
  • align ex3 with previous changes to ex2 (don't re-load forecasts from file, don't load catalog twice, etc.);
  • clean ups

Adapt run.run() to accept only input params file as command line arg

Because 86534036 dropped support for executing pymock by passing cmd line args, I made some final adjustments. I hope I'm correct and in line with your view.

Align CSV output header with CSV standard, pyCSEP, and input catalog

That is, in libs.write_forecast():

  • removed padding whitespace characters;
  • replace 'M' with 'mag'.

Edit:

Bugfix: introducing neg-binom (f599a30c) still left a permanent Poisson smell

I removed the duplicate line n_events = numpy.random.poisson(lambd) that is always called -- an old left-over from the previous Poisson-only era 😉


Edit 2:

Normalize to forecast length using seconds throughout

Given @pciturri's idea to use .total_seconds() for determining window lengths, I now also used .total_seconds() for normalizing mu and lambda to the forecast window.

Revise filename convention: hardcode short variant

Given the discussion at #1, I switched to using only the short variant, but keep code for the long variant, if needed.

Simplify lib.read_args

I structured it a bit more to facilitate extensions, like the three new pymock variant params, which I now added (I forgot in f8394a47).


Edit 3:

Improve comments & some ops

(didn't make its way into this MR, but the related branch)
I cleaned up previous verbose comments, which were only supposed to explain & justify new changes inline.
Also, it removes the "backup second" that was discussed below.

Edited by Marcus Herrmann

Merge request reports

Loading