Git Product home page Git Product logo

Comments (44)

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

@blazvicic each function in the eqcorrscan.core.template_gen module has it's own documentation here - I'm moving away from encouraging the use of _template_gen, all the wrappers in core.template_gen call on this, but use higher-level obspy Catalog and Event objects.

However, picks should be a list of obspy.core.event.origin.Pick objects. If you have your picks in a format that is readable by either obspy (through the read_events function, or in nordic (readable by EQcorrscan through the eqcorrscan.utils.sfile_util functions), or associated with SAC waveforms, you would save yourself a lot of effort by reading in to a Catalog object and using one of the wrappers in the template_gen module.

st is as standard for obspy related things: an obspy.core.Stream object (which it says in the docs for _template_gen). It's not the path, you have to read the file in using obspy.read. Because we use obspys read function, which is agnostic to data-type, you can give it (almost) any data format to read from.

Hope that helps. I'll leave this open until you are satisfied.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

thank you for your time and answers... I think I am getting somewhere.
Here is the short script and error that I get:

import glob
from obspy import *
from eqcorrscan.core.template_gen import multi_template_gen

catalog = read_events("last.hyp", format = "nlloc_hyp")
event = catalog[0]
picks = event.picks
cat = Catalog()
cat.append(event)
st = Stream()
for file in glob.glob('C:/Users/Nicolas/Desktop/eqcorrscan/24h/*'):
    st += read(file)
st.merge(method=1, fill_value=0)
print(st.__str__(extended=True))
template = multi_template_gen(catalog=cat, st=st, length=2.0, swin='all', prepick=0.1)
template.write('template.ms', format="MSEED")

15 Trace(s) in Stream:
SL.CEY..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.GBRS..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHZ | 2014-04-22T00:00:03.181700Z - 2014-04-22T12:57:53.356700Z | 200.0 Hz, 9334036 samples
SL.GBRS..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHE | 2014-04-22T00:00:01.881700Z - 2014-04-22T13:10:42.656700Z | 200.0 Hz, 9488156 samples
SL.SKDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHN | 2014-04-22T00:00:00.981700Z - 2014-04-22T12:57:53.996700Z | 200.0 Hz, 9334604 samples
SL.KNDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.GBRS..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
Traceback (most recent call last):
File "template_creator.py", line 23, in
template = multi_template_gen(catalog=cat, st=st, length=2.0, swin='all', prepick=0.1)
File "C:\Users\Nicolas\Anaconda2\lib\site-packages\eqcorrscan\core\template_gen.py", line 803, in multi_template_gen
prepick, plot, debug)
File "C:\Users\Nicolas\Anaconda2\lib\site-packages\eqcorrscan\core\template_gen.py", line 860, in _template_gen
channels.append(pick.waveform_id.channel_code[0] +
TypeError: 'NoneType' object has no attribute 'getitem'

Thanks!

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

I think that error comes about because you have an event with a pick that isn't associated with a waveform.

By the by, I wouldn't import all of obspy at once, wildcard imports are not recommended.

Also, I would edit the script as follows (which should also remove the error warning by checking that picks are what you want):

import glob
from obspy import read, read_events, Stream
from eqcorrscan.core.template_gen import multi_template_gen

catalog = read_events("last.hyp", format="nlloc_hyp")
cat = Catalog(catalog[0])
# This section to check picks, you could also select only P or S phase picks here
# or some other criteria based on weights etc.
for pick in cat[0].picks:
   if not pick.waveform_id:
      cat[0].picks.remove(pick)
      print('Removed pick as it wasn't associated with a waveform')
      print(pick)
st = Stream()
for file in glob.glob('C:/Users/Nicolas/Desktop/eqcorrscan/24h/*'):
    st += read(file)
st.merge(method=1, fill_value=0)
print(st.__str__(extended=True))
template = multi_template_gen(catalog=cat, st=st, length=2.0, swin='all', prepick=0.1)
template.write('template.ms', format="MSEED")

An another, more matched-filter specific related note - it is common to resample and filter your events. Filtering will often result in higher correlations if you filter around the period of maximum power in your signal. Resampling (downsampling) will reduce the computational cost (e.g. going from 200 Hz to 20 Hz would result in a ten-fold reduction in memory consumption) - as long as you maintain that your Nyquist frequency is above the top end of you filter then this doesn't pose problems.

Note that I haven't tested this because I don't have you data

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

@blazvicic you might be best off using from_quakeml, which actually doesn't require a quakeml file (I'm updating the name and docs now to reflect that): it can read any format meta-data readable by obspy read_events, and allows you to filter.

I'm also just adding in to the develop branch a check that all picks are associated with a waveform, which should circumvent that error.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

I think that error comes about because you have an event with a pick that isn't associated with a waveform.

Yes, this was the case, I put mseed of the wrong station in st.

it is common to resample and filter your events

Sure, I always do that, I just did not put it here in my example. Thanks

about from_meta_file:

I will probably have to upgrade eqcorrscan for this to work?

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

You would have to clone the repository, checkout the develop branch and then install it. Yup. Once you clone (press the big green button for a link to paste) then type:
git checkout develop
pip install .

Sent from my Vodafone Smart

On Jul 15, 2016 8:10 PM, blazvicic [email protected] wrote:

I think that error comes about because you have an event with a pick that isn't associated with a waveform.

Yes, this was the case, I put mseed of the wrong station in st.

it is common to resample and filter your events

Sure, I always do that, I just did not put it here in my example. Thanks

about from_meta_file:

I will probably have to upgrade eqcorrscan for this to work?

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-232889864, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGc_QeKS1rn-FDpEgqtF4gzKXcWw6Qks5qV0B-gaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024
import glob
from obspy import *
from eqcorrscan.core.template_gen import from_meta_file

catalog = read_events("last.hyp", format = "nlloc_hyp")
cat = Catalog(catalog[0])

st = Stream()
for file in glob.glob('./24h/*'):
    st += read(file)
st.merge(method=1, fill_value=0)
print(st.__str__(extended=True))

template = from_meta_file(meta_file=cat, st=st, lowcut=2.0, highcut=9.0, samp_rate=20.0, filt_order=3, length=2, prepick=0.1, swin='all')
template.write('./templates/template.ms', format="MSEED")

now i get this error:
could be because the code is running on windows? I will try on my linux pc later in the evening.

Traceback (most recent call last):
File "template_creator.py", line 21, in
template = from_meta_file(meta_file=cat, st=st, lowcut=2.0, highcut=9.0, samp_rate=20.0, filt_order=3, length=2, prepick=0.1, swin='all')
File "C:\Users\Nicolas\Anaconda2\lib\site-packages\eqcorrscan\core\template_gen.py", line 464, in from_meta_file
if not os.path.isfile(meta_file):
File "C:\Users\Nicolas\Anaconda2\lib\genericpath.py", line 37, in isfile
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, Catalog found

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

No, this us because in this instance meta_file is the file. So the nonlinloc file in your case.

Sent from my Vodafone Smart

On Jul 15, 2016 8:40 PM, blazvicic [email protected] wrote:

import glob
from obspy import *
from eqcorrscan.core.template_gen import from_meta_file

catalog = read_events("last.hyp", format = "nlloc_hyp")
cat = Catalog(catalog[0])
st = Stream()
for file in glob.glob('./24h/*'):
st += read(file)
st.merge(method=1, fill_value=0)
print(st.str(extended=True))

template = from_meta_file(meta_file=cat, st=st, lowcut=2.0, highcut=9.0, samp_rate=20.0, filt_order=3, length=2, prepick=0.1, swin='all')
template.write('./templates/template.ms', format="MSEED")

now i get this error:
could be because the code is running on windows? I will try on my linux pc later in the evening.

Traceback (most recent call last):
File "template_creator.py", line 21, in
template = from_meta_file(meta_file=cat, st=st, lowcut=2.0, highcut=9.0, samp_rate=20.0, filt_order=3, length=2, prepick=0.1, swin='all')
File "C:\Users\Nicolas\Anaconda2\lib\site-packages\eqcorrscan\core\template_gen.py", line 464, in from_meta_file
if not os.path.isfile(meta_file):
File "C:\Users\Nicolas\Anaconda2\lib\genericpath.py", line 37, in isfile
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, Catalog found

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-232895266, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGc3rHUS15mFpbJSdk6WrL1fWLYIwgks5qV0dsgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024
import glob
from obspy import *
from eqcorrscan.core.template_gen import from_meta_file

meta_file = "last.hyp"

st = Stream()
for file in glob.glob('./24h/*'):
    st += read(file)
st.merge(method=1, fill_value=0)
print(st.__str__(extended=True))


template = from_meta_file(meta_file=meta_file, st=st, 
                                          lowcut=2.0, highcut=9.0, 
                                          samp_rate=20.0, filt_order=3, 
                                          length=2, prepick=0.1, swin='all')
template.write('./templates/template.ms', format="MSEED")

I updated the eqcorrscan from git. This is the code that I tried to run on both windows10 PC and Ubuntu PC.

On windows everything becomes totally unresponsive - i had to hard reset the PC, so I could not see what the error was.
On Ubuntu, the code works, it gives some output but then fails with this:

15 Trace(s) in Stream:
SL.CEY..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.GBAS..HHN | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.GBAS..HHE | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHE | 2014-04-22T00:00:01.881700Z - 2014-04-22T13:10:42.656700Z | 200.0 Hz, 9488156 samples
SL.KNDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHN | 2014-04-22T00:00:00.981700Z - 2014-04-22T12:57:53.996700Z | 200.0 Hz, 9334604 samples
SL.GBAS..HHZ | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHZ | 2014-04-22T00:00:03.181700Z - 2014-04-22T12:57:53.356700Z | 200.0 Hz, 9334036 samples
SL.SKDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
I now have 17280000 data points after enforcing day length
I now have 17280000 data points after enforcing day length
I now have 17280000 data points after enforcing day length
Traceback (most recent call last):
File "template_creator.py", line 22, in
template = from_meta_file(meta_file=meta_file, st=st, lowcut=2.0, highcut=9.0, samp_rate=20.0, filt_order=3, length=2, prepick=0.1, swin='all')
File "/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/template_gen.py", line 534, in from_meta_file
if not '.'.join([stations[i], channels[i]]) in st_stachans:
TypeError: sequence item 1: expected string or Unicode, NoneType found

The data I am using can be found on this link:
https://db.tt/K2UQfBD5

One day data from few stations and one event in catalog to create template of.

Thanks,
Blaz

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Looks like read_events for nonlinloc doesn't read in the channel associated with the pick, which is what EQcorrscan is expecting. I think I should try and update this in obspy rather than patch something here.

In the meantime, I suggest the following work-around:

import glob
from obspy import read, Stream, read_events
from eqcorrscan.core.template_gen import from_meta_file

meta_file = "last.hyp"

st = read('24h/*')
st.merge(method=1, fill_value=0)
print(st.__str__(extended=True))

initial_cat = read_events(meta_file)
# Read in the nonlinloc file and fill the picks with
# channel names - hard-coding for P on HHZ and S on HHE
for event in initial_cat:
    for pick in event.picks:
        if not pick.waveform_id.channel_code:
            if pick.phase_hint == 'P':
                pick.waveform_id.channel_code = 'HHZ'
            elif pick.phase_hint == 'S':
                pick.waveform_id.channel_code = 'HHE'
# Write out the catalog to a quakeml file and use that
# as the meta_file
initial_cat.write('channels_added.quakeml', format='QUAKEML')

# note, haven't included JAVS, so it's not the same as
# the example you gave :(

templates = from_meta_file(meta_file='channels_added.quakeml', st=st,
                           lowcut=2.0, highcut=9.0,
                           samp_rate=20.0, filt_order=3,
                           length=2, prepick=0.1, swin='all')
templates[0].write('./templates/template.ms', format="MSEED")

Regarding the Windows issue - this is because you are (quietly) parallel processing the data, and windows is not that great at parallel processing data... It will likely have filled up your memory, which will have resulted in the freezing - I should add options to not parallel process, but then you lose the speed-ups - only way around that is to use shorter data chunks. This would also have been an issue in the matched-filter stages (parallel processing the data) - if you want to use your Windows machine you will have to use shorter chunks than 1-day i think.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

Thanks.

It looks like template was generated, but i just want to make sure it is ok...

10 Trace(s) in Stream:
SL.CEY..HE | 2014-04-22T08:58:34.802700Z - 2014-04-22T08:58:36.752700Z | 20.0 Hz, 40 samples
SL.SKDS..HZ | 2014-04-22T08:58:32.251700Z - 2014-04-22T08:58:34.201700Z | 20.0 Hz, 40 samples
SL.KNDS..HN | 2014-04-22T08:58:34.851700Z - 2014-04-22T08:58:36.801700Z | 20.0 Hz, 40 samples
SL.KNDS..HE | 2014-04-22T08:58:34.851700Z - 2014-04-22T08:58:36.801700Z | 20.0 Hz, 40 samples
SL.CEY..HN | 2014-04-22T08:58:34.802700Z - 2014-04-22T08:58:36.752700Z | 20.0 Hz, 40 samples
SL.SKDS..HN | 2014-04-22T08:58:35.601700Z - 2014-04-22T08:58:37.551700Z | 20.0 Hz, 40 samples
SL.GBAS..HZ | 2014-04-22T08:58:34.350700Z - 2014-04-22T08:58:36.300700Z | 20.0 Hz, 40 samples
SL.KNDS..HZ | 2014-04-22T08:58:31.751700Z - 2014-04-22T08:58:33.701700Z | 20.0 Hz, 40 samples
SL.SKDS..HE | 2014-04-22T08:58:35.601700Z - 2014-04-22T08:58:37.551700Z | 20.0 Hz, 40 samples
SL.CEY..HZ | 2014-04-22T08:58:31.752700Z - 2014-04-22T08:58:33.702700Z | 20.0 Hz, 40 samples

For station GBAS i think it is OK, since I only had P arrival. But what about all other stations? For CEY, KNDS and SKDS there are HZ,HE and HN eventhou there is only one S phase per station. Is the code meant to create template even for the cha that was not associated with S arrival?

Thanks.
Tomorrow I will go to the next step of detections.

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

It does select data from both horizontal channels - it has been my default, I will add an option to only output those with picks and set that to the default. I will have that updated on the develop branch today (NZ time). However, in this case when we have assigned the pick to a set channel it might be useful to take both horizontal channels (they will both have information on them).

To update your repository:

git pull origin develop
pip install .

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

I tried my data with match_filter. I just try 2 runs, to see if everything is OK. One with (threshold=6, threshold_type='MAD', trig_int=6) and the other with threshold = 7.

It was a bit unexpected to see that with thr=7 I was able to find only 1 event (mainshock) and with thr=6, there were few aftershocks picked up, but there were also few detections prior the mainshock, that were fake.

If I go to 5.5 detection will happen every few minutes, so this is not ok for me.

Later I will try changing other parameters to see if the detections will get better.

In any case, thank you for your time and help, I will try to compare the results with my manualy located aftershock seq (similarity of wfs is really high for the aftershocks, so I expect that I should find them after changing the parameters) and the other template match code that I was using for some other example.

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

That is surprising. Testing with other known cases, both real sequences (hundreds of sequences) and synthetic sequences yield expected results. I will run my system for the day of days you shared and make sure it works as I expect.

Might I ask what other Python packages you have tried?

Sent from my Vodafone Smart

On Jul 16, 2016 8:34 PM, blazvicic [email protected] wrote:

I tried my data with match_filter. I just try 2 runs, to see if everything is OK. One with (threshold=6, threshold_type='MAD', trig_int=6) and the other with threshold = 7.

It was a bit unexpected to see that with thr=7 I was able to find only 1 event (mainshock) and with thr=6, there were few aftershocks picked up, but there were also few detections prior the mainshock, that were fake.

If I go to 5.5 detection will happen every few minutes, so this is not ok for me.

Later I will try changing other parameters to see if the detections will get better.

In any case, thank you for your time and help, I will try to compare the results with my manualy located aftershock seq (similarity of wfs is really high for the aftershocks, so I expect that I should find them after changing the parameters) and the other template match code that I was using for some other example.

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-233120237, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGcxggZnxi_hg9O6SAADmaSFFMX9mCks5qWJeKgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

To get some feeling: in the manual catalog of the aftershocks I have on the same day as the mainshock 60 aftershocks (which had nice phases).

The code I tried is not yet published, but i think it should be soon.

Improving the Detection of Low-Magnitude Seismicity: Development and Optimization of a Scalable Code Based on the Cross-Correlation of Template Earthquakes (in preparation) by A. Vuan , M. Sugan, G. Amati, A. Kato

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Okay, there is some issue with how you are implementing it: if i run the template I generated for you using the data you gave me, with a threshold of 7xMAD I obtain 6 detections, which includes the self-detection with perfect correlation.

The snippet I ran:

from obspy import read
from eqcorrscan.utils import pre_processing
from eqcorrscan.core import match_filter

st = read('24h/*')
st = pre_processing.dayproc(st, lowcut=2, highcut=9,
                            samp_rate=20, filt_order=3, 
                            starttime=st[0].stats.starttime)
templates = [read('templates/template.ms')]
detections = match_filter.match_filter(template_names=['1'], 
                                       template_list=templates,
                                       threshold=7, threshold_type='MAD',
                                       cores=4, plotvar=False, trig_int=6, st=st)

I would expect, if this is the mainshock, then it would give few detections itself. In general mainshocks make poor templates, their waveforms are significantly more complex than a small earthquake, so they do not correlate well with smaller, simpler earthquakes - comparing rupture scales would lead to this idea.

I would usually use a threshold of 8xMAD as this has been shown to be usefully statistically robust (enough standard deviations from the mean that outliers in a random, but normally distributed dataset should be very rare). With 8xMAD I obtain 2 detections (one detection and a self-detection).

In practice the best use for these matched-filter techniques in aftershock sequences is to use all available catalog earthquakes as templates.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

Ah, i did not know that mainshocks are considered bed templates - i mean, sure, when talking about strong earthquakes, but since this here is a 4.7 i thought it should be similar to aftershocks. Anyway, the idea was to use all ml>1 as templates, this was just the example to make everything work ok. With the other code I used 60 events as templates and the templates found 2000 events - but that was a swarm seqence not an aftershock like this case.

next week i will run this with more templates an write the results here.

thank you!

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Golden - there is a standard rule-of-thumb (Baths law) that states that the largest aftershock will be about 1.2 magnitude units lower than the mainshock, which results in quite a large change in rupture properties. Swarms have quite different magnitude ranges, so I would expect very different results.

I am slightly concerned that you only made the self detection for 7xMAD threshold and I made 6. It might be worth running the tests for EQcorrscan before you proceed any further. To do this, from the EQcorrscan git repository directory, run:

python setup.py test

It will take about half an hour to run all the tests, and none of them should fail.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

i tried...it fails instantly...

blaz@BlazOS:~/EQcorrscan$ python setup.py test
warning: pypandoc module not found, could not convert Markdown to RST
/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/setuptools/dist.py:285: UserWarning: Normalizing '0.1.3rc' to '0.1.3rc0'
running pytest
Searching for pytest-cov
Best match: pytest-cov 2.3.0
Processing pytest_cov-2.3.0-py2.7.egg

Using /home/blaz/EQcorrscan/.eggs/pytest_cov-2.3.0-py2.7.egg
Searching for pytest-flake8
Best match: pytest-flake8 0.5
Processing pytest_flake8-0.5-py2.7.egg

Using /home/blaz/EQcorrscan/.eggs/pytest_flake8-0.5-py2.7.egg
Searching for coverage>=3.7.1
Best match: coverage 4.2b1
Processing coverage-4.2b1-py2.7-linux-x86_64.egg

Using /home/blaz/EQcorrscan/.eggs/coverage-4.2b1-py2.7-linux-x86_64.egg
Traceback (most recent call last):
File "setup.py", line 143, in
tests_require=['pytest', 'pytest-flake8', 'pytest-cov'],
File "/home/blaz/anaconda2/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/home/blaz/anaconda2/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/home/blaz/anaconda2/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.linux-x86_64/egg/ptr.py", line 73, in run
File "/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/setuptools/dist.py", line 313, in fetch_build_eggs
File "/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/init.py", line 826, in resolve
File "/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/init.py", line 1085, in best_match
File "/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/init.py", line 695, in find
pkg_resources.VersionConflict: (pyflakes 1.2.3 (/home/blaz/anaconda2/lib/python2.7/site-packages), Requirement.parse('pyflakes<1.1,>=0.8.1'))

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Sweet, that isn't any of the tests, you just don't have the requisites to run the tests - install pyflakes, pytest and pytest-cov and things should run.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024
sudo apt-get install python-pytest python-pytest-cov pyflakes
[sudo] password for blaz: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
pyflakes is already the newest version (1.1.0-2).
python-pytest is already the newest version (2.8.7-4).
python-pytest-cov is already the newest version (2.2.1-1).
The following packages were automatically installed and are no longer required:
  libenet7 libgranite-common libgranite2 libopenal-data libopenal1
  linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-22
  linux-headers-4.4.0-22-generic linux-headers-4.4.0-24
  linux-headers-4.4.0-24-generic linux-image-4.4.0-21-generic
  linux-image-4.4.0-22-generic linux-image-4.4.0-24-generic
  linux-image-extra-4.4.0-21-generic linux-image-extra-4.4.0-22-generic
  linux-image-extra-4.4.0-24-generic supertuxkart-data
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.

and i get the same error. i did restart terminal
could be because i am using anaconda?

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

It all depends on your Python path. If you are using anaconda then yes, your path likely doesn't have your system packages. You would have to install using conda.

How did you install opencv? By conda (not recommend), from apt, or from source?

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

i installed it from apt.

now i installed pytest pytest-cov pyflakes with conda install and the error persists :/

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Okay, sorry, I didn't read it in full, you need the correct pyflakes version.

conda install pyflakes=1.0

Might work.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

yes, downgrading pyflakes helped...

warning: pypandoc module not found,  could not convert Markdown to RST
/home/blaz/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/setuptools/dist.py:285: UserWarning: Normalizing '0.1.3rc' to '0.1.3rc0'
running pytest
Searching for pytest-flake8
Best match: pytest-flake8 0.5
Processing pytest_flake8-0.5-py2.7.egg

Using /home/blaz/EQcorrscan/.eggs/pytest_flake8-0.5-py2.7.egg
running egg_info
creating EQcorrscan.egg-info
writing requirements to EQcorrscan.egg-info/requires.txt
writing EQcorrscan.egg-info/PKG-INFO
writing top-level names to EQcorrscan.egg-info/top_level.txt
writing dependency_links to EQcorrscan.egg-info/dependency_links.txt
writing manifest file 'EQcorrscan.egg-info/SOURCES.txt'
reading manifest file 'EQcorrscan.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'eqcorrscan/doc/_build/latex'
no previously-included directories found matching 'eqcorrscan/plot'
no previously-included directories found matching 'eqcorrscan/detections'
no previously-included directories found matching 'eqcorrscan/grid'
no previously-included directories found matching 'eqcorrscan/tests/test_data'
no previously-included directories found matching 'misc'
writing manifest file 'EQcorrscan.egg-info/SOURCES.txt'
running build_ext
============================= test session starts ==============================
platform linux2 -- Python 2.7.11, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/blaz/EQcorrscan, inifile: pytest.ini
plugins: flake8-0.5, cov-2.2.1
collected 135 items 

eqcorrscan/core/lag_calc.py .
eqcorrscan/core/template_gen.py ....
eqcorrscan/tests/brightness_test.py .........
eqcorrscan/tests/catalog_to_dd_test.py .......
eqcorrscan/tests/catalog_utils_test.py .
eqcorrscan/tests/clustering_test.py ..............
eqcorrscan/tests/correlation_test.py .
eqcorrscan/tests/despike_test.py ..
eqcorrscan/tests/find_peaks_test.py .
eqcorrscan/tests/install_test.py .
eqcorrscan/tests/lag_calc_test.py .
eqcorrscan/tests/log_read_test.py ..
eqcorrscan/tests/mag_calc_test.py ........
eqcorrscan/tests/match_filter_test.py .............
eqcorrscan/tests/parameter_test.py .
eqcorrscan/tests/sfile_util_test.py ..............
eqcorrscan/tests/stacking_test.py ...
eqcorrscan/tests/template_gen_test.py ......
eqcorrscan/tests/trigger_test.py ...
eqcorrscan/tests/tutorials_test.py ..
eqcorrscan/utils/archive_read.py .
eqcorrscan/utils/catalog_to_dd.py ....
eqcorrscan/utils/catalog_utils.py .
eqcorrscan/utils/clustering.py ..
eqcorrscan/utils/findpeaks.py ...
eqcorrscan/utils/mag_calc.py ...
eqcorrscan/utils/picker.py ..
eqcorrscan/utils/plotting.py ......
eqcorrscan/utils/pre_processing.py ...
eqcorrscan/utils/sac_util.py .
eqcorrscan/utils/sfile_util.py ............
eqcorrscan/utils/trigger.py ...
--------------- coverage: platform linux2, python 2.7.11-final-0 ---------------
Name                                        Stmts   Miss  Cover
---------------------------------------------------------------
eqcorrscan/core/bright_lights.py              383    111    71%
eqcorrscan/core/lag_calc.py                   151     39    74%
eqcorrscan/core/match_filter.py               382     91    76%
eqcorrscan/core/template_gen.py               485    142    71%
eqcorrscan/tutorials/lag_calc.py               51      6    88%
eqcorrscan/tutorials/match_filter.py           70     11    84%
eqcorrscan/tutorials/template_creation.py      36     13    64%
eqcorrscan/utils/archive_read.py               90     15    83%
eqcorrscan/utils/catalog_to_dd.py             294     41    86%
eqcorrscan/utils/catalog_utils.py              54      4    93%
eqcorrscan/utils/clustering.py                380     48    87%
eqcorrscan/utils/despike.py                    93     18    81%
eqcorrscan/utils/findpeaks.py                 115     34    70%
eqcorrscan/utils/mag_calc.py                  442    105    76%
eqcorrscan/utils/parameters.py                 86     22    74%
eqcorrscan/utils/picker.py                    123     38    69%
eqcorrscan/utils/pre_processing.py            137     39    72%
eqcorrscan/utils/sac_util.py                   91     32    65%
eqcorrscan/utils/seismo_logs.py                96     37    61%
eqcorrscan/utils/sfile_util.py                591     77    87%
eqcorrscan/utils/stacking.py                   62      6    90%
eqcorrscan/utils/synth_seis.py                144     54    63%
eqcorrscan/utils/trigger.py                   162     32    80%
---------------------------------------------------------------
TOTAL                                        4518   1015    78%

======================== 135 passed in 2045.75 seconds ========================

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Good all fine then - I'm still confused as to why you only obtained the self detection, could you let me see what you ran for that?

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

On the link there is the data and the scripts that I used...
If you have time, can you also check what is wrong with the 2nd template (test_temp.ms)?
I used the same event, same filtring, 2.5s as a lenght but they are created a bit different - I cutted around S arrival, calculated from the iasp91 model - S arrivals are calculated from origin time.

https://db.tt/7P53kyEl

Thanks!

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

What do you mean wrong? Error messages, or otherwise? If error messages can you copy them in here. I'll have a look tomorrow afternoon NZ time, so I'll fill you in your tomorrow? Let me know anything else you need done (while I'm in bed) and I'll see what I can do.

Happy to help!

Sent from my Vodafone Smart

On Jul 18, 2016 7:58 PM, blazvicic [email protected] wrote:

On the link there is the data and the scripts that I used...
If you have time, can you also check what is wrong with the 2nd template (test_temp.ms)?
I used same filtring, 2.5s as a lenght but they are created a bit different - I cutted around S arrival, calculated from the iasp91 model - S arrivals are calculated from origin time.

https://db.tt/7P53kyEl

Thanks!

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-233258959, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGc2p55pQpuxjgtdCKKi4bhYWEXDvzks5qWzIOgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024
18 Trace(s) in Stream:
SL.CEY..HHE  | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.GBAS..HHN | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.GBAS..HHE | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHZ | 2014-04-22T00:00:03.181700Z - 2014-04-22T12:57:53.356700Z | 200.0 Hz, 9334036 samples
SL.KNDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.GBRS..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHN  | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.JAVS..HHN | 2014-04-22T00:00:00.981700Z - 2014-04-22T12:57:53.996700Z | 200.0 Hz, 9334604 samples
SL.JAVS..HHE | 2014-04-22T00:00:01.881700Z - 2014-04-22T13:10:42.656700Z | 200.0 Hz, 9488156 samples
SL.SKDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.GBRS..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.GBAS..HHZ | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples
SL.KNDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.GBRS..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
SL.SKDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples
SL.CEY..HHZ  | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
I now have 17280000 data points after enforcing day length
I now have 17280000 data points after enforcing day length
I now have 17280000 data points after enforcing day length
/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py:643: UserWarning: Data are not equal length, padding short traces
  warnings.warn(msg)
/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py:687: UserWarning: No channels matching in continuous data for templatetest_temp.ms
  warnings.warn(msg)
Traceback (most recent call last):
  File "matched_filter.py", line 24, in <module>
    cores=4)
  File "/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py", line 703, in match_filter
    [cccsums, no_chans, chans] = _channel_loop(templates, stream, cores, debug)
  File "/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py", line 396, in _channel_loop
    len(templates[0][0].data) + 1))] *
  File "/home/blaz/anaconda2/lib/python2.7/site-packages/obspy/core/stream.py", line 656, in __getitem__
    return self.traces.__getitem__(index)
