Install Madagascar (svn 7866) under sage

As I mentioned in the last post, SageMath is a powerful platform for scientific computation integrating your favorite software packages. One of my favorite packages, for example, is Madagascar for seismic data processing and visualization. So I decided to integrate it with sage. I took the following steps:

0. Sage is installed at $SAGE_ROOT
1. unzip one version of Madagascar (in my case it is svn 7866 checked out in Nov 2011). Newer versions should work as well.
2. under the directory of madagascar source, type

sage -sh

to get into the sage shell, followed by
3.

./configure API=python

Sage will automatically configure it with Sage environmental variables and will install it to $SAGE_ROOT/local
4. exit sage shell, and type

sage --scons install

5. now you should find all Madagascar binary executables in $SAGE_ROOT/local/bin together with other binaries files:

x11pen             sfsort            sfplanemis3     sfitaupmo2         sfederiv2d          sfabalance                  rst2s5.py                   mcube
vpwhitepruf        sfsnrstack        sfplanemis2     sfitaupmo          sfdwt97             sfaastack                   rst2xml.py                  optimal
vpvrms             sfsnr             sfplane         sfisolr3           sfdwt               sfTestcdstep                rstpep2html.py              class.x
vpsg               sfsmstack         sfpick3         sfisolr2one        sfduwt              sfScanCoef                  ipbori                      cws.x
vpreflkine         sfsmoothreg2      sfpick          sfisolr2tau        sfdsr2              pspen                       PolyGUI                     mori.x
vpreflexpt         sfsmoothreg       sfphaserot      sfisolr2           sfdsr               ppmpen                      python2                     nef.x
vpreflector        sfsmoothderLS     sfpfactor2      sfisin2ang         sfdrays             pngpen                      python2-config              poly.x
vppen              sfsmoothder2      sfpetscawefd2d  sfiphase           sfdrayinte          pdfpen                      python-config               mori-11d.x
vpnmotraj          sfsmoothder1      sfpermlr2       sfinvrec1          sfdowmf             oglpen                      python                      nef-11d.x
vplot2png          sfsmoothder       sfpermlr3       sfinvbin1          sfdottest           latex2wiki                  python2.7                   cws-11d.x
vplot2gif          sfsmoothcur       sfpermlr1       sfinvbin           sfdots              jpegpen                     srptool                     class-11d.x
vplot2eps          sfsmooth          sfpen           sfinttest2         sfdonf              gdpen                       certtool                    poly-11d.x
vplot2avi          sfslice           xtpen           sfinttest1         sfdominantf         mayavi2                     gnutls-cli-debug            mori-6d.x
vphyplay           sfslant           sfpefdeburst    sfintshow          sfdomf              tvtk_doc                    psktool                     nef-6d.x
vpheadray          sfsizes           sfpef           sfintervalVTI      sfdoeps             editra                      gnutls-cli                  cws-6d.x
vpfrancis          sfsinc            sfpatch         sfinterpt          sfdmo               helpviewer                  gnutls-serv                 class-6d.x
vpellipse          sfsin             sfparcel        sfinterp2          sfdmeig             img2py                      libgnutls-extra-config      poly-6d.x
vpdcretard         sfsimilarity      sfpad           sfinterleave       sfdixshape          pyalamode                   libgnutls-config            mori-5d.x
vpdc               sfsimenv          sfovc           sfintegral1        sfdix               pycrust                     tconic                      nef-5d.x
vpcsp              sfsignoi          sfopsmigrk      sfintbin3          sfdivn              pywrap                      indep                       cws-5d.x
vpcroshyp          sfsigmoid         sfomp           sfintbin           sfdistmap           img2png                     allisog                     class-5d.x
vpconvert          sfsic3d           sfofsemb        sfint3d            sfdistance          img2xpm                     twist                       poly-5d.x
vpcmp              sfsic             sfofpwd2        sfinstattr         sfdisfil            pyalacarte                  torsion                     mori-4d.x
vp7ab              sfshotprop        sfofpwd         sfinmo3            sfdips              pyshell                     conductor                   nef-4d.x
tiffpen            sfshotholes       sfofilp         sfinmo             sfdiplet            pywxrc                      tate                        cws-4d.x
svgpen             sfshotconstkirch  sfoff2abs3      sfinitial          sfdipfilter         xrced                       findinf                     class-4d.x
sfztrace           sfshot2grid       sfoff2abs       sfinfill           sfdip2              wx-config                   ratpoint                    poly-4d.x
sfzomva            sfshot2cmp        sfofd2_7        sfin               sfdip               wxrc                        mwrank                      vsyasm
sfzomig3           sfshoot2          sfofd2_5        sfimray            sfdimag             wxrc-2.8                    opencdk-config              ytasm
sfzomig            sfshifts          sfofd2_25       sfimpl3            sfdijkstra          vtkpython                   fplll_micro                 yasm
sfzoeppritz        sfshift           sfofd2_13       sfimpl2            sfdiffraction       lproj                       llldiff                     freetype-config
sfzerocross        sfshearer         sfofd2_10       sfimpl1            sfdiffoc            vtkEncodeString             generate                    patch
sfzero             sfsharpsimi       sfofd1_5        sfimospray         sfdifference        vtkWrapPython               fplll_verbose               bzless
sfzcwt             sfsharpen         sfofd1          sfimage            sfdespike3          vtkWrapPythonInit           fplll                       bzcmp
sfxlagtoang2d      sfshapesigk       sfoctentwt      sfimag             sfdespike2          ctest                       sage_singular               bzegrep
sfxcor2d           sfshapebin1       sfocparcel      sfreal             sfdespike           cpack                       Singular                    bzfgrep
sfwmf              sfshapebin        sfoclet         sfigrad            sfderiv             cmake                       singular                    bzdiff
sfwkbjTI           sfshapeagc        sfnsmooth1      sfidempatch        sfdepth2time        ccmake                      LLL                         bzmore

