## Plotting with matplotlib

September 12, 2019 Programs 1 comment

Matplotlib is a popular Python library for 2D plotting, which emulates (and exceeds) the plotting functionality of MATLAB.

At the Madagascar Working Workshop in 2018, a couple of new scripts were added to simplify plotting with Matplotlib in Madagascar.

• sfmatplotlib can be used to plot RSF files.You can use it as follows:
sfmatplotlib <matplotlib function> <plot options> [format=eps] < inp.rsf [ > out.eps]


Without the standard output, the figure is displayed on the screen.

The figure above was generated with

sfspike n1=1000 k1=300 | sfbandpass fhi=2 phase=y| sfmatplotlib plot title="Welcome to Maagascar" grid=y linewidth=3 format=png > figure.png


Futher enhancements are possible.

• sfpgreywfl is a script contributed by Carlos da Costa that uses matplotlib for plotting a seismic wavefiels overlaid on the velocity model.

The figure above was generated with

sfpgreywfl < wavefield.rsf bg=velocity.rsf wflcmap=seismic title="Wavefield" barlabel="Velocity (m/s)" tmin=0.08 savefile=figure.gif


## scons2jupyter

September 9, 2019 Programs No comments

scons2jupyter is a simple script that converts a Madagascar-style SConstruct file to a Jupyter notebook with a Python interface.

You can use it by simply running

scons2jupyter < SConstruct > mynotebook.ipynb


An example notebook is the result of running scons2jupyter in bei/vela/vscan.

A newly created notebook can be populated with Markdown text and explanations to implement the discipline of literate programmins.

## Program of the month: sfsnr2

August 10, 2019 Programs 1 comment

sfsnr2 computes the signal-to-noise (SNR) ratio in decibells.

The following example from tccs/intshape/fsyn uses the SNR computation to compare the convergence of two different methods.

SNR is computed according to the equation

$SNR=\displaystyle 10\log_{10}\left(\frac{\Arrowvert \mathbf{s} \Arrowvert_2^2}{\Arrowvert\mathbf{n}\Arrowvert_2^2}\right)$

The signal vector $\mathbf{s}$ is in the standard input, the noise vector $\mathbf{n}$ is in the file specified by noise= parameter.

## Program of the month: sflpf

July 9, 2019 Programs No comments

sfslpf estimates a non-stationary filter using shaping regularization.

The method is described in the reproducible paper Adaptive multiple subtraction using regularized nonstationary regressio

The following example from tccs/lpf/plut shows a common-offset section from the Pluto synthetic dataset before and after adaptive multiple subtraction with the help of sflpf.

Given target data $m(\mathbf{x})$ (specified with match= parameter) and a collection of fitting functions $s_k(\mathbf{x})$ (specified in the standard input), sflpf finds the fitting coefficients $b_k(\mathbf{x})$ by minimizing the error

$m(\mathbf{x}) – \displaystyle \sum_{k=1}^{N} b_k(\mathbf{x})\,s_k(\mathbf{x})$

while constraining the coefficients to be smooth. The smoothness is controlled by rect#= parameters, as in sfsmooth.

Shaping regularization is carried out iteratively, niter= controls the number of iterations.

The mean coefficient from the example above is shown in the figure below.

Optionally, a prediction-error filter can be applied to whiten the residual. The filter is specified with the help of pef= and lag= parameters, with a multidimensional helical filter specified as in sfhelicon.

The complex version of the same program is sfclpf.

## Program of the month: sfslice

June 12, 2019 Programs No comments

sfslice extracts a slice from the data given by a curve (in 2-D) or a surface (in 3-D).

The right plot in the following example from gee/prc/bob shows the semblance extracted using sfslice from the semblance scan along the trajectory picked with sfpick.

sfslice does not have parameters other than pick=, which points to the file with the surface for extraction.

It performs a simple linear interpolation to extract the values.

## sfbargraph

June 6, 2019 Programs No comments

sfbargraph is a new plotting program for displaying data as bars.

The bottom plot in the figure below shows a simple example from rsf/rsf/sfnoise.