IndexError: list index out of range

no need to hurry, get some good night rest.
thanx

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Will do, can you paste the code you used too? Looks like you might not have given match_filter a list of templates? Even if it's only one template, it needs to be a list of streams.

Sent from my Vodafone Smart

On Jul 18, 2016 8:20 PM, blazvicic [email protected] wrote:

18 Trace(s) in Stream: SL.CEY..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples SL.GBAS..HHN | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples SL.GBAS..HHE | 2014-04-22T00:00:00.000700Z

  • 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples SL.SKDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples SL.JAVS..HHZ | 2014-04-22T00:00:03.181700Z - 2014-04-22T12:57:53.356700Z | 200.0 Hz, 9334036 samples
    SL.KNDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples SL.GBRS..HHE | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples SL.KNDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z
    | 200.0 Hz, 17280000 samples SL.CEY..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples SL.JAVS..HHN | 2014-04-22T00:00:00.981700Z - 2014-04-22T12:57:53.996700Z | 200.0 Hz, 9334604 samples SL.JAVS..HHE | 2014-04-22T00:00:01.881700Z
  • 2014-04-22T13:10:42.656700Z | 200.0 Hz, 9488156 samples SL.SKDS..HHN | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples SL.GBRS..HHN | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples
    SL.GBAS..HHZ | 2014-04-22T00:00:00.000700Z - 2014-04-22T23:59:59.995700Z | 200.0 Hz, 17280000 samples SL.KNDS..HHZ | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples SL.GBRS..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z
    | 200.0 Hz, 17280000 samples SL.SKDS..HHE | 2014-04-22T00:00:00.001700Z - 2014-04-22T23:59:59.996700Z | 200.0 Hz, 17280000 samples SL.CEY..HHZ | 2014-04-22T00:00:00.002700Z - 2014-04-22T23:59:59.997700Z | 200.0 Hz, 17280000 samples I now have 17280000 data
    points after enforcing day length I now have 17280000 data points after enforcing day length I now have 17280000 data points after enforcing day length /home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py:643: UserWarning: Data
    are not equal length, padding short traces warnings.warn(msg) /home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py:687: UserWarning: No channels matching in continuous data for templatetest_temp.ms warnings.warn(msg) Traceback (most
    recent call last): File "matched_filter.py", line 24, in cores=4) File "/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py", line 703, in match_filter [cccsums, no_chans, chans] = _channel_loop(templates, stream, cores,
    debug) File "/home/blaz/anaconda2/lib/python2.7/site-packages/eqcorrscan/core/match_filter.py", line 396, in _channel_loop len(templates[0][0].data) + 1))] * File "/home/blaz/anaconda2/lib/python2.7/site-packages/obspy/core/stream.py", line 656, in getitem
    return self.traces.getitem(index) IndexError: list index out of range

