-------------------------------------------------------------------- Some general subroutines in SEISAN in LIB -------------------------------------------------------------------- Updating Dec 20 2015 jh: first version 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 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 seisan.all for a list of all subroutine files in LIB. -------------------------------------------------------------------- Statistics -------------------------------------------------------------------- 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 -------------------------------------------------------------------- Numerical -------------------------------------------------------------------- integrate integration based on trapezoid auto_proc rule 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 ctpoly CONVERT ROOT DESCRIPTION TO recfil POLYNOMIAL DESCRIPTION bessel generate bessel system function recfil delip matrix normalization delip xy_ellipse ellipsoide error and the err_ellipse orientation from the north ellipse_x major axis lengths and orienta- err_ellipse tions from covariance matrix 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 hyposub1 cartesian coordinates 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 hyposub2 real symmetric matrix 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 numerical recipies svdcmpx ------ complex ?? svd svdvar covariance of a matrix svd lubksbx linear equation problem ??? svd ludcmpx ----------------------- ??? svd pythag pythagoras ??? svd -------------------------------------------------------------------- Character handling -------------------------------------------------------------------- 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 ga_lib integer array 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 libsei search from last character 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 --------------------------------------------------------------------- Input output see also rea and wave --------------------------------------------------------------------- SEI CMD PRO get text from input libsei SEI CMD SET get argument from command line, libsei possibely execute it SEI GET FILE open file in current or alt. libsei directory 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 libsei and wait until it is closed --------------------------------------------------------------------- SEISAN specific --------------------------------------------------------------------- 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 general uncompress 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 get_baz stations in waveform header component convert from 2 to 4 char component componen findchan find channel number corresponding findchan to a station and component filename get filename seisan way filename -------------------------------------------------------------------- S-files see rea for general routines -------------------------------------------------------------------- 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 findevin name 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 statloc find coordinates of a given station statloc statloc_many --------- of many stations statloc --------------------------------------------------------------------- Timing use rotines in timerout, go to year 0 --------------------------------------------------------------------- abstim converts a data base timestring to abstim abs time 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 timerout seconds after 1.1.0000 SECTIM seconds after 1.1.0000 to date and timerout time DTE day-of-year to date (month,day) timerout TIMDIF time-difference in seconds of two timerout two input dates and time TIMADD Adds seconds to date, and returns timerout the new date MONTH_DAY number of days in a month from month timerout and year leap_year find leap year timerout -------------------------------------------------------------------- General seismological -------------------------------------------------------------------- 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 mdcf decompose moment tensor into various fmap_subs representations pcnts percentages of double-couple, CLVD & fmap_subs iso in seismic source m0find find scalar moment fmap_subs ptfind find P & T vectors fmap_subs mtsrce set up moment tensor components from fmap_subs input moment tensor representation fpsol calculate strike, dip & slip of fault fmap_subs solutions from the P & T vectors plaz calculate plunge & azimuth of fmap_subs eigenvectors in degrees mdcmp calculate components of an arbitrary fmap_subs moment tensor AN2DSR dip, strike and rake - A&R convention focmec_exe_sub from A and N AN2MOM moment tensor element from A and N -------------- ANTPIN other representations of fault planes DSRIN ------------------------------------- -------------- PTTPIN ----------------- form 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 ------------------------------------------------------------------- Coordinate handling ------------------------------------------------------------------- fold geographic to geocentric coordinates hyposub1 unfold geocentric to geographic coordiantes hyposub1 cvrtop convert from rectangular to polar hyposub1 coordinates delaz calculate the distance in km and hyposub1 azimuths distaz angular distance, azimuth and back- hyposub1 azimuth between two points cart geographical location to geocentric hyposub1 cartesian coordinates geog geocentric cartesian coordinates to a hyposub1 geographical location latlon Find a point on a sphere at a given hyposub1 distance and azimuth from an. point azibazi calculate distance, azimuth and back azibazi azimuth -------------------------------------------------------------------- Plotting, see seiplot for most general routines -------------------------------------------------------------------- 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 -------------------------------------------------------------------- Waveform handling, see wave for most general routines -------------------------------------------------------------------- seisinc read a seisan format file seisinc shead make seisan waveform channel header shead sheads ------main and channel heders sheads