eqcorrscan / EQcorrscan

Earthquake detection and analysis in Python.
https://eqcorrscan.readthedocs.io/en/latest/
Other
166 stars 86 forks source link

template_gen with swin='P' aborts #470

Closed dr-glenn closed 2 years ago

dr-glenn commented 3 years ago

I want to use swin='P' or swin='P_all' in template_gen, but program sometimes aborts.

templ = template_gen(method='from_meta_file', lowcut=4.0, highcut=10.0, samp_rate=50.0, length=4.0,
            filt_order=4, prepick=0.5, meta_file=catalog, st=st_in, skip_short_chans=True,
            swin='P', process_len=86400, min_snr=5.0, parallel=True, process=False)

Unfortunately some of the event picks are missing phase_hint. template_gen throws an exception on line 687: if pick.phase_hint.upper()[0] == 'P' and Of course this problem does not occur if swin='all', because the phase_hint attribute is not used.

Expected behavior
Would be nice if it would just skip over any pick that had no phase_hint attribute.

Desktop

calum-chamberlain commented 3 years ago

Good point @dr-glenn ! I think a simple change to station_picks after this line would simply fix this.

Do you want to try adding the line:

if _swin != "all":
    station_picks = [p for p in station_picks if p.phase_hint]

just after station_picks is defined (it should be line 730) and see if that gets around the issue? If that works we should make a pull-request with that change and a small test to fix this bug.

calum-chamberlain commented 2 years ago

This should be fixed in #510 - closing.