no need to hurry, get some good night rest.
thanx

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-233265583, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGcwlTJSJwLGeX7xC05pRQv9VB9lCWks5qWzcqgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

the code is the same as for the template.ms (that i aslo put into the dropbox). with that template it works normaly. so, it must be the test_temp.ms

from eqcorrscan.core import match_filter
from eqcorrscan.utils import pre_processing
from obspy import read

# Read in and process the daylong data
st = read('24h/*')
st.merge(method=1, fill_value=0)
st.detrend('constant')
print(st.__str__(extended=True))

# Use the same filtering and sampling parameters as your template!
st = pre_processing.dayproc(st, lowcut=3.0, highcut=6.0, filt_order=3,
                            samp_rate=20,
                            starttime=st[0].stats.starttime)
# Read in the templates
templates = []
template_names = ['test_temp.ms']
for template_file in template_names:
     templates.append(read(template_file))
detections = match_filter.match_filter(template_names=template_names,
                                       template_list=templates, st=st,
                                       threshold=7, threshold_type='MAD',
                                       trig_int=6, plotvar=False, plotdir=('./plots'),
                                       cores=4)

for detection in detections:
     detection.write('my_first_detections.csv', append=True)

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Thanks, I'll have a closer look tomorrow then.

Sent from my Vodafone Smart

