Results for: font

Japanese “Hiragana” and “Katakana” fonts in Madagascar

January 28, 2010 Celebration No comments

Update Madagascar and try “\F17” and “\F18”, respectively. The ligatures can be found in Wiki page: http://en.wikipedia.org/wiki/Hiragana and http://en.wikipedia.org/wiki/Katakana.

A journal requires a particular font (e.g. Arial or Helvetica) in figure labels. How do I achieve that?

October 15, 2008 FAQ No comments

Update: If you generate Geophysics manuscripts using rsf.tex, the font change should happen automatically. Otherwise, use font= parameter.

See also:

How do I change fonts in vplot graphics?

October 27, 2007 Uncategorized 10 comments

The collection of fonts in Vplot is small and goes back to so-called “Hershey fonts” (created originally by Dr. A.V. Hershey at the U. S. National Bureau of Standards).
You can use \F# directives to switch between different fonts.
In general, there are two sorts of escape sequences, those that take an argument and those that do not. Here is a complete list of escape sequences that do not take an argument:

  • \> Advance one interletter space
  • \< Back up one interletter space
  • \\^Raise one half of a capital letter height
  • \\_ Lower one half of a capital letter height
  • \g Continue processing text, but don’t actually print it (“ghostify it”).
    This is useful if you want to leave space to go back and add something by hand.
  • \G Start printing text again (“deghostify”)
  • \n Newline
  • \h Backspace (control-h also works) back up over the last character
  • \- Does nothing; used to prevent a group of characters from being formed into a ligature.
  • \\ Print a backslash

The following escape sequences take an integer argument immediately after, with a required space after the integer to delineate the end. This space is not printed.

  • \s# Size change. Change to # percent of the size set in the text vplot. \s100 restores the default height.
  • \f# Add # to current fatness. Goes out of effect when text printing is finished.
  • \F# Switch to font number #. (-1 restores the default font).
  • \k# Move by # space widths to the right (in percent; 100 = one space width). Negative numbers are allowed (moves left).
  • \r# Move up # character heights (in percent; 100 = the height of a standard capital letter). Negative numbers are allowed (moves down).
  • \v# Print ASCII character number # in the current font, stripping it of any special meaning. This and ligatures are the only way that glyphs numbered greater than 255 are available.
  • \c# Switch to color number #. \c-1 restores the current drawing color. Vplot’s current drawing color is not changed by changing the color inside text.
  • \m# Save current position in register number #.
  • \M# Restore position saved in register number #.

The following example is from rsf/rsf/sfgraph:

The line to create this title is

title="\s100 \F11 Polinom CHebysheva + \F3 T\\_\s75 n\\^\s100 (cos \F10 q) = \F3 cos n\F10 q"

.
You can find a set of tests for different fonts in pens/tests:


Font 0
original (designed by Rob Clayton at Stanford)
Font 1
roman simplex
Font 2
roman duplex
Font 3
roman complex
Font 4
roman triplex
Font 5
italic complex
Font 6
italic triplex
Font 7
script simplex
Font 8
script complex
Font 9
greek simplex
Font 10
greek complex
Font 11
Cyrillic complex
\Font 12
German style gothic triplex
Font 13
Greek style gothic triplex
Font 14
Italian style gothic triplex
Font 15
mathematics
Font 16
miscellaneous

To display a particular font character by character on the screen, try something like

sfplas < RSFSRC/pens/fonts/cyrilc.vplot_font | \
xtpen xcenter=0 ycenter=0 scale=50 pause=1

Thanks to Joe Dellinger for help with this answer! For more information, see his presentation on Vplot and vplotttext.m.

How can I read and write RSF files in MATLAB?

April 13, 2013 FAQ No comments

  • The most straightforward way is to install the MATLAB interface to Madagascar. When installing Madagascar, run
    ./configure API=matlab

    The configure script will try to find and test matlab and mex executibles on your system. If they are not in your PATH, you can specify them with

    ./configure API=matlab MATLAB=/path/to/matlab MEX=/path/to/mex

    Install Madagascar as usual, set MATLAB path to $RSFROOT/lib, and you will able to read and write RSF files from MATLAB using rsf_read, rsf_write, and other functions from the Madagascar interface.

  • Alternatively, you can try reading binary data using MATLAB functions, as in the following example

    % get in=, n1=, and n2= parameters from file.rsf
    [stat,in] = unix(‘sfget in parform=n < file.rsf’)
    in = strtrim(in)
    [stat,n1] = unix(‘sfget n1 parform=n < file.rsf’)
    n1 = str2num(n1)
    [stat,n2] = unix(‘sfget n2 parform=n < file.rsf’)
    n2 = str2num(n2)
    % read binary data
    fid = fopen(in,‘rb’)
    data = fread(fid,n1*n2,‘float32’);
    % reshape to 2-D matrix
    data = reshape(data,n1,n2);
  • An even better alternative is to abandone MATLAB in favor of free software, such as GNU Octave, Python with NumPy, Sage, etc. A Python interface to Madagascar is installed by default.

