SYNOPSIS

PERL PROGRAM NAME:

AUTHOR: Juan Lorenzo (Perl module only)

DATE:

DESCRIPTION:

Version:

USE

NOTES

Examples

SYNOPSIS

SEISMIC UNIX NOTES SUMEDIAN - MEDIAN filter about a user-defined polygonal curve with

	   the distance along the curve specified by key header word 	



 sumedian <stdin >stdout xshift= tshift= [optional parameters]		



 Required parameters:							

 xshift=               array of position values as specified by	

                       the `key' parameter				

 tshift=               array of corresponding time values (sec)	

  ... or input via files:						

 nshift=               number of x,t values defining median times	

 xfile=                file containing position values as specified by	

                       the `key' parameter				

 tfile=                file containing corresponding time values (sec)	



 Optional parameters:							

 key=tracl             Key header word specifying trace number 	

                       =offset  use trace offset instead		



 mix=.6,1,1,1,.6       array of weights for mix (weighted moving average)

 median=0              =0  for mix					

                       =1  for median filter				

 nmed=5                odd no. of traces to median filter		

 sign=-1               =-1  for upward shift				

                       =+1  for downward shift				

 subtract=1            =1  subtract filtered data from input		

                       =0  don't subtract				

 verbose=0             =1  echoes information				



 tmpdir= 	 if non-empty, use the value as a directory path	

		 prefix for storing temporary files; else if the	

	         the CWP_TMPDIR environment variable is set use		

	         its value for the path; else use tmpfile()		



 Notes: 								

 ------								

 Median filtering is a process for suppressing a particular moveout on 

 seismic sections. Its advantage over traditional dip filtering is that

 events with arbitrary moveout may be suppressed. Median filtering is	

 commonly used in up/down wavefield separation of VSP data.		



 The process generally consists of 3 steps:				

 1. A copy of the data panel is shifted such that the polygon in x,t	

    specifying moveout is flattened to horizontal. The x,t pairs are 	

    specified either by the vector xshift,tshift or by the values in	

    the datafiles xfile,tfile.	For fractional shift, the shifted data	

    is interpolated.							

 2. Then a mix (weighted moving average) is performed over the shifted	

    panel to emphasize events with the specified moveout and suppress	

    events with other moveouts.					

 3. The panel is then shifted back (and interpolated) to its original	

    moveout, and subtracted from the original data. Thus all events	

    with the user-specified moveout are removed.			



 For VSP data the following modifications are provided:		

 1. The moveout polygon in x,t is usually the first break times for	

    each trace. The parameter sign allows for downward shift in order	

    align upgoing events.						

 2. Alternative to a mix, a median filter can be applied by setting	

    the parameter median=1 and nmed= to the number of traces filtered.	

 3. By setting subtract=0 the filtered panel is only shifted back but	

    not subtracted from the original data.				



 The values of tshift are linearly interpolated for traces falling	

 between given xshift values. The tshift interpolant is extrapolated	

 to the left by the smallest time sample on the trace and to the right	

 by the last value given in the tshift array. 				



 The files tfile and xfile are files of binary (C-style) floats.	



 The number of values defined by mix=val1,val2,... determines the	

 number of traces to be averaged, the values determine the weights.	



 Caveat:								

 The median filter may perform poorly on the edges of a section.	

 Choosing larger beginning and ending mix values may help, but may	

 also introduce additional artifacts.					



 Examples:								







 Credits:



 CWP: John Stockwell, based in part on sumute, sureduce, sumix

 CENPET: Werner M. Heigl - fixed various errors, added VSP functionality



 U of Durham, UK: Richard Hobbs - fixed the program so it applies the

                                   median filter

 ideas for improvement:

	a versatile median filter needs to do:

	shift traces by fractional amounts -> needs sinc interpolation

	positive and negative shifts similar to SUSTATIC

	make subtraction of filtered events a user choice

	provide a median stack as well as a weighted average stack

 Trace header fields accessed: ns, dt, delrt, key=keyword

User's notes (Juan Lorenzo) untested

CHANGES and their DATES

Import packages

instantiation of packages

Encapsulated hash of private variables

sub Step

collects switches and assembles bash instructions by adding the program name

sub note

collects switches and assembles bash instructions by adding the program name

sub clear

sub key

sub median

sub mix

sub nmed

sub nshift

sub sign

sub subtract

sub tfile

sub tmpdir

sub tshift

sub verbose

sub xfile

sub xshift

sub get_max_index

max index = number of input variables -1