eqcorrscan / EQcorrscan

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

party.lag_calc(plot=True) doesn't work #397

Closed ikahbasi closed 4 years ago

ikahbasi commented 4 years ago

Describe the bug When I use party.lag_calc(plot=True) raise error. It works good when party.lag_calc(plot=False). To Reproduce

 cat_cc = party.lag_calc(stream=st,
                                pre_processed=params['parallel'],
                                shift_len=params['shift_len'],
                                min_cc=params['min_cc'],
                                horizontal_chans=['E', 'N', '1', '2'],
                                vertical_chans=['Z'],
                                cores=params['cores'],
                                interpolate=params['interpolate'],
                                plot=params['plot'],
                                plotdir=join(output, 'lag-plot'),
                                parallel=params['parallel'],
                                process_cores=params['cores'],
                                ignore_bad_data=params['ignore_bad_data'],
                                relative_magnitudes=params['relative_magnitudes'],
                                **kwargs)

installed develop branch of eqcorrscan

'AxesSubplot' object does not support indexing
Traceback (most recent call last):
  File "3-0-lag_calc.py", line 77, in <module>
    **kwargs)
  File "/home/ehsan/Documents/kahbasi/eq041/lib/python3.6/site-packages/EQcorrscan-0.4.1-py3.6-linux-x86_64.egg/eqcorrscan/core/match_filter/party.py", line 869, in lag_calc
    relative_magnitudes=relative_magnitudes, **kwargs)
  File "/home/ehsan/Documents/kahbasi/eq041/lib/python3.6/site-packages/EQcorrscan-0.4.1-py3.6-linux-x86_64.egg/eqcorrscan/core/match_filter/family.py", line 600, in lag_calc
    interpolate=interpolate, plot=plot, plotdir=plotdir)
  File "/home/ehsan/Documents/kahbasi/eq041/lib/python3.6/site-packages/EQcorrscan-0.4.1-py3.6-linux-x86_64.egg/eqcorrscan/core/lag_calc.py", line 328, in xcorr_pick_family
    savefile=savefile)
  File "/home/ehsan/Documents/kahbasi/eq041/lib/python3.6/site-packages/EQcorrscan-0.4.1-py3.6-linux-x86_64.egg/eqcorrscan/utils/plotting.py", line 1556, in plot_repicked
    axes[0].legend(lines, labels, loc='upper right', framealpha=1)
TypeError: 'AxesSubplot' object does not support indexing

anaconda

max() arg is an empty sequence
Traceback (most recent call last):
  File "3-0-lag_calc.py", line 77, in <module>
    **kwargs)
  File "/home/ehsan/anaconda3/lib/python3.7/site-packages/eqcorrscan/core/match_filter/party.py", line 868, in lag_calc
    relative_magnitudes=relative_magnitudes, **kwargs)
  File "/home/ehsan/anaconda3/lib/python3.7/site-packages/eqcorrscan/core/match_filter/family.py", line 600, in lag_calc
    interpolate=interpolate, plot=plot, plotdir=plotdir)
  File "/home/ehsan/anaconda3/lib/python3.7/site-packages/eqcorrscan/core/lag_calc.py", line 327, in xcorr_pick_family
    savefile=savefile)
  File "/home/ehsan/anaconda3/lib/python3.7/site-packages/eqcorrscan/utils/plotting.py", line 1511, in plot_repicked
    len(x)])
ValueError: max() arg is an empty sequence

Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

calum-chamberlain commented 4 years ago

Thanks for this issue - it looks like it is happening when you have only one channel in the detection and only one axis is created. This should be a simple fix to change:

axes[0]...

to

if len(template) > 1:
    axis = axes[0]
else:
    axis = axes
axis....

This change should come in here: https://github.com/eqcorrscan/EQcorrscan/blob/f8665a833ff444cbe800e77c86a75ec26061d82a/eqcorrscan/utils/plotting.py#L1556

ikahbasi commented 4 years ago

Your welcome. thanks, can I fix it in a pull request or you want to fix it?

calum-chamberlain commented 4 years ago

A fix would be great, yes please.

calum-chamberlain commented 4 years ago

Closed by #400