Computing

This page is primarily my own reference for installing programs and codes on a Mac, but if you find it useful, great!  

The link to my GitHub page is : https://github.com/AntonyButcher

Python packages 

Create a new pygmli environment: 

conda create -n pg -c gimli -c conda-forge pygimli=1.2.6

conda activate pg

pandas: 

conda install pandas

pylops - Geophysical inversion library:

conda install -c conda-forge pylops

disba - Surface wave modelling code:

pip install disba

obspy - Seismic processing library: 

conda install -c conda-forge obspy 

mtspec - required for estimating MW to avoid spectral leakage, this is a collection of modules for spectral analysis using the multitaper algorithm. (https://github.com/gaprieto/multitaper)

conda install -c gprieto multitaper

UTM - Coordinate conversion code:

conda install -c conda-forge utm

wget for data downloading and web scraping. I was unable to get the conda version to work, therefore used pip instead

pip install wget

jupyter lab: 

conda install -c conda-forge jupyterlab


SAC 

Seismic Analysis Code (SAC) is a general purpose waveform analysis and processing application. For MacOS the .dmg install file can be found here - https://members.elsi.jp/~george/sac-download.html#gl

I'm currently using release grh-116, which fixed the error "**MMGETS:  Memory allocation failure due to offset > 32 bits." when using grh-113

If this is a first time install, then you'll also need the display server XQuartz, which is a replacement to X11. 


A few commands to get you started ....

sactosac -m myfile.sac  # use this command before opening sac to ensure the data is in big-endian format. Obspy defaults to little-endian. 

bd xwindow    # open a viewer.

qdp off        # turn off quick dirty plot.

r myfile.sac   # read sac file.

ppk perplot 3  # plot data. per plot stipulates the number of traces displayed. Use p to pick p-wave; s to pick s-wave; q to quit and return to command line.

wh             # writes the header to the file. Note, if endian format is incorrect, then using this command in v116 corrupts the data.


SW4

SW4 is 3D finite difference seismic modelling code written by Lawrence Livermore NL. 

It can be downloaded from here - https://geodynamics.org/cig/software/sw4/

I've installed it on a MacOS running Catalina (10.15.2) which was recently updated from 10.14, and had a few issues to overcome while following the installation guide. 

Before installing the following path to CPATH needed to be added: 

export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/

and the make.inc file needs to be changed to:

etree = no

proj = no

FC = mpif90

CXX = mpicxx

EXTRA_FORT_FLAGS =

EXTRA_LINK_FLAGS = -framework Accelerate -L/usr/local/gcc-8.3/lib -lgfortran

 

Machine Learning

I've install tensorflow and keras for the purposes of using machine learning to detect seismic arrival. Both were installed using conda environments, however I encountered a problem with a numpy dependancy; basically version 1.14 was the default version however this does not have  'numpy.core._multiarray_umath'. Upgrading using 

pip install numpy --upgrade

did the trick. 


Bluepeeble

Here at Bristol, HPC is provided through BluePeeble and BlueCrystal. BluePeeble can be used for everyday computing tasks. Here are some commands to use a node through jupyterlab. 

Log into bluepeeble using 

ssh -X  abxxxxx@bp1-login.acrc.bris.ac.uk

where abxxxxx is your logon credentials

Add the following to you .bashrc file using a module of you choice

# .bashrc

 

# Source global definitions

if [ -f /etc/bashrc ]; then

        . /etc/bashrc

fi

 

# Load modules

module load lang/python/anaconda/3.8.8-2021.05

You'll now need to create a python virtual environment with all the require libraries in you work directory. In this example we have call the env digimon. 

conda create --prefix /user/work/abxxxxx/conda/digimon 'python=3.8.8'


ln -s /user/work/abxxxx/conda/digimon ~/.conda/envs/digimon

Next create a SBATCH file which will run jupyter lab on a BP node. This should also be located in your work directory. 

#!/bin/bash

# launch jupyter

 

#SBATCH --job-name=jupyter

#SBATCH --output=jupyter_out

#SBATCH --error=jupyter_error

#SBATCH --nodes=1

#SBATCH --ntasks-per-node=4

#SBATCH --time=14:00:00

#SBATCH --mem=20G

 

# Setup Environment

source .bashrc

source activate .conda/envs/digimon

 

jupyter lab --no-browser --ip "*" \

            --notebook-dir /user/home/abxxxxx/

The previous steps only need to be carried out once. To run the sbatch file on the BP terminal

sbatch sbatchfilename.sh 

and retrive the allocated node number with 

squeue -u username

on your local terminal run, replacing 194 with your node number.

ssh -N -f -L 8888:bp1-compute194:8888 abxxxxx@bp1-login01.acrc.bris.ac.uk

If you have locked the port which multiple atempts to run this command, the process can be kill with 

lsof -ti:8888 | xargs kill -9

Finally, find the require url in the jupyter_error file

nano jupyter_error

and paste this into you browser. 

To kill a SLURM job use 

scancel 1234567

where 1234567 is the job number.

Use

scp -r abxxxxx@bp1-login01.acrc.bris.ac.uk:/user/work/abxxxxx/1-Data/1-FRS local/

or sync using 

rsync -r abxxxxx@bp1-login01.acrc.bris.ac.uk:/user/work/abxxxxx/1-Data/1-FRS local/

to copy files from remote to local.