Matlab utilities - SACLAB

SACLAB - utilities for converting between Seismic Analysis Code (SAC) and Matlab formats

Matlab utilities - Seismic Handler

Utilities for reading SeismicHandler files into Matlab

Matlab utilities - Other sources

SHaxi - downloads

SHaxi - SH-wave axisymmetric finite difference technique for global wave propagation. The most up to date version of the SHaxi software is now available from the subversion site here.

Note: A new release of the SHaxi code was released on 7/22/2008. The new version includes anelasticity, full documentation, and a more examples of integrating user-defined models into SHaxi.

Fortran codes

All fortran codes available here are compilable with g95.

Each utility is packed into a tar file. In order to extract the files type 'tar -xvf utilityname'

Each utility also comes with a makefile. To compile the utility cd into the directory for the utility and just type 'make'.  The makefiles are currently set up for the g95 compiler.

Each makefile has a variable 'BINDIR' which should be set before typing the 'make' command. The variable 'BINDIR' just specifies a location in your search path to copy the executable to. In some cases the routines also contain a man page and the makefile will also contain a variable 'MANDIR'. This variable should also be set to a location in your manpath.

  • prem - prem is a simple program to return the PREM velocities and density for an input depth. It seems I am often wondering what the PREM velocity at some depth is so this makes that lookup easy. It also returns the PREM values with an input dVs, etc. so one can quickly retrieve the actual velocity associated with a tomography model for example.
  • sachead - sachead returns the value of a specified SAC header variable to standard out. Is useful in shell scripts when you want to set a shell variable to the value stored in the header of a SAC file, or to just quickly see the value of a SAC header variable without starting SAC.
  • usage: >> sachead sacfile headervariable

    where: sacfile is the name of the input SAC file to retrieve the header information from; headervariable is the SAC header variable (e.g., gcarc, evla, stla, ...)

    Example of how to set a cshell variable to the SAC header variable gcarc.

    >> set gc = `sachead foo.sac gcarc | awk '{print $2}'`

  • sac2xy - sac2xy takes an input SAC file and returns a table of x,y pairs of time and amplitude of the SAC trace. This is useful when using a program such as GMT to plot seismic waveforms.
  • usage: >> sac2xy sacfile outputfile

    where: sacfile is the name of the input SAC file; outputfile is the name of the file to write the x,y pairs to.

    Example, write the trace in foo.sac to foo.xy

    >> sax2xy foo.sac foo.xy

    xy2sac - this is a rather crude program to take an input Ascii table of values and convert them into SAC format. It only sets the most minimal of header values because most header values are specific to what you are converting. But, it will take your ascii data and turn it into a SAC file, which is the hardest part. For this program the input data must have column 1 = time values, column 2 = amplitude values.

    amp2sac - similar to xy2sac but takes as input a vector of amplitude values and converts to a SAC file. Command line input lets you set the sampling interval.

Other utilities, Shell scripts etc.

  • statmap - make quick event/station map from SAC files. (requires sachead from above)

Fortran tricks - useful f95 tricks

  • commandline.f90 - Example code showing how to read command line arguments in f95
  • num2str.f90 - Example code showing how to take an integer or real variable and convert it into a character string.
  • progress.f90 - Shows how to add a non-advancing status counter to a loop.

Contact

  • email: michael.thorne at utah.edu