On Jul 18, 2016 8:33 PM, blazvicic [email protected] wrote:

the code is the same as for the template.ms (that i aslo put into the dropbox). with that template it works normaly. so, it must be the test_temp.ms

from eqcorrscan.core import match_filter
from eqcorrscan.utils import pre_processing
from obspy import read

Read in and process the daylong data

st = read('24h/*')
st.merge(method=1, fill_value=0)
st.detrend('constant')
print(st.str(extended=True))

Use the same filtering and sampling parameters as your template!

st = pre_processing.dayproc(st, lowcut=3.0, highcut=6.0, filt_order=3,
samp_rate=20,
starttime=st[0].stats.starttime)

Read in the templates

templates = []
template_names = ['test_temp.ms']
for template_file in template_names:
templates.append(read(template_file))
detections = match_filter.match_filter(template_names=template_names,
template_list=templates, st=st,
threshold=7, threshold_type='MAD',
trig_int=6, plotvar=False, plotdir=('./plots'),
cores=4)

for detection in detections:
detection.write('my_first_detections.csv', append=True)

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-233269855, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGc5AgOARy2ML4IXo8swL8kTJPqlfgks5qWzpCgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

i checked first trace of both templates...

>>> tr1.stats
Stats({u'network': u'SL', '_format': 'MSEED', u'mseed': AttribDict({'record_length': 4096, 'encoding': u'FLOAT64', 'filesize': 40960, u'dataquality': u'D', 'number_of_records': 10, 'byteorder': u'>'}), u'sampling_rate': 20.0, u'station': u'CEY', u'location': u'', u'starttime': UTCDateTime(2014, 4, 22, 8, 58, 34, 802700), u'delta': 0.05, u'calib': 1.0, u'npts': 40, u'endtime': UTCDateTime(2014, 4, 22, 8, 58, 36, 752700), u'channel': u'HE'})
>>> st2 = read("test_temp.ms")
>>> tr2 = st2[0]
>>> tr2.stats
Stats({u'network': u'SL', '_format': 'MSEED', u'mseed': AttribDict({'record_length': 4096, 'encoding': u'FLOAT64', 'filesize': 61440, u'dataquality': u'D', 'number_of_records': 15, 'byteorder': u'>'}), u'sampling_rate': 20.0, u'station': u'CEY', u'location': u'', u'starttime': UTCDateTime(2014, 4, 22, 8, 58, 31, 752700), u'delta': 0.05, u'calib': 1.0, u'npts': 101, u'endtime': UTCDateTime(2014, 4, 22, 8, 58, 36, 752700), u'channel': u'HHE'})

