next up previous contents
Next: Tape reading and writing Up: Answers to Frequently Asked Previous: Installation questions   Contents

Data format questions

In this section, we address questions about converting data that are in various formats into SU format.

Question 5   What is the data format that SU programs expect?

Answer 5   The SU data format is based on, (but is not exactly the same as) the SEG-Y format. The SU format consists of data traces each of which has a header. The SU trace header is identical to SEG-Y trace header. Both the header and the trace data are written in the native binary format of your machine. You will need to use segyread to convert SEGY data to SU data.

Caution: The optional fields in the SEG-Y trace header are used for different purposes at different sites. SU itself makes use of certain of these fields. Thus, you may need to use segyclean--see the answer to Question 7. SU format does not have the binary and ebcdic tape headers that are part of the SEG-Y format.

After installing the package, you can get more information on the SEG-Y/SU header by typing:

% sukeyword -o
This lists the include file segy.h that defines the SU trace header.

Question 6   Is there any easy way of adding necessary SEG-Y information to our own modeled data to prepare our data for processing using the SU package?

Answer 6   It depends on the details of how your data was written to the file:
  1. If you have a `datafile' that is in the form of binary floating point numbers of the type that would be created by a C program, then use suaddhead to put SU (SEG-Y) trace headers on the data. Example:
    % suaddhead < datafile  ns=N_SAMP >
    Here, N_SAMP is the (integer) number of samples per trace in the data.

  2. If your data are Fortran-style floats, then you would use:
    % suaddhead < datafile ftn=1 ns=NS >
    See also, Question 10.

  3. If your data are ASCII, then use:
    % a2b n1=N1 < data.ascii | suaddhead ns=NS >
    Here N1 is the number of floats per line in the file data.ascii.

  4. If you have some other data type, then you may use:
    % recast < data.other in=IN out=float | suaddhead ns=NS >
    where IN is the type (int, double, char, etc...)

For further information, consult the self-docs of the programs suaddhead, a2b, and recast.

Question 7   I used segyread to read a SEG-Y tape. Everything seems to work fine, but when I plot my data with suximage, the window is black. What did I do wrong?

Answer 7   When you read an SEG-Y tape, you need to pipe the data through segyclean to zero the optional SEG-Y trace header field. If the SU programs see nonzero values in certain parts of the optional field, they try to display the data as ``nonseismic data,'' using those values to set the plot parameters.

Another possibility is that there are a few data values that are so large that they are overwhelming the 256 gray scale levels in the graphics. The way to get around this problem is to set perc=99 in the graphics program. For example:

% suximage < sudata  perc=99 &
This will clip data values with size in the top 1 percentile of the total data.

Question 8   I am trying to plot data with the pswigb (or pswigp, or xwigb, or ...) program. I know that I have data with n1=NSAMP and n2=NTRACES, but when I plot, I find that I have to set n1=NSAMP+60 for the plot to look even remotely correct. Why is this?

Answer 8   It is likely that you are trying to plot with the wrong tool. The input data format of the programs, pswigb, pswigp, pscontour, pscube, psmovie, xwigb, xgraph, and xmovie, expect data to consist of simple floating point numbers. If your data are SU data (SEG-Y) traces, then there is an additional header at the beginning of each trace, which, on most computer architectures, is the same number (240) of bytes as the storage for 60 floats.

To plot these data, use respectively: supswigb, supswigp, supscontour, supscube, supsmovie, suxwigb, suxgraph, or suxmovie.

Also, it is not necessary to specify the dimensions of the data for these latter programs. The su-versions of the codes determine the necessary information from the appropriate header values. (In fact, that is all they do--the actual graphics is handled by the version without the su prefix.)

Question 9   I want to check the size of a file to see if it has the right number of values, but I am not sure how to take the header into account. How is this done?

Answer 9   If the file consists of simple floating point numbers, then the size in bytes equals the size of a float times the number of samples (SIZE = 4 * N_SAMP). The SU data (SEG-Y traces) also have a header (240 bytes per trace) giving the total number of bytes as:
(240 + 4 N_SAMP ) N_TRACES.
The byte count computed in this way is the number that the UNIX command ls -l shows.

Caveats: The above calculations assume that you have the conventional architecture and that the header definition in segy.h has not been altered. Watch out as machines with 64 bit word size become common!

Question 10   I have some data in Fortran form and tried to convert it to SU data via the following:
% suaddhead < data.fortran ns=N_SAMP ftn=1 >
but this did not work properly. I am sure that my fortran data are in unformatted binary floats. What should I do?

Answer 10   There are different ways of interpreting the term ``unformatted'' with regard to fortran data. Try:
% ftnstrip < data.fortran | suaddhead ns=N_SAMP >

The program ftnstrip can often succeed in converting your fortran data into C-like binary data, even when the ftn=1 option in suaddhead fails. (Note: the program ftnunstrip may be used to take C-style binary data and convert it to Fortran form.)

Question 11   I just successfully installed the CWP/SU package, but when I try to run the demo scripts, I get many error messages describing programs that the shell script cannot find. How do I fix this?

Answer 11   You need to put CWPROOT/bin (where CWPROOT is /your/root/path that contains the CWP/SU source code, include files, libraries, and executables) in your shell PATH. This is done in your .cshrc file if you run under csh or tcsh. In Bourne shell (sh), Born Again shell (bash), or Korn shell (ksh) the PATH variable is in your .profile file. You also need to type
% rehash
if you are running C-shell /bin/csh or TC-shell /bin/tcsh as your working shell environment, if you have not relogged since you compiled the codes.

Question 12   How do I transfer data between SU and a commercial package, such as Promax.

Answer 12   The short answer is that you make a SEGY tape on disk file. To do convert a file called, say, "" to a segy file do the following:

% segyhdrs <
% segywrite tape=data.segy <

Now use Promax to read data.segy. This file is a "Promax tape-on-disk file in IBM Real format." Choose Promax menus accordingly.

For other commercial packages, use the appropriate commands to read a SEGY tape on disk file.

To go from the commercial package to SU follow the reverse steps. Create a file that is a SEGY tape image and then use

% segyread tape=data.segy | segyclean >

Question 13   I would like to strip the trace headers off of some SU data, perform an operation of some type on the bare traces and put the headers back on without losing any of the header information. How do I do this?

Answer 13   Do the following:

% sustrip < head=headers > data.binary

(Do whatever was desired to data.binary to make data1.binary)

% supaste < data1.binary head=headers >

Question 14   I have made some data on an IBM RS6000 and have transferred it to my Linux-based PC system. The data looks ok on the RS6000, but when I try to work with it on the PC, none of the SU programs seem to work. What is wrong?

Answer 14   The problem you have encountered is that there are two IEEE binary formats called respectively `big endian` and `little endian` or, alternately `high byte` and `low byte`. These terms refer to the order of the bytes that represent the data. IBM RS6000, Silicon Graphics, NeXT (black hardware), SUN, HP, PowerPC, any Motorola chip-based platforms are `big endian` machines, whereas, Intel-based PCs and Dec and Dec Alpha products are `little endian` platforms.

Two programs are supplied in the CWP/SU package for swapping the bytes for data transfer. These are swapbytes and suswapbytes.

The program swapbytes is designed to permit the user to swap the bytes on binary data that are all one type of data (floats, doubles, shorts, unsigned shorts, longs, unsigned longs, and ints).

For data that are in the SU format, the program suswapbytes is provided.

Furthermore, within the programs segyread and segywrite there are ``swap='' flags that permit the user to specify whether the platform they are working on are ``big endian'' or ``little endian'' platforms.

In older releases of SU there were problems with the bitwise operations that would be encountered in the wiggle-trace drawing routines. However, these problems have been fixed via the ENDIANFLAG that appears in Makefile.config.

Question 15   How do I convert data that are in the SEG-2 format to SEGY?

Answer 15   In $CWPROOT/src/Third_Party/seg2segy there are two programs that have been made available to us by the University of Pau in France, for this purpose. These should be easy to install on any system where SU has been installed.

Once you have converted data.seg2 to data.segy, you may read it into the SU format via:

% segyread tape=data.segy >

next up previous contents
Next: Tape reading and writing Up: Answers to Frequently Asked Previous: Installation questions   Contents
John Stockwell 2007-04-10