Sandbox: Difference between revisions
How to transform a jpg image into a RSF file |
|||
Line 119: | Line 119: | ||
End () | End () | ||
</python> | </python> | ||
=How to transform a RSF file into an image, without axes= | |||
==Using sfbyte2jpg== | |||
<bash> | |||
< model.rsf sfbyte | sfbyte2jpg > model.jpg | |||
</bash> | |||
Then use another program to convert <tt>model.jpg</tt> to the desired format. | |||
==Using ImageMagick== | |||
The following commands can be used in a SConstruct to generate almost any type of bitmap output: | |||
<python> | |||
Flow('data.gray','data', | |||
''' | |||
transp | # Make data in row-major order | |||
byte gainpanell=all allpos=y | # Convert data to byte representation | |||
disfil col=1 format="%02X" | # Dump data in one column in ASCII-hex | |||
sed -e "s/\s*[0-9]*\:\s*//g" | # Strip column numbers | |||
xxd -r -p # Read ASCII output and convert it to binary form | |||
''') | |||
Flow('data.png','data.gray', | |||
''' | |||
convert -size %dx%d -depth 8 ${SOURCES[0]} ${TARGETS[0]} # Run ImageMagick | |||
''' % (n2, n1), stdin=0, stdout=0) | |||
</python> | |||
This one uses a 3rd party tool from ImageMagick suite (which | |||
nowdays is included by default in any Linux distribution). It knows | |||
almost any existing bitmap format. Just change the extension | |||
in the last Flow() from .png to .gif or .jpg, for example. | |||
Create the output simply by running scons data.png | |||
=Artwork= | =Artwork= | ||
ASCII art – possibly useful for error messages, text UIs with <tt>ncurses</tt>, etc. Standard font: | ASCII art – possibly useful for error messages, text UIs with <tt>ncurses</tt>, etc. Standard font: |
Revision as of 20:17, 23 June 2009
The Wiki Sandbox contains links to:
- useful documentation bits from the blog, mailing lists and forums. These bits may coagulate into documentation pages when a critical mass on a topic is attained;
- pages under construction that may not be ready to go into the navbar (the navbar = the vertical list of links on the left of this page).
- obsolete pages that have been unlinked from the navbar
The intent is to provide a middle ground between "fragment of useful information stranded in a forum post/in author's head" and "finished page ready for being posted to the world with pride". This sort of information benefits much more from collaborative editing than finished pages that are incrementally improved after creation.
Pages under construction
- Manual
- Library Reference
- Parallel Computing
- Madagascar for non-seismologists
- Task-centric program list
- IP self-audit
- SU to m8r dictionary
- SEPlib to m8r dictionary
- Graphics development with vplot
Info from the blog/mailing lists/forums
Using Madagascar
- Hidden parameters in Madagascar programs
- How to make RSF files easy to fetch from FTP servers
- Plotting a function defined in polar coordinates
- Tools complementary to vplot2eps
- Checking parameters -- from rsf-user: "At the compile time, a special database is constructed, which contains all information about each module and its parameters. The parameter information is extracted automatically from the source code. This puts minimal requirements on the developers and prevents documentation from getting out of sync with the code. The database is stored as a Python module rsfprog.py and becomes instantly available to any Python script that uses import rsfprog. The immediate use is for self-documentation with sfdoc. The other use is to optionally check parameters for sanity when running processing flows through scons".
- Demo on reproducibile Matlab and Mathematica figures
- Unit keywords in headers, sfunits example
- How to use information from sfattr or sfget in SConstruct Flows
- Why does Plot/Result in SConstruct files sometimes have two parameters instead of three?
- How to plot 1-D irregular data with sfdots?
- How to zero a portion of a dataset based on a header mask
- scalebar in sfgrey3
- Plotting irregular data
- Timing execution of SCons targets
- The algorithm behind sfnoise
- Figure sizes and aspect ratios
- Demo of color schemes in sfgrey and sfgrey3
Configuration, install, testing, etc
- How to generate local documentation with sfdoc
- latex2wiki example
- Screenshot of Madagascar running under MS Services for Unix
- The origin of Madagascar's name
- How to perform unit testing
- How to make the VERSION line of the self-doc work correctly
- Subscribing to the RSF blog with a RSS/Atom reader
- SCons and packed RSF files
- From SCons rules to shell scripts
- How to test Madagascar programs
- SCons macros are found in book/packages
- How to set up a mirror for the Madagascar public datasets
LaTeX
Brainstorming
- Madagascar file bundles
- Byteswapping option for sfdd
- Google bombing for Madagascar; interface to industry
- Parallelization API
- Using XML in RSF headers;
- Later: Author's own repudiation of the AJAX part of the previous proposal (other parts still stand).
- Author's suggestion for an alternative to XML (from a private email to Sergey): "What does one do with XML? Read it with a program, right. XML is good if you can make no assumptions whatsoever about which language the said program was written in, and what that program is (could be a web browser of sorts, could be an Erlang application, could be a Python script, could be a C++ compiled binary). Then to deal with uncertainty you spend resources on insurance, using a verbose, completely unambiguous data description. So XML is the "canonical" approach. But what if one goes for the agile "worse is better" and notices that header file I/O costs nothing, so it can be done all in Python , regardless of what the language of the computational engine of the program. Then it does not make much sense to write from Python to XML, then read it back -- just write the header in Python! This, incidentally, is what the current syntax of RSF headers is. I realize that what I wanted XML for was delimiting in some way what was written to a header by a program and what was written by another. This way one would not get five trailing dimensions of length one because at some point the file was a five dimensional cube, while at the same time retaining meaningful dimensions of length one (i.e. the crossline for an inline extracted from a dataset). Rewriting to the header the complete description (n,o,d,unit,label) of the axes of the output for each program , all "kept together" by some syntax, would make it much easier to figure out what was actually done to the cube, and would avoid having to parse the entire file -- just read the last structure. JSON ( http://en.wikipedia.org/wiki/Json ) is designed to be an alternative to XML that is step in this direction (it is valid Javascript, and not at all far from Python), and of course, one can use Python syntax for keeping some variable values together, and do the I/O all in Python. I think this is what Lisp does and what the whole "data is code/code is data" thing is about."
- From the Sergey-Reg Beardsley email exchange on rsfuser in Jul 2006: add to each history record Madagascar, OS versions
- To have a consistent user interface, certain types of inputs and outputs should be standardized. A small beginning has been made by giving the verbosity option the same name everywhere. More meaningful issues would involve:
- having all frequencies in Hertz
- deciding whether all offsets should be half offsets or full offsets
- FFT sign conventions (- for FFT forward in time, + for FFT forward in space, like in BEI)
- Deciding whether programs should work with velocities or slownesses, and the standard axis order for a velocity model file.
- Standard axis order for inputs to programs that do similar things, i.e. switching a migration program for another in a SCons rule should be as simple as just changing the name of the program, without having to scratch one's head to determine how should the data and velocity be set up. Create Python metaprograms that add transparently to the user dimensions of length 1 to 2-D datasets when needed by programs that deal with 3-D data.
How to transform a jpg image into a RSF file
Provided that:
- your image is a grayscale one;
- samples are in byte format;
- you know the resolution of the image;
- you have ImageMagick installed on your computer;
your SConstruct file would look like this (simple jpg->rsf conversion + application of Sobel operator):
<python> from rsfproj import *
n1 = 512 n2 = 512
Flow('lena.gray','lena.jpg',
convert - ${TARGETS[0]} , stdout=0)
Flow('lena','lena.gray',
echo in=$SOURCE data_format=native_uchar esize=1 n1=%d n2=%d d1=1 d2=1 o1=0 o2=0 | transp | dd type=float % (n2, n1))
Result('lena',
grey allpos=y title="Original Image" wantaxis=n )
Flow('grad','lena','grad2')
Result('grad',
grey allpos=y title="Sobel Operator" wantaxis=n )
End () </python>
How to transform a RSF file into an image, without axes
Using sfbyte2jpg
<bash> < model.rsf sfbyte | sfbyte2jpg > model.jpg </bash> Then use another program to convert model.jpg to the desired format.
Using ImageMagick
The following commands can be used in a SConstruct to generate almost any type of bitmap output: <python> Flow('data.gray','data',
transp | # Make data in row-major order byte gainpanell=all allpos=y | # Convert data to byte representation disfil col=1 format="%02X" | # Dump data in one column in ASCII-hex sed -e "s/\s*[0-9]*\:\s*//g" | # Strip column numbers xxd -r -p # Read ASCII output and convert it to binary form )
Flow('data.png','data.gray',
convert -size %dx%d -depth 8 ${SOURCES[0]} ${TARGETS[0]} # Run ImageMagick % (n2, n1), stdin=0, stdout=0)
</python> This one uses a 3rd party tool from ImageMagick suite (which nowdays is included by default in any Linux distribution). It knows almost any existing bitmap format. Just change the extension in the last Flow() from .png to .gif or .jpg, for example. Create the output simply by running scons data.png
Artwork
ASCII art – possibly useful for error messages, text UIs with ncurses, etc. Standard font:
__ __ _ | \/ | __ _ __| | __ _ __ _ __ _ ___ ___ __ _ _ __ | |\/| |/ _` |/ _` |/ _` |/ _` |/ _` / __|/ __/ _` | '__| | | | | (_| | (_| | (_| | (_| | (_| \__ \ (_| (_| | | |_| |_|\__,_|\__,_|\__,_|\__, |\__,_|___/\___\__,_|_| |___/
Big font:
__ __ _ | \/ | | | | \ / | __ _ __| | __ _ __ _ __ _ ___ ___ __ _ _ __ | |\/| |/ _` |/ _` |/ _` |/ _` |/ _` / __|/ __/ _` | '__| | | | | (_| | (_| | (_| | (_| | (_| \__ \ (_| (_| | | |_| |_|\__,_|\__,_|\__,_|\__, |\__,_|___/\___\__,_|_| __/ | |___/