as you can see there is a difference in channel... template created by from_meta_file will have H* while those I created will have HH*

What should I modify so I can use my templates? (If this is indeed the case).

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

That is most definitely the issue. If you edit your script to the following (just added an extra loop in the template reading, which will change channel names to two letter names - it will work with both templates you generate yourself with three-letter names, and those generated by EQcorrscan with two letter names):

from eqcorrscan.core import match_filter
from eqcorrscan.utils import pre_processing
from obspy import read

# Read in and process the daylong data
st = read('24h/*')
st.merge(method=1, fill_value=0)
st.detrend('constant')
print(st.__str__(extended=True))

# Use the same filtering and sampling parameters as your template!
st = pre_processing.dayproc(st, lowcut=3.0, highcut=6.0, filt_order=3,
                            samp_rate=20,
                            starttime=st[0].stats.starttime)
# Read in the templates
templates = []
template_names = ['test_temp.ms']
for template_file in template_names:
    templates.append(read(template_file))
for template in templates:
    for tr in template:
        # Change channel names to two letters because EQcorrscan uses Seisan
        # style channel names, which are not standard, and should be changed!
        # Note that I might change EQcorrscan to use proper three letter
        # chanel names in a future release, but I will ensure it works with
        # two letter channel names too.
        tr.stats.channel = tr.stats.channel[0] + tr.stats.channel[-1]