The unique parameters of sfbargraph include width= for controling the relative width of the bars and stack= to control if the bars from multiple input traces should be stacked on top of one another.

The other parameters are shared with other plotting programs.

## Program of the month: sfzomig3

May 6, 2019 Programs No comments

sfzomig3 performs 3-D zero-offset modeling or migration using one-way wave extrapolation and the exploding reflector concept.

The following example from rsf/su/rsflab10 shows the result of migrating the benchmark Viking Graben dataset.

The algorithm used by sfzomig3 is known as extended split-step or phase-shift plus interpolation (PSPI). It works in the frequency domain and mixed space-wavenumber domain.

• Gazdag, J., and Sguazzero, P., 1984, Migration of seismic data by phase shift plus interpolation: Geophysics, 49, 124-131.
• Kessinger, W., 1992, Extended split-step Fourier migration: 62nd Ann.
Internat. Mtg., Soc. Expl. Geophys., Expanded Abstracts, 917-920.

Depending on inv= flag, sfzomig3 performs modeling or migration (if mode=m) or datuming (upward or downward) wavefield continuation (if mode=d). The default is migration (mode=m inv=n).

The algorithm efficiency depends on the number of reference velocities, which corresponds to the number of spatial Fourier transforms. By default, the algorithm is trying to estimate this number automatically at each depth step. The maximum number can be set by nrmax=.

The pmx=, pmy=, and tmx=, tmy= parameters control padding and tapering in space, needed to avoid boundary reflections and Fourier wrap-around artifacts.

## Program of the month: sfseislet

April 19, 2017 Programs No comments

sfseislet implements the 2-D seislet transform.

The seislet transform theory is descibed in the paper Seislet transform and seislet frame.

The following example from fpwd/teapot shows a 3-D seismic image before and after a seislet transform in the inline direction.

To perform the forward seislet transform, run sfseislet with the flag adj=y. To run the inverse transform, use adj=n. In a confusing choice of parameter names, inv= does not control the direction of the transform but the type of the weighting function used. Another control is provided by unit=.

A required auxiliary input is the dip field specified by dip=. If the dip was estimated using plane-wave destruction (sfdip), the order= parameter should be the same.

Different types of the seislet transform (specified by type=) correspond to different types of the corresponding digital wavelet transform. The choices are haar, linear, and biorthogonal.

## Program of the month: sflinear

March 23, 2016 Programs No comments

sflinear performs 1-D linear interpolation of irregularly spaced data.

The following example from rsf/su/rsflab4 shows a linearly interpolated velocity profile:

The input to sflinear contains coordinate-value pairs arranged so that the second dimension of the data is n2=2. The output contains regularly sampled values on the specified grid.

If the input coordinates are not in order and need sorting, use sort=y.

The output grid can be specified either by supplying it in a pattern file pattern= or by specifying the usual parameters n1=, o1=, d1=.

If the number of iterations specified by niter= is greater than zero, sflinear switches from simple linear interpolation to iterative interpolation by shaping regularization, which can produce a smooth output. The additional parameters to control this process are nw= (size of the local Lagrange interpolation filter for forward interpolation) and rect= (smoothing radius for shaping).

## Program of the month: sfmig2

February 18, 2016 Programs No comments

sfmig2 implements 2-D prestack Kirchhoff time migration.

The program is using triangle antialiasing filters.

J. F. Claerbout, 1992, Anti Aliasing: SEP-73, Stanford Exploration Project, 371-390.

D. E. Lumley, J. F. Claerbout, and D. Bevc, 1994, Anti-aliased Kirchhoff 3-D migration: SEG Annual Meeting, Expanded Abstracts, 1282-1285.

The following example from sep/aal/gulf shows migration applied to a near-offset section from the Gulf of Mexico.

The amount of antialiasing is controlled by antialias= parameter.

A half-derivative waveform-correction filter (rho filter) is applied and is controlled by rho= parameter.

The program has an adjoint flag adj= and can be used as a linear operator. The default value adj=y corresponds to migration, adj=n corresponds to modeling (demigration).

An additional required input is vel= (time-migration velocity). An optional output is gather= (common-offset image gathers).