(xcor module)= # **xcor module** This optional module allows to compute cross-correlation from a 2D ndarray (or a A1Section) containing a DAS section. The core function is written in fortran and parallelized using openMP. Instead of processing cross-correlation using individual records, the __xcor__ module uses directly the 2D float array containing DAS data. A pre-processing step to select the couple of traces to be cross-correlated is achieved by calling the [register_couple()](#register_couple) function. A number of pre-processing are built-in and available (one-bit, whitenning, bandpass filtering, ...) by calling the [register_par()](#register_par) function. ## Requirements This module requires: - C and fortran compilers (e.g gfortran) and make (gmake is ok) - numpy - one of the **MKL** or **OpenBlas**+**FFTW3** libraries. For linux, these are standard and free libraries that can be easily download using apt-get. Try; apt-get install libfftw3 apt-get install libfftw3-dev apt-get install libopenblas-dev For mac with __arm__ cpu (M1, M2, ...) using OpenBlas and FFTW is mandatory, they can be get from __brew__. Getting a fortran compiler usually requires to install Apple xcode. ## Download and installation 0) Install (tar.gz archive) the xcor module in the same directory as a1das from the gitlab repository (e.g. [in2p3 gitlab](https://a1das-v2-olivier-coutant-fa984751404466eb2f1c34128bcd5750d522ff.pages.in2p3.fr/A1-XCORPY.tar.gz)), you should see a directory named A1-XCORPY. 1) Check that the required libraries are installed and find their locations (/opt/..., /usr/local/lib, /usr/lib/x86_64-linux-gnu, /opt/homebrew, ....). You should look for **libopenblas.a**, **libfftw3.a** or **libmkl** 2) change to A1-XCORPY directory and under a python environment, run the shell **configure_var.sh**, this will create the __Makefile.python__ file 3) select one of the proposed Makefile.inc.???, edit and change according to your needs, then copy it as **Makefile.inc** 4) run the compilation step by typing "**make python**" This should have installed the binary module under the **a1das** directory. If you have already installed the a1das package you can either a) uninstall and reinstall it: python -m pip uninstall a1das pip install . b) or copy the _a1xcorPy.cpython.?? file in the directory where a1das has been installed (e.g. ## Usage ```{eval-rst} .. autofunction:: xcor.compute_xcorr ``` (register_couple)= ```{eval-rst} .. autofunction:: xcor.register_couple ``` ```{eval-rst} .. autofunction:: xcor.reset_couple ``` (register_par)= ```{eval-rst} .. autofunction:: xcor.register_par ``` ```{eval-rst} .. autofunction:: xcor.list_processing ``` ```{eval-rst} .. autofunction:: xcor.trace_index_list ``` ```{eval-rst} .. autofunction:: xcor.sort_xcorr ``` ```{eval-rst} .. autofunction:: xcor.get_nxcorr ```