D. Some general subroutines in SEISAN in LIB

Subroutines in SEISAN are located in different files and it is not always easy to find what is available. Consequently there are some duplication. The following is a list of some of the commmon routines and their location. Very technical routines have not been listed. Some much used routines are not listed since they are found together in a file like routines for waveform handling in LIB/wave.for. There are also many routines in main programs which might be useful, they are not listed here. Most entries are subroutines but there are also a few functions. See also INF/seisan.all for a list of all subroutine files in LIB.

Table D.1: Statistics
Name Description Location
r4sort sorting tau
r8sort sorting double precision numbers hypoloc1
hpsort sorting general
qsort sorting quarrycheck
mdian calculate median general
sei rand random number generator general
lin_interp linear interpolation genenral
lsqlin linear regression lsqlin
sdv standard deviation lsqlin
maxlik maximum likelihood linear fitting maxlik
fit least squares with chi square general

Table D.2: Numerical
Name Description Location
integrate integration based on trapezoid rule auto_proc
rtr remove linear lsq trend auto_proc
differentiate differentiate auto_proc
char_fu calculate characteristic function auto_proc
normalize_signal normalize a signal auto_proc
bcd bcd byte to number bcd
bndpas butterworth filter, time domain bndpas
recfil many filter types, type domain recfil
bworth butterworth filter, freq. domain sys_resp
pazresp poles and zeros reponse sys_resp
mpolys multiply two polynomials recfil
bessel generate bessel system function recfil
delip matrix normalization delip
xy_ellipse ellipsoide error and the orientation from the north err_ellipse
ellipse_x major axis lengths and orientations from covariance matrix err_ellipse
fft fft fft
reakft ftt real numbers ?? sig_spec
real2fft two dim fft ?? sig_spec
four1 ftt ?? sig_spec
dyadic calculate dyadic of eigenvectors fmap_subs
matsum calculate matrix sum fmap_subs
remove_dc remove dc remove_dc
rotate rotate matrix remove_dc
rotate rotate a 3-vector represented in cartesian coordinates hyposub1
scmxmn extremal values of the time series sacsubf
jacobi eigenvalues and eigenvectors of a real symmetric matrix sacsubf
eigsrt sorts the eigenvalues sacsubf
eigen eigenvalues and eigenvectors of a real symmetric matrix hyposub2
GMPRD matrix multiplication focmec_exe_sub
imtql2 find eighe values and vectors focmec_exe_sub
dec_to_bin convert real number to binary ga_lib
bin_to_dec convert binary to decimal number ga_lib
minv svd of partial derivative matrix hyposub2
polos finds if point inside a polygon polos
qdis pythagorean distance calculation quarrycheck
smooth smooth data sig_spec
prepare pad and taper sig_spec
taper taper sig_spec
precoh1 azimuth and vel. from 3 comp . sig_spec
cross cross correlation sig_spec
crosscorr —————– sig_spec
cor_time —————–, time domain sig_spec
cor_freq —————–, freq —— sig_spec
correl correlation ??? sig_spec
rotate_comp signal rotation sig_spec
check_clipped check if clipped signal sig_spec
check4gap find gaps in data sig_spec
svbksbx solves the equation A * X = B svd
svdcmpx —— complex ?? svd
svdvar covariance of a matrix svd
lubksbx linear equation problem ??? svd
ludcmpx ———————– ??? svd
pythag pythagoras ??? svd

Table D.3: Character handling
Name Description Location
SEI UPC convert any lower case to upper libsei
upper convert to upper case quarrycheck
trimlen characters in string, ignore blank quarrycheck
trimbeg first not blank char in string quarrycheck
text_to_array read numbers in text string into integer array ga_lib
casefold convert to capital codecoutil
ucase lower case to upper case hyposub1
lcase upper case to lower case hyposub4
SEI LEFT left justify a text string libsei
SEI CLEN lenght of text string libsei
r_index find character in text, starting search from last character libsei
swap4 swap 4 byte data swap
swap4_one swap 4 byte data, one value swap
swap2 swap 2 byte data swap
swap2_one swap 2 byte data, one value swap
text_sort sort text strings text_sort
check_whole check string for spaces isf_isc

Table D.4: Input output see also rea and wave
Name Description Location
SEI CMD PRO get text from input libsei
SEI CMD SET get argument from command line, possibely execute it libsei
SEI GET FILE open file in current or alt. directory libsei
SEI GET VALUES get values from input string libsei
SEI INTEGER get integer from a text string libsei
SEI OPEN open file on next availabel unit libsei
get_seisan_def read SEISAN.DEF libsei
file_ready check if file is opened already and wait until it is closed libsei

Table D.5: SEISAN specific
Name Description Location
iasp91_filename set name of iasp91 files general
topdir get top dir name general
get_env_op get operator id general
get_operator ———– interactively eev_sub
get_env_event get event name general
put_env_event put event name general
put_env_base put base name in memory general
put_env_seistop put seisan top ——– general
put_env_op put operator id ——- general
get_env_base get base name from —- general
get_env_cal get alt. CAL dir —— general
get_def_base get def. base ——— general
get_env_string get any string ——– general
put_env_string put any string ——– general
put_seisan_message put a seisan message seis_mes
get_seisan_message get a seisan message seis_mes
get_agency get agency from ——- general
send_plot send plot to laser general
dir_char directory separation char general
uncompress check if file is compressed and uncompress general
sort_event sort an s-file acor. to distance general
get_agency_hyp return agency in station file general
get_baz calculate station back azimuth for stations in waveform header get_baz
component convert from 2 to 4 char component componen
findchan find channel number corresponding to a station and component findchan
filename get filename seisan way filename
init_networ start UDP communication network
send_udp_message send UDP message network
get_udp_message receive UDP message network
close_network close UDP communication network
ms_sleep sleep function networtk
number_of_events count number of events in a CAT file general

