MSNoise is capable of using a reference function defined by absolute or
relative dates span. For example, an absolute range could be “from 1 January
2010 to 31 December 2011” and a relative range could be “the last 200 days”.
In the latter case, the REF will need to be exported at every run, meaning the
following steps (MWCS and DTT) will be executed on the whole configured period.
If the REF is defined between absolute dates, excluding “today”, the MWCS and
DTT will only be calculated for new data (e.g. “yesterday” and “today”).
The corresponding configuration bits are `ref_begin`

and `ref_end`

. In the
future, we plan on allowing multiple references to be defined.

Only data for new/modified dates need to be exported. If any CC-job has been marked “Done” within the last day, the stacks will be calculated and a new DTT job will be inserted in the database. For dates in the period of interest, the moving-window stack will only be exported if new/modified CCF is available. The export directory are “REF/” and “DAY%03i/” where %03i will be replaced by the number of days stacked together (DAYS_005 for a 5-days stack, e.g.).

Please note that within MSNoise, stacks are always *inclusive* of the time/day
mentionned. For example, a 5-days stack on January 10, will contain
cross-correlation functions computed for January 6, 7, 8, 9 AND 10!
The graphical representation centered on a “January 10” tick might then display
changes in the CCF that occurred *on* the 10th !

Moving-window stack length(s) are configured using the `mov_stack`

bit.

If `stack_method`

is ‘linear’, then a simple mean CFF of all daily is saved
as the mov or ref CCF. On the other hand, if `stack_method`

is ‘pws’, then
all the Phase Weighted Stack (PWS) is computed and saved as the mov or ref CCF.
The PWS is done in two steps: first the mean coherence between the instataneous
phases of all windows is calculated, and eventually serves a weighting factor
on the mean. The smoothness of this weighting array is defined using the
`pws_timegate`

parameter in the configuration. The weighting array is the
power of the mean coherence array. If `pws_power`

is equal to 0, a linear
stack is done (then it’s faster to do set `stack_method`

= ‘linear’). Usual
value is 2.

Warning

PWS is largely untested, not cross-validated. It looks good, but that doesn’t mean a lot, does it? Use with Caution! And if you cross-validate it, please let us know!!

Schimmel, M. and Paulssen H., “Noise reduction and detection of weak, coherent signals through phase-weighted stacks”. Geophysical Journal International 130, 2 (1997): 497-505.

`ref_begin`

: Beginning or REF stacks. Can be absolute (2012-01-01) or relative (-100) days (default=1970-01-01)`ref_end`

: End or REF stacks. Same as ref_begin (default=2018-01-01)`mov_stack`

: Number of days to stack for the Moving-window stacks ([5]= [day-4:day]), can be a comma-separated list 1,2,5,10 (default=5)`stack_method`

: Stack Method: Linear Mean or Phase Weighted Stack: [linear]/pws (default=linear) |*new in 1.4*`pws_timegate`

: If stack_method=’pws’, width of the smoothing in seconds : 10.0 (default=10.0) |*new in 1.4*`pws_power`

: If stack_method=’pws’, Power of the Weighting: 2.0 (default=2.0) |*new in 1.4*

The best way to call this code is to start it from the console (-h shows the help)

```
$ msnoise stack --help
Usage: msnoise-script.py stack [OPTIONS]
Stacks the [REF] and/or [MOV] windows
Options:
-r, --ref Compute the REF Stack
-m, --mov Compute the MOV Stacks
-s, --step Compute the STEP Stacks
-i, --interval INTEGER Number of days before now to search for modified
Jobs
--help Show this message and exit.
```

On a routine basis, one should thus run the following to compute REF *and* MOV
stacks:

```
$ msnoise stack -r -m
```

While, when playing around with data, and surely on the first run, one should
define the *-i INTERVAL*, as jobs might have been marked “Done” more than 24
hours before running the stack. This, for example, will tell the code to search
for jobs marked in the last 10 days:

```
$ msnoise stack -r -m -i 10
```

New in version 1.4: The Phase Weighted Stack.