detections = match_filter.match_filter(template_names=template_names,
                                       template_list=templates, st=st,
                                       threshold=7, threshold_type='MAD',
                                       trig_int=6, plotvar=False,
                                       plotdir='./plots', cores=4)

for detection in detections:
    detection.write('my_first_detections.csv', append=True)

I left a comment in there - the channel naming is pretty arbitrary, its solely because I mostly use seisan for picking earthquakes, which uses two letter naming, I think I will change EQcorrscan to use full three-letter channel names soon because it is silly not to really. I will make it backwards compatible though.

When I run this I obtain 103 detections using this template.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

Thanks, it works perfect.
This time I got 103 detections so this is the same as you got. this is much better (taking in considiration of events you got regarding to my test) then the run we did before.

The change in number of detections is probably in the fact that with the template before, I was using P arrivals and one S arrival. Now I dont use P but use calculated S arrivals.

I will check the detections with detection_multiplot later to see how good they are.

Next step, I will try to detect aftershocks with more templates on many days.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

detection_multiplot plots all the detections agains the st (in this case one day plot).
i tried pretty_template_plot (for template in templates, but since i only have one template ofcourse i only get one plot). all clear here.

it would be usefull to be able to produce plot of one template against the stream and detection, where stream is cuted around the event, so you are able to visualy check if the detection is true event or not. something like the picture in pretty_template_plot but created from all the continuus data and all the detections and templates.

