Month: August 2008

SLIMpy: SLIM-UBC’s Python interface to Madagascar

August 6, 2008 Systems No comments

In the light of the recent discussion on extending the Python interface to Madagascar, I would like to inform those of you who did not know already about the public release of SLIMpy: SLIM-UBC’s Python interface to out-of-core seismic data processing.
SLIMpy is a Python interface that exposes the functionality of seismic data processing packages, such as MADAGASCAR, through operator overloading. SLIMpy provides a concrete coordinate-free implementation of classes for out-of-core linear (implicit matrix-vector), and element-wise operations, including calculation of norms and other basic vector operations. The library is intended to provide the user with an abstract scripting language to program iterative algorithms from numerical linear algebra. These algorithms require repeated evaluation of operators that were initially designed to be run as part of batch-oriented processing flows. The current implementation supports a plugin for Madagascar’s out-of-core UNIX pipe-based applications and is extenable to pipe-based collections of programs such as Seismic Un*x, SEPLib, and FreeUSP. To optimize performance, SLIMpy uses an Abstract Syntax Tree that parses the algorithm and optimizes the pipes.
The main features of SLIMpy include:
– Powerful interpreted programming language (Python)
– Syntax (through overloading) close to pseudo-code for numerical linear algebra
– Abstract Syntax Tree analyzer/optimizer (including command rearrangement form improved performance)
– Concrete linear operator and vector classes, including dottests, domain-range and type checks
– Elementwise reduction-transformation operations (norms, elementary math)
– Compounded linear operators
– Augmented linear operators and vector classes
– Plugin mechanism for Unix pipe-based collections of (seismic) data processing programs
– Parallel execution of reduction/transformation operations
– Parallel execution of embarrassingly parallel linear operators (block diagonal)
– Integration with SCons
– Automatic cleanup of temporary datafiles (garbage collection)
– In-code documentation through Doxygen
SLIMpy is an academic research code that we share with the community through this alpha release. By making SLIMpy available as open source, we hope to create an active community to further develop this software.
SLIMpy is released under GNU Lesser General Public License, and it is available for download from SVN repositories:
– the core packages from https://wave.eos.ubc.ca/Public/Public.Software.SLIMpy/
– the contributions from https://wave.eos.ubc.ca/Public/Public.Software.SLIMpy-contrib/
Additional documentation and tutorials can be found at
– SLIMpy’s documentation http://slim.eos.ubc.ca/SLIMpy/
– SLIMpy’s tutorial http://slim.eos.ubc.ca/SLIMpy/exampleset1.html
Through this release, we hope that SLIMpy can grow into a widely-used Library, supplementing the functionality of currently available processing-flow oriented (seismic) software packages. Please, use SLIMpy-user (http://slim.eos.ubc.ca/mailman/listinfo/slimpy-user) mailing list to report concerns and exchange the ideas. Those of you, who wish to contribute to development, please, subscribe to SLIMpy-devel (http://slim.eos.ubc.ca/mailman/listinfo/slimpy-devel).
Most of the credit for developing SLIMpy goes to Sean Ross-Ross of the SLIM group.

Extending Python interface

August 3, 2008 Systems No comments

Work is under way on extending the Python interface to Madagascar. With new tools, you should be able to use an interactive Python session rather than a Unix shell to run Madagascar modules. Here are some examples:

import m8r as sf
import numpy, pylab

f = sf.spike(n1=1000,k1=300)[0]

# sf.spike is an operator
# f is an RSF file object

f.attr()

# Inspect the file with sfattr

b = sf.bandpass(fhi=2,phase=1)[f]

# Now f is filtered through sfbandpass

c = sf.spike(n1=1000,k1=300).bandpass(fhi=2,phase=1)[0]

# c is equivalent to b but created with a pipe

g = c.wiggle(clip=0.02,title='Welcome to Madagascar')

# g is a Vplot file object

g.show()

# Display it on the screen

d = b - c

# Elementary arithmetic operations on files are defined

g = g + d.wiggle(wanttitle=False)

# So are operations on plots

g.show()

# This shows a movie

pylab.show(pylab.plot(b))
c = numpy.clip(b,0,0.01)

# RSF file objects can be passed to pylab or numpy

c.attr()
s = c[300:310]

print s

# Taking a slice outputs a numpy array

c = sf.clip(clip=0.01)[b]
c.attr()

# Alternatively, apply sfclip

For doing reproducible research, one can also use the new syntax inside SConstruct files, as follows:

from rsf.proj import *
import m8r as sf

Flow('filter',None,sf.spike(n1=1000,k1=300).bandpass(fhi=2,phase=1))
Result('filter',sf.wiggle(clip=0.02,title='Welcome to Madagascar'))

End()

See also a 4-line dot-product test and 20-line conjugate-gradient algorithm.

The picture shows a screenshot of an interactive session in a SAGE web-based notebook