Table Of Contents

Previous topic

Module correlationGoodNumber

This Page

Tutorial

  1. Libraries needed

  2. Packages needed

  3. Processing traces

  4. Compute the correlations

  5. Take also a look at the OVERVIEW OF THE PACKAGES.

Libraries needed

For runnings applications you need the following libraries:

More precisely we use at the present time:

numpy.__version__
'1.5.0'
scipy.__version__
'0.9.0.dev6939'
obspy.core.__version__
'0.4.7'
obspy.signal.__version__
'0.4.8'
obspy.sac.__version__
'0.4.6'
obspy.mseed.__version__
'0.4.7'

Packages needed

Obvioulsy you need the packages traces, correlations.

Processing traces

For processing the traces you should follow the steps:

  • Set the parameters in the module traces.tracesParam.

  • Define the treatment before resampling.

  • Define the treatment after resampling.

  • (optionaly) add a new treatment.

  • Then you have only to type (for whisper users):
    $ cd traces
    $ python2.7 tracesMain.py

    But, before, you should set your parameters and the treament.

  1. Set the parameters:

    Suppose:

    • There is a directory named DirTraces in your homedir with files whose format are sac, mseed, gse2, etc...
    • You want to processing the traces for the stations named ‘ARIG’, ‘CAIG’ and ‘CCIG’.
    • You want only the east component E.
    • You want only the traces between the 2003-11-09 to the 2004-05-24, that is, with julian day, from 2003-313 to 2004-115.
    • You want to save the traces treated in a directory ‘test/TracesTread/’.
    • You want to change the sampling to 2Hz.

    Set parameters for processing traces in the module traces.tracesParam:

    alternate text

    Note

    Note that the boolean variable HasToMakeDictOfTraces is setting to True because it is the first time we processing these traces with these parameters.

  2. Define the treatment

    Before resampling, suppose you want to filter the trace between 1 second and 3 seconds with the function traces.tracesFunctions.makeFiltfiltAndButterFromPeriod() of the module traces.tracesFunctions with a butter of order 3. The function traces.tracesDefineTreatments.makeTreatmentTraceBeforeNewFrequence() in the module traces.tracesDefineTreatments is currently empty:

    alternate text

    Then you define a variable OrderButter equal to 3, a variable PeriodMin set to 1.0 and a variable PeriodMax set to 3.0. You add the following code in the function traces.tracesDefineTreatments.makeTreatmentTraceBeforeNewFrequence() in the module traces.tracesDefineTreatments:

    alternate text

    Note

    You can also do the same with the library scipy and with the function filtfilt() (see here) before resampling. Define also a Butterworth of order 3.

    Add the following code to the function traces.tracesDefineTreatments.makeTreatmentTraceBeforeNewFrequence() in the module traces.tracesDefineTreatments:

    alternate text

    Suppose you want to make a treatment with the function traces.tracesFunctions.glitchCorrectionWithFactorStd() contains in the module traces.tracesFunctions after resampling. Moreover, you use the function highpass() of the library obspy. Add the following code to the function traces.tracesDefineTreatments.makeTreatmentTraceAfterNewFrequence() in the module traces.tracesDefineTreatments (define your own parameters):

    alternate text
  3. Add a new treatment

    Suppose you have define a function foo() with parameters p1, p2. Then add a code like this in the module traces.tracesFunctions:

    alternate text

    Then add the new treatment, for example after the resampling, traces.tracesDefineTreatments.makeTreatmentTraceAfterNewFrequence() in the module traces.tracesDefineTreatments. Verify the signature and choose the good order for the treatments:

    alternate text
  4. Processing the traces

    Now, for processing the traces, you have to launch the module traces.tracesMain. Simply type (for whisper users):

    $ cd traces
    $ python2.7 tracesMain.py
  5. Processing the traces with new treatments

    If you have already made a treatment and you want to change it, you can save time by skiping the construction of dictionaries made by the module traces.tracesDictOfTraces. Just set the parameter HasToMakeDictOfTraces to False in the module traces.tracesParam:

    HasToMakeDictOfTraces = False
    

    If you want to compute the other component ‘Z’, set:

    ComponentStation = 'Z'
    
    HasToMakeDictOfTraces = False
    

    You can take also a subset of stations and a subset of dates. But do not change the SaveDirectory where the dictionaries are save (or copy them in the new folder).

    Note

    If you have a set of traces (stations, dates) but you do not know the treatments, you can save time by processing the traces (take a very small NewFrequence!) with no treatments and thus get the dictionaries (detroy the traces).

Compute the correlations

Now you have the traces treated with a well architecture of files in the directory ‘test/TracesTread/’.

  1. Set the parameters:

    Suppose you want to compute the correlations of the existing traces in the directory ‘test/TracesTread/’

    • The sampling of the processing traces is now 2.0 Hz. So the length of the ‘day-traces’ is LenTrace=2*86400=172800 points.
    • You take a lag of one hours, i.e. Maxlag= 7200 points.
    • You want to read the correlations with matlab, then you choose the format ‘mat’.
    • You have also to choose a ‘GoodNumber’, a number great than LenTrace+Maxlag. If you have no idea, take the next power of two, i.e. 262144. But here, you can take a ‘best number’ for the correlations: 187500.
    • You want to compute between the components ‘Z’ and ‘E’ (first station and second station).

    You have to change the module correlations.correlationsParam as follows:

    alternate text
  2. Compute the correlations:

    • You want to save them in a directory ‘/home/test/Correlations’.
    • You want to compute between the components ‘Z’ and ‘E’ (first station and second station).

    Then launch the module correlations.correlationsMain as follows (for whisper users):

    $ cd correlations
    $ python2.7 correlationsMain.py oneList test/TracesTread/ /home/test/Correlations Z E 1 0 1 0
  3. Decentralized computation

    You can choose to compute the correlations for a subset of the list of dates and a subset of the list of stations You can divide the list of dates into 14 equal sublists and focus only on the tenth sublist. You can choose also the two sublist of stations and take only the first.

    Note

    The sublist are made by the correlations.correlationsUtil.makeListOfSubListFromList(). Sublist have disjoints elements , the same length (+1 or -1) and order in the same way as the original list.

    Then set:

    $ cd correlations
    $ python2.7 correlationsMain.py oneList test/TracesTread/ /home/test/Correlations Z E 14 9 2 0

    You can choose also to compute correlations for two sublists of stations. Then change the tag ‘onelist’ into the tag ‘twoLists’ and choose the appropriate indexes for the sublists of stations like this (here between the first and the second subilst of stations):

    $ cd correlations
    $ python2.7 correlationsMain.py twoLists test/TracesTread/ /home/test/Correlations Z E 14 9 2 0 1


Whisper project: FP7 ERC Advanced grant 227507 (WHISPER).
Codes are develop for the Whisper project (Seismic ambient noise).
If you use this code, specify it is provide by: Whisper project FP7 ERC Advanced grant 227507 (WHISPER).
Author: Xavier Briand. For questions, send email to xav.briand.whisper@gmail.com with subject begin exactly with [whisper].