and python files under

$SAGE_ROOT/local/lib/python2.7/site-packages/rsf$ ls
apibak.py    gui             sfbash.pyc      sfgee.py        sfjun.pyc       sfmain.py       sfplplot.pyc      sfseplib_compat.py   sftour.pyc       use.py         vplot2png.py
apibak.pyc   __init__.py     sfbrowaeys.py   sfgee.pyc       sfjyan.py       sfmain.pyc      sfpsava.py        sfseplib_compat.pyc  sftrip.py        use.pyc        vplot2png.pyc
api.py       __init__.pyc    sfbrowaeys.pyc  sfgeneric.py    sfjyan.pyc      sfmccowan.py    sfpsava.pyc       sfslim.py            sftrip.pyc       user           vpplot.py
book.py      latex2wiki.py   sfchen.py       sfgeneric.pyc   sfkourkina.py   sfmccowan.pyc   sfrickettj.py     sfslim.pyc           sftriptrace.py   version.py     vpplot.pyc
book.pyc     latex2wiki.pyc  sfchen.pyc      sfgodwinj.py    sfkourkina.pyc  sfparvaneh.py   sfrickettj.pyc    sfsongxl.py          sftriptrace.pyc  version.pyc
conf.py      path.py         sfcuda.py       sfgodwinj.pyc   sflcasasan.py   sfparvaneh.pyc  sfroman.py        sfsongxl.pyc         sftsai.py        vpconvert.py
conf.pyc     path.pyc        sfcuda.pyc      sfivlad.py      sflcasasan.pyc  sfpens.py       sfroman.pyc       sfsumain.py          sftsai.pyc       vpconvert.pyc
conjgrad.py  prog.py         sfeffsilva.py   sfivlad.pyc     sflexing.py     sfpens.pyc      sfsalah.py        sfsumain.pyc         sfxuxin.py       vplot2avi.py
doc.py       prog.pyc        sfeffsilva.pyc  sfjeff.py       sflexing.pyc    sfpetsc.py      sfsalah.pyc       sfsuplot.py          sfxuxin.pyc      vplot2avi.pyc
doc.pyc      proj.py         sffomels.py     sfjeff.pyc      sflibplot.py    sfpetsc.pyc     sfsaragiotis.py   sfsuplot.pyc         sfyliu.py        vplot2eps.py
dottest.py   proj.pyc        sffomels.pyc    sfjennings.py   sflibplot.pyc   sfplot.py       sfsaragiotis.pyc  sftariq.py           sfyliu.pyc       vplot2eps.pyc
flow.py      recipes         sfgchliu.py     sfjennings.pyc  sfllisiw.py     sfplot.pyc      sfseismic.py      sftariq.pyc          tex.py           vplot2gif.py
flow.pyc     sfbash.py       sfgchliu.pyc    sfjun.py        sfllisiw.pyc    sfplplot.py     sfseismic.pyc     sftour.py            tex.pyc          vplot2gif.pyc

Now you can start a sage notebook and text the following code:

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.image()
# 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

The result looks like the following

Link to the Madagascar sage notebook page.

Leave a Reply

Your email address will not be published. Required fields are marked *