and another question regarding trig_int parameter in match_filter. in my script it is set to 6s. this means that if you have more then 1 detection from the template inside 6s window, only one will be chosen. but as I see this is only true for one template. if you have 2 templates, there can/should be 2 detections inside 6s?

because now I tried with 4 templates, and 2 of them have a detection inside 6s window:
23:45:51.7...
23:45:52.7...

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

trig_int only applies to each template individually, yes. This is more explicit in the forthcoming docs. This is because you might have two templates from vastly different places, but the earthquakes might have similar origin times, so you would want to keep them both. It is up to you what you do with the detections from multiple templates - there is an example of only taking detections separated by 1 second here (the loop beginning with the comment: Extract unique detections from set): http://eqcorrscan.readthedocs.io/en/develop/tutorials/lag-calc.html

As far as the plotting goes - it would be really easy to do exactly what you suggested on your end by using detection_multiplot. I don't plan on adding this plotting feature because:

  1. It is really easy to do yourself because the hard bits have been done for you;
  2. I don't plan on making all the possible plots with EQcorrscan - plotting provides the basis for a lot of other plots, but it is never going to be what everyone wants - matplotlib is your friend.

How to do it:

for detection in detections:
    st_plot = st.copy()  # we will trim in place so we need to copy
    st_plot.trim(starttime=detection.detect_time - 30, endtime=detection.detect_time + 45)
    detection_multiplot(stream=st_plot, template=template, times=[detection.detect_time])

