next up previous contents
Next: Setting Geometry - Converting Up: Setting, Editing, and Viewing Previous: SUGETHW - Get the   Contents

SUSHW - Set the Header Words in SU Data

The program sushw (pronounced, SU set header word) is an all purpose utility for setting the value of seismic trace headers. This program permits the user to set one or more trace header words. A common use of sushw is to just set a particular field to one value. For example, sometimes data don't have the ``dt'' field set. Let's say that the data are sampled at 2 ms, By using sukeyword, we see that dt is in microseconds

% sukeyword dt

...skipping
        unsigned short ns;      /* number of samples in this trace */

        unsigned short dt;      /* sample interval; in micro-seconds */
...
This means that the following command sequence will set all dt values to 2000 microseconds
% sushw < data.su key=dt a=2000 > data.out.su
A more tangible example can be seen by piping suplane data into sushw
% suplane | sushw key=dt a=2000 | sugethw key=dt | more
161 wenzel> suplane | sushw key=dt a=2000 | sugethw key=dt | more

    dt=2000     

    dt=2000     

    dt=2000     

    dt=2000     

    dt=2000     
...

From the selfdoc for sushw we see that the following optional parameters are defined

 Optional parameters ():						
 key=cdp,...			header key word(s) to set 		
 a=0,...			value(s) on first trace			
 b=0,...			increment(s) within group		
 c=0,...			group increment(s)	 		
 d=0,...			trace number shift(s)			
 j=ULONG_MAX,ULONG_MAX,...	number of elements in group
These extra options permit more complicated operations to be performed. This is necessary, because often there is a relationship between header fields and the position of the trace within the dataset. The value of the header field is computed by the following formula
 	i = itr + d							
 	val(key) = a + b * (i % j) + c * (i / j)			
 where itr is the trace number (first trace has itr=0, NOT 1)
where percent % indicates the ``modulo'' function and / is division.

For example if we want to set the sx field of the first 5 traces to 6400, the second 5 traces to 6300, decrementing by -100 for each 5 trace groups

% sushw < data.su key=sx a=6400 c=-100 j=5  > data.new.su
Again, piping in suplane data into sushw
% suplane | sushw  key=sx a=6400 c=-100 j=5 | sugethw key=sx | more

    sx=6400     

    sx=6400     

    sx=6400     

    sx=6400     

    sx=6400     

    sx=6300     

    sx=6300     

    sx=6300     

    sx=6300     

    sx=6300     

    sx=6200     

    sx=6200     
...

As another example, if we wanted set the ``offset'' fields of each group of 5 traces to 200,400,...,6400

%  sushw  < data.su key=offset a=200 b=200 j=5 > data.out.su
As before, piping suplane data into sushw yields the following
% suplane | sushw  key=offset a=200 b=200 j=5 | sugethw key=offset | more

offset=200      

offset=400      

offset=600      

offset=800      

offset=1000     

offset=200      

offset=400      

offset=600      

offset=800      

offset=1000     

offset=200      

...

We can perform all 3 operations with one call to sushw, via:

% sushw < data.su key=dt,sx,offset a=2000,6400,200 b=0,0,200 c=0,-100,0 j=0,5,5 > newdata.su
Or with suplane data piped in
% suplane | sushw key=dt,sx,offset a=2000,6400,200 b=0,0,200 c=0,-100,0 j=0,5,5 |
 sugethw key=dt,sx,offset | more

    dt=2000         sx=6400     offset=200      

    dt=2000         sx=6400     offset=400      

    dt=2000         sx=6400     offset=600      

    dt=2000         sx=6400     offset=800      

    dt=2000         sx=6400     offset=1000     

    dt=2000         sx=6300     offset=200      

    dt=2000         sx=6300     offset=400      

    dt=2000         sx=6300     offset=600      

    dt=2000         sx=6300     offset=800      

    dt=2000         sx=6300     offset=1000     

    dt=2000         sx=6200     offset=200      

    dt=2000         sx=6200     offset=400      
...
As you can see, it is natural to use pipes and redirects to control job flow, but this becomes ungainly on a single command line. Later in this document, we will see how to construct complicated processing sequences in the controlled environment of shell scripts.


next up previous contents
Next: Setting Geometry - Converting Up: Setting, Editing, and Viewing Previous: SUGETHW - Get the   Contents
John Stockwell 2007-04-10