Program of the month: sfgraph

August 9, 2011 Programs 4 comments

sfgraph belongs to the family of plotting programs and is used for plotting explicitly defined 2-D curves.

Here are 10 basic facts about this program:

  1. sfgraph shares most of its parameters with some other 2-D plotting programs (sfgrey, sfcontour, sfwiggle). These common parameters can be accessed by running sfdoc stdplot. The following plot from rsf/rsf/sfgraph is using parameters grid=y gridcol=5 pad=n and some creative changes of fonts in the title.
  2. If the input to sfgraph is real, it is understood as representing a regularly sampled 1-D function Y(X), where X is sampled according to n1=, o1=, and d1= parameters in the input file.
  3. If the input is complex, its real part is taken as X, and the imaginary part is taken as Y. If the input is real initially, it is easy to turn it into complex by using sfcmplx or sfdd.
  4. If the n2 parameter in the input is greater than 1, multiple curves are plotted. The following plot from rsf/rsf/sfmath shows plots of closed curves defined by a complex-valued input.
  5. If the n3 or any of the larger dimensions is greater than 1, the plot becomes a movie.
  6. By default, the graphs are plotted with lines. One can control the line appearance with generic parameters dash=, plotcol=, plotfat=.
    The following plot from jsg/seislet/sin2 contained dashed lines created with dash=1,2,0.
  7. If symbol= is specified, the graph is plotted with the given symbols. The size of the symbol is controlled with symbolsz=. The following plot from sep/precon/oned is created with symbol=”md” symbolsz=7.
  8. The displayed function can be changed from $Y(X)$ to $X(Y)$ by using transp= parameter. The following plot from jsg/nmo3/azimuthtest is created with transp=y yreverse=y symbol=+ symbolsz=4.
  9. The ranges of $X$ and $Y$ are selected automatically but can be controlled with min1=, max1=, min2=, max2=.
    If you want automatic ranges, but no padding around minimum and maximum values, use pad=n.
  10. sfgraph avoids plotting infinite or NaN (not a number) values.

How do I prepare a Geophysics article for submission?

March 20, 2011 FAQ No comments

The Geophysics instructions to authors state

Preferred formats for production are Microsoft Word and LaTeX, in that order.

Never mind the order. If you use LaTeX, you are not alone. According to SEG staff, half of submitted papers use LaTeX, including papers from many of the SEG editors. The SEGTeX package has been downloaded from SourceForge more than 5,000 times. Here are some useful trips for producing a Geophysics paper with SCons and rsf.tex:

1. If you don’t use Madagascar for your computations but would like to use the SCons setup for papers, you can download and install the madagascar-framework Python package.

2. To prepare a paper called article.tex for submission, put

use rsf.tex
Paper('article',options='manuscript')

in you SConstruct, then run scons article.pdf to produce the manuscript or scons article.read to display it on the screen. If your paper is named paper.tex, you can also put the options in

End(options='manuscript')

and use simply scons pdf and scons read. See the wiki documentation for more options and explanations.

3. Submit your paper by login into ManuscriptCentral.

4. After your paper goes through a round of revisions, you will be asked to prepare and submit both the new version and the revised version with the revision clearly marked. Use \old{} and \new{} macros to mark your changes, as shown in the example. You can produce both PDF files from once source using something like

use rsf.tex
Paper('article',options='manuscript')

Command('article-revised.tex','article.tex','cp $SOURCE $TARGET') 
Paper('article-revised', options='manuscript,revised')

5. When submitting the final version, you will be asked to submit the LaTeX file that includes bibliography. If you use BibTeX, do the following:

  1. Run scons article.pdf
  2. Open article.ltx in an editor and replace the line \bibliography{} with the contents of article.bbl.
  3. Submit article.ltx.

6. When submitting the final version, you will be asked to submit high-resolution figures in EPS format. Run scons article.figs to generate figures suitable for submission.

7. Geophysics may insist that the labels on the vertical axis in your Madagascar plots should run horizontally, rather than vertically. To comply with this bizarre requirement, you may need to regenerate your plots using parallel2=n option.

See also:

What are the most popular programs in Madagascar?

February 8, 2009 FAQ No comments