Note that you will need to associate the correct template with the correct detection - each detection object had a template_name item which you can use to associate the correct template with the detection.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

thank you. I managed to do it (well, it does what i want for this case, so i will need to change it for some other case, since the code is not really generalized (need to work on my knowledge of python)).

just one last question, otherwise I think that with the help and explanation u provided I will be able to work with all other utilitis:

if detection.template_name == "042214a.ms":     
          detection_multiplot(stream=st_plot, template=templates[0], times=[detection.detect_time], save=True, savefile=str(detection.template_name)+str(detection.detect_time)+".jpg")

The saved jpgs are tiny (i cant resize them). I know how to set the size if I change the code inside detection_multiplot, but this is not really apropriate. Is there a workaround for this when i call detection_multiplot in my script?

Thanks!

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

I should add a size option, but until then, a workaround would be to use the returned figure object, set the size of that and then save and over-write the one you created.

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Pushed here: 94da62a may as well use that.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

am i doing this correctly? I updated eqcorrscan

M eqcorrscan/utils/plotting.py
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

but when i run the script with

      detection_multiplot(stream=st_plot, template=templates[0], times=[detection.detect_time], save=True, savefile=str(detection.template_name)+str(detection.detect_time)+".jpg", size=(10.5, 7.5))

i get the error:
detection_multiplot() got an unexpected keyword argument 'size'

i also manualy changed plotting.py with the new one and got the same

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

I can't see what command you used to update.

You should use:

git pull origin develop

Sent from my Vodafone Smart

On Jul 21, 2016 8:53 PM, blazvicic [email protected] wrote:

am i doing this correctly? I updated eqcorrscan

M eqcorrscan/utils/plotting.py
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

but when i run the script with

if detection.template_name == "042214a.ms":

detection_multiplot(stream=st_plot, template=templates[0], times=[detection.detect_time], save=True, savefile=str(detection.template_name)+str(detection.detect_time)+".jpg", size=(10.5, 7.5))

i get the error:
detection_multiplot() got an unexpected keyword argument 'size'

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-234195013, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGcyT4D6IcJ2Cctksnf7lUW9RXnUYZks5qXzOFgaJpZM4JMJwF.

from eqcorrscan.

calum-chamberlain avatar calum-chamberlain commented on June 2, 2024

Then run:

pip install .

Or:

python setup.py install

To install the update that you pulled.

Sent from my Vodafone Smart

On Jul 21, 2016 8:53 PM, blazvicic [email protected] wrote:

am i doing this correctly? I updated eqcorrscan

M eqcorrscan/utils/plotting.py
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

but when i run the script with

if detection.template_name == "042214a.ms":

detection_multiplot(stream=st_plot, template=templates[0], times=[detection.detect_time], save=True, savefile=str(detection.template_name)+str(detection.detect_time)+".jpg", size=(10.5, 7.5))

i get the error:
detection_multiplot() got an unexpected keyword argument 'size'

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/40#issuecomment-234195013, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKaGcyT4D6IcJ2Cctksnf7lUW9RXnUYZks5qXzOFgaJpZM4JMJwF.

from eqcorrscan.

TraziBatine avatar TraziBatine commented on June 2, 2024

i skipped python setup.py install
it works now, thanks

from eqcorrscan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.