Table D.6: S-files see rea for general routines
Name Description Location
check_s check s-file for erros check_s
read_s_file_e open and read s-file, close, for eev check_s
write_s_file_e write s-file, ——- check_s
auto_tr get trace file names from s-file auto_tr
auto_filename ——————————— autofil
findevin finds an event in list of events findevin
get_fstart find start of s-file name and check name findevin
merge_f merge two s-files merge_f
nortype find if compact or normal d-file nortype
rea_xxx different routines rea
sfilname make s-file name sfilname
stat_loc find coordinates of a given station stat_loc
stat_loc_many ——— of many stations stat_loc

Table D.7: Timing rotines
Name Description Location
abstim converts a data base timestring to abs time abstim
etoh epoch time to human time sacsubf
htoe calendar date to epoch time since January 1, 1970 sacsubf
dtoepo convert julian date to epoch time sacsubf
julian calculates julian day codecoutil
mnthdy YEAR and DOY, return MONTH and DAY sacsubf
systime get system time systime
datetimex get date and time systime
TIMSEC time in year to double precision seconds after 1.1.0000 timerout
SECTIM seconds after 1.1.0000 to date and time timerout
DTE day-of-year to date (month,day) timerout
TIMDIF time-difference in seconds of two two input dates and time timerout
TIMADD Adds seconds to date, and returns the new date timerout
MONTH_DAY number of days in a month from month and year timerout
leap_year find leap year timerout

Table D.8: General seismological
Name Description Location
autoamp peak to peak amplitde and period autoamp
find_coda find signal duration auto_proc
auto_coda ——————– auto_coda
compute_brune calcualte brune spectrum auto_proc
freq_event_type determine if local or distance ev. auto_proc
m0dcf decompose moment tensor into various representations fmap_subs
pcnts percentages of double-couple, CLVD & iso in seismic source fmap_subs
m0find find scalar moment fmap_subs
ptfind find P & T vectors fmap_subs
mtsrce set up moment tensor components from input moment tensor representation fmap_subs
fpsol calculate strike, dip & slip of fault solutions from the P & T vectors fmap_subs
plaz calculate plunge & azimuth of eigenvectors in degrees fmap_subs
mdcmp calculate components of an arbitrary moment tensor fmap_subs
AN2DSR dip, strike and rake - A&R convention from A and N focmec_exe_sub
AN2MOM moment tensor element from A and N ————–
ANTPIN other representations of fault planes
DSRIN ————————————- ————–
PTTPIN —————– from T and P ————–
GDMOT ground displacement of incident P
grndmtn vertical and radial grond disp. amp. ————–
mb_att mb attenuation curves veith et all m_att
mbb_att ——————- gutenberg-richter —–
plot_foc plotting focal mechanism plot_foc
fps_gap find az gap in polarity data plot_foc
fps_gap_all find az gap in polarity and amplitude data plot_foc
p_t_gap calculate difference in P and T axis between two fault plane solutions eev_sub

Table D.9: Coordinate handling
Name Description Location
fold geographic to geocentric coordinates hyposub1
unfold geocentric to geographic coordiantes hyposub1
cvrtop convert from rectangular to polar coordinates hyposub1
delaz calculate the distance in km and azimuths hyposub1
distaz angular distance, azimuth and back-azimuth between two points hyposub1
cart geographical location to geocentric cartesian coordinates hyposub1
geog geocentric cartesian coordinates to a geographical location hyposub1
latlon Find a point on a sphere at a given distance and azimuth from an. point hyposub1
azibazi calculate distance, azimuth and back azimuth azibazi

Table D.10: Plotting, see seiplot for most general routines
Name Description Location
fcircl Plot a filled circle plot_foc
draw_circle draw a circle plot_foc
draw_triangle draw a triangle plot_foc
xy_plot general xy-plot xy_plot
xy_plot_line make a line in xy_plot xy_plot

Table D.11: Waveform handling, see wave for most general routines
Name Description Location
seisinc read a seisan format file seisinc
shead make seisan waveform channel header shead
sheads ——main and channel heders sheads

Table D.12: Routines for logging
Name Description Location
get_log_file_name This subroutine creates the name of the log file from the name of the sfile seisan_logging
create_log_file This subroutine creates a log file (is it does not exist), name=sfilename.LOG seisan_logging
show_log_file This subroutine sends the content of the logfile to the screen seisan_logging
sfile_to_log_file This subroutine adds the sfile to the end of the log file seisan_logging
move_log_file This subroutine add actions to the log file seisan_logging
get_log_time This subroutine returns a string used to timestamp the log seisan_logging
message_to_log_file This subroutine added a message in the logfile seisan_logging
pick_to_log_file This subroutine adds the character used to pick phases etc. seisan_logging
string_to_log_file This subroutine add a string to the logfile seisan_logging