In reverse order, the 10 most popular programs in Madagascar are:
10. sftransp Transpose two axes in a dataset (used in 83 projects)
9. sfadd Add, multiply, or divide RSF datasets (used in 92 projects)
8. sfgraph Graph plot (used in 99 projects)
7. sfspike Generate simple data: spikes, boxes, planes, constants (used in 109 projects)
6. sfcat Concatenate datasets (used in 110 projects)
5. sfput Input parameters into a header (used in 118 projects)
4. sfmath Mathematical operations on data files (used in 143 projects)
3. sfdd Convert between different formats (used in 163 projects)
2. sfwindow Window a portion of a dataset (used in 216 projects)
1. sfgrey Generate raster plot (used in 260 projects)
More documentation on these and other programs – in Guide to Madagascar programs.
The three most popular programs in the “generic” category (signal processing programs applicable to any kind of data) are sffft1 (Fast Fourier Transform along the first axis), sfnoise (Add random noise to the data), and sfsmooth (Multi-dimensional triangle smoothing).
The three most popular programs in the “seismic” category (signal processing programs applicable to seismic data) are sfmutter (Muting), sfricker1 (Convolution with a Ricker wavelet), and sfsegyread (Convert a SEG-Y or SU dataset to RSF).
Here is a simple Python script that extracts the popularity information:

#!/usr/bin/env python
from rsfdoc import progs
import rsfprog
def nuses(p):
‘how many times a program is used’
n=0
uses = progs[p].uses
for book in uses.keys():
for chapter in uses[book].keys():
n = n + len(uses[book][chapter])
return n
programs = progs.keys()
programs.sort(lambda x,y: nuses(y)-nuses(x))
for prog in programs:
print ‘%s is used in %d projects’ % (prog,nuses(prog))

RSF hypercubes acquire physical dimensions

March 17, 2006 Programs No comments

At the suggestion of Gilles Hennenfent, certain RSF programs now recognize unit1=, unit2=, etc keywords in addition to label1=, label2=, etc. This allows for more control on physical dimensionality.
Here is an example of having some fun with physical units:

  1. Create some data.
    bash$ sfspike n1=100 n2=100 > spike.rsf
    bash$ sfin spike.rsf
    spike.rsf:
    in="/var/scratch/spike.rsf@"
    esize=4 type=float form=native
    n1=100         d1=0.004       o1=0          label1="Time" unit1="s"
    n2=100         d2=0.1         o2=0          label2="Distance" unit2="km"
    10000 elements 40000 bytes
    
  2. Convert kilometers to feet:
    bash$ sfunits unit2=ft spike.rsf >> spike.rsf
    Converting "km" to "ft" on axis 2
    bash$ sfin spike.rsf
    spike.rsf:
    in="/var/scratch/spike.rsf@"
    esize=4 type=float form=native
    n1=100         d1=0.004       o1=0          label1="Time" unit1="s"
    n2=100         d2=328.084     o2=0          label2="Distance" unit2="ft"
    10000 elements 40000 bytes
    

    sfunits is a new script for unit conversion. It relies on the Unix units utility.

  3. Apply 2-D FFT transform.
    bash$ < spike.rsf sffft1 | sffft3 axis=2 > fft.rsf
    sffft3: padded to 200
    bash$ sfin fft.rsf
    fft.rsf:
    in="/var/scratch/fft.rsf@"
    esize=8 type=complex form=native
    n1=55          d1=2.31481     o1=0          label1="Frequency" unit1="1/s"
    n2=200         d2=1.524e-05   o2=-0.001524  label2="Wavenumber" unit2="1/ft"
    11000 elements 88000 bytes
    
  4. Transform back.
    bash$ < fft.rsf sffft3 axis=2 inv=y | sffft1 inv=y > back.rsf
    bash$ sfin back.rsf
    back.rsf:
    in="/var/scratch/back.rsf@"
    esize=4 type=float form=native
    n1=100         d1=0.00400001  o1=0          label1="Time" unit1="s"
    n2=100         d2=328.084     o2=0          label2="Distance" unit2="ft"
    10000 elements 40000 bytes
    

Warning: this is a substantial change that affects many programs and examples. Please report any problems.

Contributing programs to RSF

August 3, 2005 FAQ No comments

I would like to contribute my program to RSF. What do I do?
Update: Please see Adding new programs to madagascar.

Timing the execution

June 3, 2005 Examples No comments

You can now time the execution of processing flows in Scons using a TIMER option. Use it like this:
scons TIMER=y <target>
An example from rsftour:


bash$ scons -Q TIMER=y windowed.rsf
/usr/bin/time < Txx.HH /path/to/RSF/bin/sfwindow n2=10 n1=200 f1=200 > windowed.rsf
0.00user 0.01system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (170major+25minor)pagefaults 0swaps

Thanks to Jim Jennings for the idea.