antelope 4.10 reference guide - ooici confluence site · 2008-10-29 · antelope 4.10 2 antelope...

234
Antelope 4.10 Reference Guide April 2008 Kent Lindquist Lindquist Consulting Daniel Quinlan BRTT, Inc. BRTT, Inc 2045 Broadway, Suite 400 Boulder, CO 80302 www.brtt.com

Upload: others

Post on 06-Aug-2020

8 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10Reference Guide

April 2008

Kent LindquistLindquist Consulting

Daniel QuinlanBRTT, Inc.

BRTT, Inc2045 Broadway, Suite 400

Boulder, CO 80302www.brtt.com

Page 2: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c
Page 3: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

UserCommands

Page 4: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Contents

Antelope Real Time System ............................ 1

Processing Database Data............................ 25

Seismic Source Location ............................... 27

Foreign Data Formats.................................... 28

Waveforms..................................................... 34

Datascope Database Tools............................ 43

Miscellaneous Utilities ................................... 50

Page 5: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Antelope Real Time System

Administration and Controlrtm [-icon iconname] [-title title] [-procwin] [-netwin]

monitor real-time tasks and resource usage

rtexec [options] [comment]real time system executive; runs all other real time processes-c clear logs-d debug mode-f don't ask about killing previous rtexec-k kill running rtexec-n show what processes would be run-s save old logs in new subdirectory-t run `tail -f logs/rtexec` -v more verbose

-w why with -k, file why explains shutdown

rtinit [-q] [-v] [db]initialize directory for rtexec/rtm by creating direc-tories and copying pf files

rtrun [-nv] command-linerun command-line using rtexec environment (like an rtexec cron job)

cronrun [-nv] command linerun command line immediately, reproducing cron environment

ecrontab [-r] [file]gui interface for editing crontab files; -r option for rtexec style crontab

rtkill [options] [procname]stop, start, or restart a process running under rtexec-l list process names from the rtexec.pf Run array-r restart the specified process-s start the specified process-q query whether the specified process name is set

to run-v verbose

rtdemo [-t] [name]setup to run an Antelope realtime demo; -t sup-presses gui

Antelope Real Time System 1

Page 6: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

truncate_log [options] log [log..]eliminate old lines in log files-c also remove lines without time tags

-d n trim lines before n days ago

-f force truncation sooner than 8 days

-h h specify max records in rtsys tables

-m m trim files so maximum size is m kbytes

-r suppress saving removed lines in new file

-s n only trim files larger than n kbytes

-v be more verbose

rtorbcmd [-d] [-p pf] target commandclient program for sending commands to remote orb

rtorbcmd [-d] [-n npkts] [-p pf] [-S state] orbserver program for reading and executing com-mands at remote orb

Reportsdbevents [options] dbname [start [end]]

display map of seismic events and waveforms (between times start and end)-max_age max_agelimit age of displayed events

-show_detectionsshow stations with detections only

-title window_titlewindow title

-pf pfname parameter file name

rtreport [options] [directory]report some statistics on data collection-d start start of reporting period

-g only show gaps

-m email,.. list of email recipients

-N re only report on network codes matching re

-n days number of days report covers

-p pf use specified pf instead of rtreports.pf

-s subset report only on stations satisfying subset

-w wfdb alternate waveform database

-v more detail about gaps-Y include full date in event report -z only z channels

2 Antelope Real Time System

Page 7: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

rtsys [options] [directory]summarize system operation and log reports-C eliminate summary of cronjobs

-d time start of reporting period

-m email,.. list of email recipients

-N re only report on network codes matching re

-n n last n lines from log files (default = 10)

-P pf use specified pf instead of rtreports.pf

-p mail only when problem is detected

-w db specify alternate waveform db

rtoutage [options] db t0 t1show data gaps for database db from time t0 to t1-A format output as an autodrm outage report-c list reporting stations-C list reporting channels

-d gapdb save gap info into database gapdb

-n netcode only process station from netcode

-N summarize by network

-P maxpts maximum # waveform points to load at once

-p print percentage of data recovered

-s subset only show gaps for sta/chan subset

-S show gaps as seconds only-t only show totals-z select only vertical channels

rtmail [-s subject] [-a filename] [-b bcc] [-c cc] [-f from] [-r replyto] [-dv] recipients

send mail with attachments

stanote [-{f|F} file] [-r range] [-t time] [database] [sta [note]]

simple method for adding note about station, to appear in gap report in rtreport

rtsnapshot [options]collect some pertinent info from real time system into tar file for problem report-c include core files

-d #rows max rows from database tables

-f filename specify output filename

-l #loglines max lines from log files

-p re collect 50 packets matching re

-v more verbose

syssnapshot [-c] [-f filename] [-l #lines] [-v] [dir]create tar snapshot of system configuration

Antelope Real Time System 3

Page 8: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

rtincident [options] [output_file]collect some system related information into report; rtexec runs this program and sends the results to [email protected] corefile specify corefile (on which dbx is run)

-e command specify command line

-l log specify log file for program

-M msg specify message to include in report

-m addr send report as email to addr

-n just show what would be run

-p program specify program which dumped core

-v verbose-x append corefile to email

inspect_snapshot snapshotgui to help read output from rtincident or other snapshots

IP network monitoringpingmeister

display network connectivity

tcpmonitor [options] hostmonitor tcp connections for stability and throughput-B sz specify packet size

-d db save statistics in database db

-f send bursts only from server -2 send bursts only to server

-N #pkts set #packets in burst

-m run in monitor (server) mode

-n #loops # of bursts to send

-p port alternate port

-P #ping # of pings between bursts

-r lrsz set size of client receive buffer

-R rrsz set size of server receive buffer

-s lssz set size of client send buffer

-S rssz set size of server send buffer

-t timeout set timeout (in seconds) for socket reads

-v more verbose

-W sec/ping set number of seconds between "pings"

4 Antelope Real Time System

Page 9: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Orbserver and Utilitiesorbserver [options] pf

orb ring buffer server, using parameter file pf-k don't reset ring buffer

-p port use port instead of 6510

-P prefix alternate names for orb files

-r reset ring buffer

-s size ringsize, eg 150M

-v[v] verbose/doubly verbose

orbserver64 [options] pfsame as orbserver, but allows much larger ring buff-ers (32 bit Solaris only)

diskserver [-p pf] [-v] dir[:port]emulate read-only orbserver on port using directory dir of special forb files

orb2disk [options] orb directory [start-time [end]]copies packets from orb into into forb(5) segment files inside directory-b bi save state every bury interval seconds

-m re1 read only packets which match re1

-r re2 don't read packets matching re2

-n n stop after n packets

-p period approximate time length of files

-s size size limit for directory-v more verbose

orbproxy [options] orbhostportorbserver proxy-i local_ipaddrbind to one of several local ip addresses

-p local_portnolocal proxy port number

-v more verbose

orbstat [options] orb [secs]show statistics for orbserver orb every secs seconds-c show client statistics-s show source statistics-i interactive mode

-d [all|nets|stations|channels|loc_codes|types]show wave-form info

-m re show only packets or clients matching re

-r re don't show packets or clients matching re

-n avg boxcar average over avg queries

-v more verbose

orbclients [-t] orbshow organized view of orbserver/diskserver clients

Antelope Real Time System 5

Page 10: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

pforbstat [options] orb [secs]Create parameter files of orb status-a analyze status for orb2orb connections-c show client statistics-s show source statistics

-m re show only packets or clients matching re

-r re don't show packets or clients matching re

-f specify output filename

-o orb specify output orb-n name specify srcname for packets on output orb-v more verbose

orblook { start orbname interval | restart orbname interval | stop orbname }

Start/Stop orblookupd daemon for monitoring orb status

Data Loggers: import to orbadsend2orb orb port

read earthworm packets from udp port and copy to orbserver orb

guralp2orb [options] orbnamecopy data from Guralp SCREAM server to orb-d calibration_database-p pf-l file_for_logpackets-v verbose-V extremely verbose

guralplocate log1 log2 ...estimate station location from guralp log files

ida2orb [-u] [-r sec] orb nrts selectioncopy selected data from IDA nrts to orbserver-u change station and channel to uppercase-r sec reject future packets

liss2orb [options] liss orbcopy data from LISS server liss to orbserver orb-d database lookup calib, calper and segtype in db

-m m only forward packets matching m

-r remap net,sta,chan,and loc using local foreign-keys db

-s pktsize specify block size explicitly

-v

6 Antelope Real Time System

Page 11: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

rddas [options] port orbcopy data from RefTek DAS port to orbserver orb-R send RESET_DAS command before reading -l create logfile representing data

-p pf specify parameter file

-s B,P,D,S specify serial port baud rate B, parity P, data bits D, stop bits S

-u write uncompressed packets to orb-v verbose

q3302orb [options] targetname [orbtag1 orbname1 [orbtag2 orbname2 [...]]]

communicate with Q330 Quanterra digitizer, bring-ing data from Q330 into orb, and sending and moni-toring commands from orb to Q330-calib_db dbnamemetadata database

-pf pf parameter file

-S statefile-noipresolv do not try to resolve ip addresses-v

q330pocd [-i ip] [-p port] [-noipresolv] targetname orbreceive POC messages and save to orb-i ip bind to one of several local ip addresses

-p port specify alternative to port 2254

-noipresolv don't look up hostnames

q330_location [-m mail] [-p pf] [-t mmax] [-v] orb dbalert if Q330 locations in status packets differ more than mmax from database location

q330coms [-n net] [-p pf] [-v] orb dbcompare Q330 status packets with Q330comm data-base table

q330proxy [-v[v[v]]] [-help] [template]internet to SLIP proxy utility for Q330 data loggers

q330snoop [-noeth] [-noip] [-snoop] prefix_exprused with snoop to parse and print raw UDP Q330 packets

q330gpslocate log1 log2 ...estimate station location from Q330 log file

qtbsetaddr ipaddr [timeout]set Quanterra baler ip-address

Antelope Real Time System 7

Page 12: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

qt2orb [options] -dataorb orbd -cmdorb orbc -calib_db calib_db [-dataorb2 orbd2]

communicate between Quanterra digitizer and orb-pf pf specify parameter file

-sta net_sta1 [net_sta2 [...]] override names from parameter file

-msglevel {0|1}-v verbose

cs2orb [-v] [-seedout] [-t pf] [-dbcalib db] station orboutcopy data from comserv to an orbserver orb

k22orb [options] target orbdata [orbcmd]transfer data from Kinemetrics Altus digitizer to an orb-pf pf specify alternate parameter file

-db db specify database for calib information

-dlclock dlname-v be more verbose

-state file save state in filename

-start time only get events after time

rtp2orb [-v] configuration_filecollect data from RefTek data server (RTPD) and writes to orb

ryo2orb [-v] [-V] [-p pfname] [-m subset] rtd_ipaddress:port orbserver

collect GPS data in RYO format and write to orb

b3s2orb [options]read B3S2 data to orb-c p1 command port (default = "/dev/ttya")

-i p2 data port (default = "/dev/ttyb" )

-o orb default = localhost

-p pf default = pkt.pf

-s -v more verbose

slink2orb [options] SeedLink orbSeedLink to orb module-dc database db to get calib, calper and segtype

-dm database db to map SEED to CSS names

-nd delay network reconnect attempt delay

-nt timeout network timeout

-k interval keepalive interval

-pf pf-S statefile-o dumpfile-r remap net/sta/chan-v[v[v]] more verbose

8 Antelope Real Time System

Page 13: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Datalogger Commandingdlcmd [options] orbcmd targets dltypes dlnames cmd

[params]execute command cmd on generic data loggers-waittime waittimewait time for multiple targets-timeout timeouttimeout waiting for response

-noblock don't wait for response-noreply don't generate response packets-prm delete parameter files

-replytarget replytarget-delayhangup delayhangupdelay digitizer hangup

k2cmd [options] orb target datalogger cmdexecute command cmd on remote Kinemetrics Altus digitizer-timeout timeouttimeout waiting for response

-noblock don't wait for response-noreply don't generate response packets-prm delete parameter files

-delayhangup delayhangupdelay digitizer hangup

q330util {pollsn targetip | register targetip,sn,lport | get-config targetip,sn,lport,config | control tar-getip,sn,{eeprom|reboot|resync|gpson|gpsoff|gpscs}}

perform some utility functions for Q330-port port udp port

-port_base port_basebase port for Q330

-auth auth Q330 authorization code

-sequence seq starting sequence number for commands

-timeout timeouttimeout for udp response

qtcmd [options] cmdorb net_sta cmd [params]execute commands on remote Quanterra digitizer-target target-replytarget replytarget-timeout timeout-noreply

automrc [options] orbname dc_nameautomatically send mass recentering command to RefTek DAS-m srcmatch-p pf-s sleep-t tperiod-V verbatim-v max_lta

Antelope Real Time System 9

Page 14: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dlautomrc [options] cmdorb orb [target]issue mass recenter commands to remote data log-gers-a vlt out of range voltage value

-d dl data logger type

-f force mass recenter (with -s, not with -a)

-m add email notification list

-n no mrc, only report what would be done

-p pf parameter file

-s dl_sta1,dl_sta2,... comma separated list of data loggers

-t n number of retries

-v verbose

-x dl_sta1,dl_sta2,...comma separated list of rejected data loggers

Real Time Status to orbcpu2orb [-i t] [-vv] orb

put cpu and system utilization packets on orb every t seconds

df2orb [-i t] [-p pf] [-vv] orbput filesystem status information packets on orb every t seconds

heartbeat [-i interval] [-N net_sta] [-v] orbcreates periodic condensed status packets with sys-tem info

ps2orb [options] orbsave process information from ps(1) to orb at inter-val t seconds-a m report on all processes every m'th iteration

-i t report every t seconds

-n mx quit after mx iterations

-t n report on top n processes every iteration

-r {mem|cpu} sort by mem or cpu

-u user restrict to specified user

-vv print reports on stderr

tail2orb [options] orb [file ...]monitor multiple files, sending any added lines as packets to orbserver orb-g n check for new files matching glob patterns

every n'th iteration

-i t check files every t seconds

-m m specify maximum number of files monitored

-N net_sta specify alternate srcname

-p pf specify alternate parameter file

-S state specify alternate state file

-vv print lines on stderr also

10 Antelope Real Time System

Page 15: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

orblog [-f file] [-s subcode] orb [log info]write single log packet to orb; packet contents are remainder of command line, stdin, or -f file

orb2logs [-cn] [-m match] [-r reject] [-S state] [-w pattern] orb logdb [start [stop|period]]

save logs packets (from tail2orb or from data logger acquisition) back into corresponding plain files divided by epoch day boundaries (and by data log-ger).

orbtail [-f] [-m match] [-r reject] [-number] orb [start [end|period]]

read and print log packets from orb

orb2ntp [-d delay] [-f freq] [-m match] [-n navg] [-o old] [-r reject] [-u unit] [-Mv] orb

use orb packet times as (very rough) ntp clock

rtlogs orbdisplay log messages from orbserver orb

Other Orb Writerspf2orb [-s sta] [-p subcode] pfile orb

put parameter file onto an orb as packet; use -s and -p to specify parts of packet srcname

dbt2orb [-v] [-s subset_expr] [-l naptime] db table orbread rows from database and post them to orb

dborigin2orb [options] db orbcopy new origins from db.origin into orb for auto-matic association of external catalogs with real time events-after time specify start earlier than now()

-delay delay wait delay seconds before appending to orb-nowait quit after processing existing db.origin

-number n quit after processing n events

-target_orb2dbt targetspecify alternate target orb2dbt

-v more verbose output

Antelope Real Time System 11

Page 16: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbreplay [options] view orb [t0 [{t1|T}]]replay database view to orb from t0 to t1 (or t0+T)-b max pause if client is more than max seconds

behind-d send station portion of database-e send event portion of database

-F db db to map net/sta/chan/loc

-n n quit after n packets

-p pktsuffix specify output packet type

-r rate specify data rate as ratio to real time

-s expr subset input according to expression

-T timeout with -w, give up after some timeout

-t timestep specify packet time size

-u don't append /@ suffix-v more verbose

-w client specify read client to watch (to avoid overruns)

-x eliminate trailer packet used for orb2db flush

Real Time processing: Orb reader/writersorb2orb [options] in out [start [period|end]]

copy data from one orb to another-c suffix convert packets to suffix format

-C rate throttle to specified output rate: kbytes/sec or (with p suffix) pkts/sec.

-d print hex dump of each packet -f for file input, do not adjust time tags, and out-

put packets as quickly as possible

-i secs save state file every secs seconds

-l loop repeatedly over input forb(5) file

-m re1 read only packets which match re1

-n n stop after n packets

-p pf alternate parameter file

-R r when saving to file, use forb(5) format r

-r re2 don't read packets matching re2

-S filename save state in filename

-s p start after pktid #p

-U unstuff each packet and print

-u n discard duplicates in latest n packets

-v more verbose

-X xlat translate srcnames according to morph table

-x require acknowledgment for each packet sent

orbxchange [-d db] pfrun multiple orb2orb connections controlled by pf; use db for fallback orb sources

12 Antelope Real Time System

Page 17: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

orbxfer2 [-N net] [-p pf] [-w dir] [-v] [file ...] orbwrite files into orb; with -w, watch directory dir and send files which appear there into the orb and remove them from dir

orbxfer2 [-p pf] [-S state] [-v] orbreceive incoming files, save into directory specified in pf

orb2genc [options] orbin orboutconvert input packets into unmultiplexed GENC for-mat-t translation_pf-start {pktid|time|OLDEST}-select select_expr-reject reject_expr-S statefile-dbcalib dbcalib-v

orbaddcalib [options] dbcalib orbin orboutadd calib, calper and segtype to ORB waveform packets-onlynull only fill in packets with NULL calib values-dbcheck check database for each waveform packet-v more verbose

-t translation_pfmorph SEED names

-select select_exprselect expression for incoming packets

-relect reject_exprreject expression for incoming packets

-start {pktid|time|OLDEST}initial ORB read pointer position

-S statefile statefile

orbstaseg [options] csssta orbdetect orbwfin orbwfoutsingle station waveform segmenter-start {pktid|time|OLDEST}-select_wf expr-twin_pre twin_pre-twin_post twin_post-twin_write_timeout

-twin_maxon twin_maxon-S statefile-repackage twin subcode-detev -v

Antelope Real Time System 13

Page 18: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

orbdetect [options] orbname dbnamemulti-frequency STA/LTA detector-nopending suppress pending detection packets-onlypicks only output onset time packets

-out orb-out_detev orb output orb for detev packets

-pf pf-reject re-select re-tstart t0-twin minutes-v

orbdetev2detection [options] dbfkeys orbin orboutconvert detev database rows to detection rows-delay delay_seconds-start {pktid|time|OLDEST}-S statefile-v

orbtrigger [options] orbnamereal time network trigger algorithm-v

-tstart t0-target_orbassoc torbassoc-pf pf-out orbout

orbassoc [options] orbin orbout ttgridf1 [ttgridf2 [...]]spatial grid search based real time associator/locator-auth author origin author field

-delay delay time delay for processing latent stations

-pf pf-select expr-start {pktid|time|OLDEST}-target_orb2dbt torb2dbt-trigger_start_only -v

ttgrid [-pf pf] [-time {timestr|all}] dbcompute travel time grid file for use by orbassoc and dbgrassoc

displayttgrid [-shownames] filename [gridname]display travel-time grids on map

14 Antelope Real Time System

Page 19: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

ttgrid_show [-adDgnNPsSv] ttgridfileshow members of a ttgrid file-a show everything-d show depths-D show distances-g show grids-n show nodes-N print in a nicer form-P show P arrival times-s show stations-S show S arrival times

orbevproc [options] orbwf orbev dbnamegeneralized real-time event processor-start {pktid|time|OLDEST|NEWEST}-select expr input select expression

-number numbernumber of events to process

-nowait

-state file save state in file

-p pf-tmpdbdir dir directory for temp databases

-dbwf dbwf archive waveform database

orbmag [options] orbwf orbdb dbnamereal time magnitude computation-start {pktid|time|OLDEST|NEWEST}-number number-nowait

-state file save state in file

-p pf-auth_expr auth_expr-target_orbmag torbmag-make_magtables -use_mean -use_if_not_associated -use_if_not_defining

Antelope Real Time System 15

Page 20: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

orbampmag [options] orbwf orbdb dbnamereal time computation of mb, ML or Ms magnitudes-auth_expr auth only use packets with matching author

-make_magtablesmake netmag and stamag packets-nowait quit when no packets left to process

-number n limit on packets to process

-pf pf-start {pktid|time}-state state-target_orbmag orb1 -next_target_orbmag orb2-use_mean use mean, not median statistics-use_p2p use peak to peak, not maximum value -use_if_not_associated

use all stations-use_if_not_defining

use all picks-v

orbwfrms [options] dbname orbin [orbout]compute running rms estimates from waveform packets-start {pktid|time|OLDEST} -select sexpr-reject rexpr -end endtime -pf pf-S state-v

orbpftrigger [options] orb [cmdstring]parameter file trigger of program execution-select expr-start {pktid|time}-number number-nowait

orbptrigger [options] orb command ...orb packet trigger of program execution-select packet-start {pktid|time}-number number-state file-background

16 Antelope Real Time System

Page 21: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

orbwfmeas [options] orbwf orbdb dbnamemake waveform measurements from an orb-select_wf expr-start {pktid|time|OLDEST|NEWEST}-number number-nowait

-state filename save state in filename

-p pf-net net-dbsift_expr dbsift_expr

qedd [options] dbnamedaemon to get realtime QED data from finger site-l

-ipfinger ipfinger-sleep seconds-timeout seconds-author author

orb2sms [-v] [-m match] [-r reject] [-M prog] orb {cell#|email}

reformat packets from orb as sms messages

sms2orb [-dv] queue orbread incoming sms email from queue directory and write packets to orb

Orb Real Time Displaydlmon [options] orb [cmdorb]

monitor/control generic digitizers-model model data logger model

-state {Icons|Multi|Single}initial display state

-select_status expr_status-select_log expr_log-subset subs_exprinitial expression for subsetting stations

-sort name initial sort name

-pf pffile parameter file

-dump period-dump_image file

old_dlmon [options] orb [-cmd cmdorb]legacy version of monitor/control generic digitizers-model model data logger model

-start_status {OLDEST|pktid|time}-start_log {OLDEST|pktid|time}-select_status expr_status-select_log expr_log-dump period imagefile-pf pffile parameter file

Antelope Real Time System 17

Page 22: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dlmontxt [options] orbname [orbname2 [...]]generate terse status summary for data loggers-m re1 read only packets which match re1

-r re2 don't read packets matching re2

-d dl_re match data logger names

-M email list of email addresses, or @filename for addresses in filename

-s subject subject line for email report

orbmonrtd [options] orbreal time waveform trace display-dump dt gif dump image to gif every dt seconds

-filter filter-height pixels single trace window height in pixels

-hmax hmax maximum height of main window in pixels

-ntinc nt number of traces between time scales

-pf pf use alternate parameter file

-redraw start with oldest orb packet

-reject re reject channels matching re

-select re select channels matching re

-source net_sta_chan select display channels on command line

-title title title for orbmonrtd window

-tshift_time t0 specify t0 for right edge of window

use t0="-" to use first packet time

-twin minutes window size in minutes

-unmap remove controls from display (for vnc in browser)

-width pixels trace width in pixels

-wmax wmax maximum width of main window in pixels

-reverse_labels put station labels on right

orbdisp [options] orbserver [start [range|end]]inspect waveform data on orb server-c re save channel matching regular expression re

-m re select packets matching regular expression re

-r re reject packets matching regular expression re

-l latency expected max latency for packets

-n show network on display

-p period specify minimum packet period

-w t make time window t seconds

18 Antelope Real Time System

Page 23: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Saving Orb Data in Databaseorb2db [options] orb db [start [end|period]]

copy waveform data from orbserver orb into data-base db (starting at time start through end or for stated period)-a log log of waveform files opened and closed

-c re save channel matching regular expression re

-m re select packets matching regular expression re

-r re reject packets matching regular expression re

-p pf specify parameter file

-S file save state in file

-s datatype specify output waveform type (overriding pf)

-T tol tolerance for packet time tag deviation

-t timetags create file of time tags from input packets

-v more verbose-vv show every packet read.

-w wfname specify pattern for waveform file names

orb2db_flush [-nv] [-m match] [-r reject] orbcause orb2db to write out all waveform data for selected packets

cdorb2db [options] orb db [start [end|period]]copy gappy/out of order (CD1) waveform data from orbserver orb into integer waveform files of database db (starting at time start through end or for stated period)-c re save channel matching regular expression re

-m re select packets matching regular expression re

-r re reject packets matching regular expression re

-p pf specify parameter file

-S file save state in file

-t timetags create file of time tags from input packets

-v more verbose-vv show every packet read.

-w wfname specify pattern for waveform file names

db2msd [-t age] [-1nv] dbconvert older waveform files to miniseed in place, used with cd2orb. with -1, use steim 1 compression

Antelope Real Time System 19

Page 24: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

orb2dbt [options] orb dbout [orbout]read database packets from an orb and write to data-base-select expr-reject expr-start {pktid|time|OLDEST}-number number-target_orbmag torbmag-timeout timeout-overwrite

-state statefile-pf pf-orbdbout orbdbout-v

orb2db_msg [-q] [-s sleep] [-t timeout] db [pause|con-tinue|status]

signal orb2db and orb2dbt processes to pause for database db cleanup oro realtime database crunch

par2db [options] orbname dbname [start [window]]create database with GPS site coordinates and DC/DAS status parameters from orb-c Extract DC status parameters-g Extract GPS site coordinates

-i time_interval-m re select packets matching regular expression re

-v more verbose

orblatency [options] orb databaseaccumulate latency statistics from network-m re select packets matching regular expression re

-n n quit after n iterations

-r re reject packets matching regular expression re

-p period period over which latencies are averaged

-v more verbose

20 Antelope Real Time System

Page 25: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

orbmsd2days [options] orbsave miniseed (only) packets from orb into day vol-umes-c nscl specify particular net_sta_chan_loc desired

-d db create wfdisc table in db

-S state save orb position in state file

-U limited duplication suppression-I inclusive time screening

-m re1 select packets matching regular expression re1

-r re2 reject packets matching regular expression re2

-s st save data only when block start time >= st

-e et save data only when block start time < et

-w wf pattern for the output miniseed files

-v Be more verbose.

Orb Alarmsacalarm [-d] [-m srcmatch ] orbin mail_add [stime]

send mail when AC power fails in DC packets

battalarm [-d] [-m srcmatch ] orbin mail_addsend mail when battery power drops in DC packets

pktmon [-n npkts] [-p pf] [-S state] [-0dv] orbread packets, send alarms for specified conditions-0 start at first packet in orb-S state specify alternate directory to save history files

-d print debugging information.

-n npkts stop after npkts packets

-p pf specify alternate parameter file

-v print each packet read.

Miscellaneousresetnetblazer hostname line timeout

reset Telebit Netblazer terminal server

orb2pf [options] orb [file]copy parameter file objects from an orb to file-select expr-start {pktid|time}-number number-nowait

mail_parser [options] [file [file...]]direct incoming email to customized perl handlers-v -m

-f logfile-l library_path-p pf

Antelope Real Time System 21

Page 26: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Archiving Datartbackup [-v] [-V] [-n]

[-p pf] [-r reject_stas] [-s sta_match] [-t start_time ] [-e end_time] rt_db backup waveform and database data from rt_db to independent disk directory

rtbackup2tape [-v] [-m who] [-p pf] db driveoriginal rtbackup (renamed)- backup waveform and database data from db to (tape) drive

get_archive [options] db dbout drive [t0 [t1]]restore waveforms (between t0 and t1) to dbout using db.wftar from rtbackup tape on drive-c re select channels with regular expression

-s re select stations with regular expression

-v more verbosely

rtdbclean [-n] [-v] [-V] [-w] [-p pf] orb rt_dbremove old waveform data and associated database records

get_wftar -v dbmaster tape_driveextracts wftar table from an ARTS archive tar tape

online_backup [options] [directories]backup certain files to an online directory-d n remove log files after n days

-d dir specify an alternate base directory

-m send mail rather than writing to stdout-n don't actually run backup, but show what

would happen

-p pf specify parameter file

-t t backup files modified more recently than time t

-v more verbose-V show generated perl procedure which selects

files to be saved

-y n backup files modified in last n days

Orb Diagnostic Toolsorbcapture [options] orb db file

save packets from orbserver orb to file when new row in database (satisfies condition)-b m start capture m packets before trigger packet

-a n capture n packets after trigger packet

-c condition only new rows satisfying condition trigger cap-ture

-R {a|x|f} specify output format ascii, hexadecimal, or header only

-v verbose

22 Antelope Real Time System

Page 27: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

forbserver [options] filenamefile orbserver emulator-[a|b|f|x] specify format in output forb(5) file-c adjust time tags to the current time.-s meter out packets at real time rate-U run elog_debugger() to start a debugger on the

process.-v more verbose-w overwrite existing file instead of appending

pkttypes [-c]print summary of packet types for installed packet library

orbstash [-m match] [-o out] [-r reject] [-v] in [srcname]get and print stash packets from an orbserver in

ipvalidate [-p pf] [-v] [ip-addresses]test if particular ip address is accepted or rejected by valid_ip_address list in pf

CD1 Alpha Format Protocolorb2cd1s [-pf pf] [-select expr] [-reject expr] [-state state-

file] [-start {pktid|time}] [-v] orb1 orb2repackage and reformat data packets from orb1 into CTBT/IMS standard CD-1 format subframe data packets on orb2

cd1s2cd1 [-n net] [-m match] [-r reject] [-v] [-S state] orb1 orb2

copy CD1S subframe packets from orb1 and put CD1 packets on orb2

cd1tran [-a after] [-S base] [-m match] [-r reject] [-s name] [-v] orb alphahost

read CD1 packets from orb and send to alphahost using alpha protocol

cd2orb [options] [orb]alpha protocol server to save incoming CD1 packets from multiple hosts onto orb-c sec max sec between connect mgr request and con-

nection

-d db database for calib, calper, segtype

-i ip explicit ip address for mgr to provide incoming requests

-P cmport[,cd1port]request port, connection port

-p pf alternate parameter file

-S dir specify state directory

-v[v] more verbosity

cdremap [-p pf] [-t time] databasetest/reproduce channel mapping done by cd2orb

Antelope Real Time System 23

Page 28: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

cd1replay [-s sta] [-t dt] [-v] file [file2 ...] receiverreplay cd1 data saved by cd2orb (using code sta)

24 Antelope Real Time System

Page 29: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Processing Database Datadbdetect [options] dbin dbout

run multifrequency STA/LTA detector on dbin, writ-ing detections into dbout.-arrivals write arrival records also-noaddchk don't do database checks-onlypicks write only detection pick rows to db

-pf pf pf specifies channels and filters

-tstart t0 start at t0

-twin T for T minutes

-v

dbgrassoc [options] dbin dbout ttgridf1 [ttgridf2 [...]]spatial grid search based associator/locator: reads detections from dbin, generating new origin, assoc and arrival records in dbout-auth auth auth field for db, default is dbgrassoc

-i flush stdout and reread pf-noassoc no smart association

-pf pf-v

dbassoc [options] dbin dbout dbcat timeres_P timeres_Sassociate origins from dbcat with arrivals in dbin, write origin, assoc and optionally predicted arrivals into dbout; timeres_P and timeres_S specify allowable travel time residuals-arid arid1 ... | -orid orid1 ... | -evid evid1 ...

select events by arid, orid or evid-ignoreiphase do not match indicated phase with predicted-v -writeout write text to STDOUT after processing each

origin-pred save predicted arrivals-prefor set prefor

-rules r any combination of P,S,PS,PS+,first,arids=all,best,all

dbassoc_arrival [-p delta_p] [-s delta_s] dbout dbinsearch for arrivals from dbout which match origins in dbin, copying matching origins into dbout and cre-ating assoc records

assoc_rayleigh [-v] dbout dbinassociate rayleigh wave picks from dbout to origins from dbin, copying matching origins into dbout and creating assoc records

Processing Database Data 25

Page 30: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbgme [-vfd] [-p pf] -r recipe [-r recipe...] [-o orid] dbname

2-D ground-motion estimation from hypocenters and waveform measurements

dbevproc [options] dbin dboutgeneralized database-driven event processor-p pf-tmpdbdir dir directory for temp databases

-v

dbmag db orid author netcompute mb magnitude for origin orid (or "all") in db, saving result in netmag and origin with specified author

dbml [options] db [orid]database Richter magnitude computation-v

-p pf-use_if_not_associated -use_if_not_defining -make_magtables -use_mean

dbmapevents db {sta | orid | lat:lon} range [-c] [auth1 sym1 hue1 lit1 sat1 ...]

make map of events from database db centered on sta, origin orid, or lat:lon within radius of range degrees; -c starts interactive mode, ^C kills window

dbrecenteqs [-p pf] [-v] [-h] [-u] [-e evid] [-c sourcedb] dbname

maintain web-site of earthquake maps for for data-base dbname

26 Processing Database Data

Page 31: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Seismic Source Locationdbloc2 [-r] [-p pf] database

interactive hypocenter location

dbloc_snapshot [-f output-file] [-v] databasecreates snapshot of dbloc2 directory for problem resolution

dbgenloc [-p pf] dbin dboutgenloc program used by dbloc2

dblocsat2 dbin [dbout]locsat program used by dbloc2

dblocgrad dbin [dbout]locate local earthquakes with 1D linear gradient model

tabcalc travel time calculator for 1-D, continuous velocity models

hypotab companion program to tabcalc travel time calculator

pltt phases depth d0 dd nd tmin tmax vred [table]plot travel times from tau-p travel time table

prtt phases ndp dp0 ddp ndel del0 ddel [table]print travel times from tau-p travel time table

tp2ls phases header [table]make locsat style travel time table file from tau-p travel time table

dbproject_covariance [-v] [-c conf] dbnameupdate origerr table with new smajax, sminax, sdepth, stime, strike, and conf values, based on covariance matrix from origerr table

relocate dbin dbout [-pf pf] [-useold] [-sift expression]relocate all events in database using genloc

orbgenloc orb [-S statefile] [-pf pf]orb interface to genloc single event location code

sgnloc inpf outpfcommand line interface to single event location code

taup_convert phase [-d0 x -ddelta x -z0 x -dz x -ndelta n -nz n]

uses taup library to produce travel time tables that can be used by genloc location programs

Seismic Source Location 27

Page 32: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Foreign Data Formats

Exporting Data from Datascope Databaseautodrm [options] [files]

Antelope IDC/GSE2.1 AutoDRM Server-d debug: print output to stderr rather than send-

ing mail

-D dir run in directory dir

-p pf use parameter file pf

-v more verbose

dbresp2autodrm viewconvert response information from view to autodrm format

rtbulletin [-Av] [-s subset] aview [t0 [t1|period]]create a bulletin from input view aview (-A causes standard autodrm output)

db2ah [options] dbin dboutconvert css waveform files into ah format-sc sta_chan-ts start time-te end time-w wfdir-gap { none | zero | interp }-counts -h help-v version

db2sac [options] dbin dboutconvert css waveform files into sac format-i intel order output

-sc sta/chan select sta/chan pairs with dbpick style pseudo-glob

-ts t0 starting at time t0

-te t1 ending at time t1

-w wfdir write waveform files into wfdir (default "sac")

-gap {none|zero|interp}handle gaps according to rule (default zero)

-counts keep output waveform in counts (don't apply calib)

db2segy db outfile [-pf pf] [-v]convert waveforms from input database db to segy disk image

Importing Data into a Datascope Databaseaah2db [-vV] ahfile [ahfile...] dbname

convert non-XDR AH files to database

28 Foreign Data Formats

Page 33: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

ah2db ah1 [ah2 .. ] dboutcreate CSS database dbout from AH format wave-form files ah1, ah2, ...

autodrm2db [-vV] reply1 [reply2 ..] dboutread autoDRM replies reply1, reply2, ... and copy into output database dbout

gnis2db gnis_file dbname [State]convert GNIS feature-name files to database

grdinfo2db [-n name] [-t type] gridfile dbnameadd GMT grid-file information to database

pick2db [-cvp] [-r reference_db[:reference_db...]] pickfile [pickfile...] dbname

convert hypoellipse pickfile(s) to CSS3.0 database-c attempt to fake channel names-v verbose-p put component code into channel field

-r reference_db[:reference_db...]] add references to other databases in descriptor

file

reb2db filename [filename ...] dbconvert Reviewed Event Bulletins of GSE2.0, IMS1.0, or IMS1.0:SHORT format to CSS3.0 data-base db

ref2db [options] input dbname [start-time [end-time]]convert data in REFTEK format to css3.0-d datatype specify waveform datatype

-e create files based on RefTek event start and end time

-l create logfile containing instrument status information

-m das copy only packets with serial number das

-p pf specify parameter file to match das to station name

-s size default segmentation of waveforms

-n net specify miniseed network

-v print srcname and time of every packet read-w do not save waveform data; used to extract log

file or get gap info

sac2db [-v] sac1 [sac2 ... ] dboutcreate wfdisc, site, sitechan (and possibly origin, event, arrival and assoc records) in output database dbout from SAC files sac1, sac2 ...

Foreign Data Formats 29

Page 34: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

scec2db [options] dbnameretrieval and conversion of SCEC bulletin-v verbose-d retrieve one day-w retrieve one week-m retrieve one month-f file-s start_time-e end_time-c {catread|scecdc|hypo71|hypo2000}

segy2css [-event] [-ftbl] fname ..convert PASSCAL SEGY format data to CSS for-mat

Xphase2db db [-phase name]convert an input Xphase pick file to css3.0 arrivals

Examining Foreign Filessachd [sac1 ...]

print header information from SAC files sac1, ...

Reading seed/miniseedsdd [-sv] sd

dump blockettes (summary only if -s) from SEED volume sd

msdd [-dovx] miniseed ...dump miniseed volume; -o shows opaque blockettes

msdd -i miniseedinteractive mode for inspecting miniseed

chkmsd [-v] dbchecks all miniseed blocks to see db and miniseed agree

seeddump [-lsize sz] [-types list] [-v[v]] [-sta] seeddump certain blockettes from seed according to tlist: (V=Volume, A=Abbreviation, S=Station, T=Time span, D|R|Q=Data)

30 Foreign Data Formats

Page 35: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

seed2db [options] seed [db]read SEED volume seed, produce validation com-mentary and optionally database tables-lsize size specify logical record size-vvv be increasingly verbose

-respdir rdir save responses into rdir

-stagedir sdir create stage table; save stage responses into sdir

-chansift pf select specific sta/chan pairs through pf

-tstart t0 start at time t0

-tend t1 stop at time t1

-nodata create no wfdisc table-nodataless only create wfdisc-nofirerrors shut up about fir errors

qtunbale [options] url [time [endtime|period]]unload data from Quanterra baler-a just show time range available

-c chan only channel chan (??-???)

-d db make wfdisc with miniseed2db

-f w size of time window for requests

-i info where to save info files from baler

-o orb pass directly to orb using miniseed2orb

-q wait quietly for baler to wake up-Q don't ping baler-r raw output, no miniseed2days or miniseed2orb

-S dir subdirectory for miniseed day files

-t to timeout for ping response from baler

-u show all URLs used-v more verbose

-w wfname specify pattern for miniseed files

qtunbale2 [options] url [time [endtime|period]]like qtunbale, but using wget instead of perl http

miniseed2db [-T tolerance] [-v] miniseed|dir [msd2|dir2 ...] db

create wfdisc rows in db for miniseed volume(s), or miniseed volumes under directories

Foreign Data Formats 31

Page 36: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

miniseed2orb [options] file ... orbput data blocks from input miniseed files into pack-ets on orb-s start start-time

-e endtime end time

-I inclulsive time screening

-m re keep if net_sta_chan_loc matches re

-r re reject if net_sta_chan_loc matches re

-d db look up correct sta/chan in calibration table

-p pf alternate parameter file-u don't add /@ suffix to srcnames-v more verbose

miniseed2days [options] miniseed ...separate input miniseed into separate channel day volumes-C file chuck blocks with bad time or compress errors

into file

-d db create output db by running miniseed2db on output files

-D retain duplicate seed blocks in output-I inclulsive time screening

-S dir alternate output directory

-e end ignore data after endtime

-k keep input data blocks with poor timing quality

-m match only keep net_sta_chan_loc matching this re

-r reject reject net_sta_chan_loc matching this re

-s start ignore data before start

-U eliminate consecutive duplicate data blocks on input

-u eliminate all duplicate data blocks from input-v more verbose

-w wfname alternate pattern for output file names

Writing/Patching SEED/miniseeddb2sd [-cv] [-n net] [-l lbl] db sd

create SEED volume sd from database db (db must contain affiliation, network, sensor, site, stage, cali-bration and wfdisc tables)

mk_dataless_seed [-n re] [-o dataless_seed] [-p pf] [-s re] [-vk] db

create dataless seed volume from db, optionally using only stations which match -n net and/or -s sta regular expression

mk_dmc_seed [-nvV] [-l secs] [-r days] [-M maxmem] [-m email] [-s stime] [-t tape] [-d dir] rt_db

build IRIS DMC files on tape or disk

32 Foreign Data Formats

Page 37: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

db2miniseed [options] db [output]create miniseed from input database-r size specify record size (default 4096)

-l {1|2} specify steim compression level (default 2)

-n net specify default network

-v verbose

log2miniseed [-a] [-c chan] [-l loc] [-n net] [-s sta] log ...read input log files and create miniseed

fix_miniseed [-iv] [-d db] [-{p|P} pf] miniseed|dir ...change network, station, channel and/or location codes in specified miniseed volumes or all miniseed found under specified directories

patch_miniseed [-nvv] miniseed ...look for and fix bad reverse integration constants, unless -n

Foreign Data Formats 33

Page 38: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Waveforms

Waveform manipulationtrexcerpt [options] dbin dbout [start {duration|end}]

extract waveform segments from database-A autodrm style (ascii) waveform files-a append to existing waveform files if present

-c expr sta/chan/instrument subset

-d write complete database with site, sensor, sitechan, instrument

-D dumb mode requires only wfdisc table-e include correct subset of event, origin, origerr,

arrival, and assoc in output database-E expert mode does not check for problems in

site, sensor, sitechan or instrument tables-g eliminate 'marked' data gaps

-j expr origin/site subset

-m {time|convert|event|arrival|explicit}-o datatype specify output waveform datatype (default =

sd)-p in arrival mode, save waveforms only for pick

channel

-s expr evid/orid/arid subset

-v more verbose-vv show details of view evaluations

-w pattern specify naming convention for output wave-forms

specify mode (default = time)

-W db specify database from which waveforms come

trtally [-d output] [-ekv] [-r start stop] db1 [{+|-|!|&|^|a} [db2]]

compute intersections and other operations on two sets of waveform time ranges

trmapnames [-anv] db [net fsta fchan {loc|aux}]

trmapnames -u [-anv] db [sta [chan]]map foreign net/sta or sta/chan/loc codes into local sta and chan codes, or vice versa

34 Waveforms

Page 39: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

event_archive [options] dbin dboutcopy event information (arrivals, origins, and wave-forms) from continuous database dbin to archive dbout-I idserver specify idserver

-l n wait n days before copying an event

-M db db containing site, sitechan: used only on ini-tial archive to dbout

-m addr send errors as email to addr

-s t1 process events after time t1

-e t2 process events before time t2

-n ignore check for reviewed events

-p pf use parameter file pf

-t tdb use temporary database tdb

-w wff output waveform format

-v be verbose-V be extremely verbose

trsample [options] database[.table] [time [end|period]]print a few samples from waveforms in database-c apply calib to samples-e read data from each row in table-I interactive mode-[i|t|T] show integer, epoch time, or readable time

index for each sample

-n npts print npts samples

-o write samples one to a line

-s expr subset input according to expr

Waveforms 35

Page 40: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

trsignal [options] databasecreate wfdisc records with test signal data-{A|D|V} segtype

-a amplitude-b timebase generating function base time

-c channel specify chan code

-d datatype specify output datatype (default = "as")

-f f0 generating function frequency in hz

-g calib specify calib

-k keep output as floating point, not integers

-n nsec length of output waveform

-p phase generating function phase

-r samprate sample rate

-s station sta code

-t time start time for output

-T type sin, cos, sqr, tri, saw, dlt, ran, stp, pkt, dif

-v be more verbose

-w pattern specify naming convention for output wave-forms

-y yaw constant signal drift

dbdec [options] dbin dbout chan_maps dec_stage1 [dec_stage2 ...]

decimate waveform data-sift expr-c calper-wfdir wfdir-f format

alter_timestamps [-demnquv] [-p pf] db[.table]

alter_timestamps [-nquv] [-f foreign] [-p pf] miniseedchange waveform and arrival timestamps for clock problems-d dump corrections table-e expert mode: ignore checks on corrections

table

-f foreign specify foreignkeys database

-m correct the miniseed along with the wfdisc table

-n just show what would happen

-p pf use an alternate parameter file pf

-q interactively examine time corrections by entering a station and time

-u undo previously applied corrections-v be more verbose

36 Waveforms

Page 41: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbtc [-p pf] [-t time] [-v] gdb:gnet:gsta:gch bdb:bnet:bsta:bch

create time correction table by comparing good source gdb:... with bad source bdb:...

correctdt [-m srcmatch] [-t stime] [-v] bdbusing correction table from dbtc, correct times in wfdisc and arrival tables, and in miniseed

Analysisdbap [options] -dbin dbin -recipe recipe1 [recipe2 [...]]

database array processing program-script script_file-dbout dbout-v verbose-ts tstart_time-te end_time-arid arid-arid_t0 arid_t0-arid_tw arid_tw-chan chan-filter filter-samprate samprate-azimuth azimuth-slow slow-name1 value1 [-name2 value2] [...]

Waveforms 37

Page 42: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbcalibrate [options] dbin [sequence_id [sequence_id_cmp[,chan_cmp]]

sensor and cross comparison calibration analysis program-out dbout output database name

-prm delete temporary parameter file after exe-cution

-p pfname use an alternate parameter file pfname

-calper calper calibration period

-resp_dir resp_dirdirectory for output response files

-resp_dfile resp_dfilefilename for output response spec-trum

-resp_dfilee resp_dfileefilename for output response error spectrum

-resp_dfilen reap_dfilenfilename for output nominal response spectrum

-dcalwf_sifter exprused to subset rows from input dlcalwf table

-sngen sngen fix sensor generator gain to this value

-v be more verbose-outrecno print output sensorcal table row numbers-error_at_calper compute errors relative to spectrum ampli-

tude at calper period

-template name use name processing template from parameter file

-dbcmp dbcmp take comparison waveforms from dbcmp database

-noise tstart_noisenoise start time

-type {ratio|power|coherence}computation type

dbwfmeas [options] {detection|arrival|time staexpr chanexpr tstart twin} db [dbout]

make waveform measurements from database-p pf-net net-v -outrecno -exitonerror

dbnoise dbnamemake power spectral density plots of noise

displayspec dbnamedisplay power spectral density results

trstack dbin dbout subset imode [-azmin=xx] [-azmax=xx] [-delmin=xx] [-delmax=xx] [pf-file]

stack selected traces from dbin

38 Waveforms

Page 43: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Waveform displaydbplotcov database sta:chan tstart tend [-h[scale]] [-

wftar]make plot and listing of waveform coverage from database

dbrsec [options] dbmake record section plot of waveforms-sc sta:chan-orid orid:chan-top top-bot bot-tstart tstart-twin twin-filter filter-sift sift-clip {on|off}-vred vred-gain gain-amp amp

dbspgram dbname sta chan tstart twin [options]compute time varying spectragram-fmin fmin min freq in hz

-fmax fmax max freq in hz

-units {D|V|A} displacement, velocity, acceleration

-thalf thalf 1/2 width of gaussian time window

-noic no instrument correction

-ampdecades ampdecades# decades in amplitude to plot

-ps psfile

Waveforms 39

Page 44: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbpick [options] dbnamepick arrivals and review waveforms from dbname (see .dbpickrc for filter specs)-sc sta:chan specify station/channel "glob"; eg "*:*Z"

-ts tstart specify start time

-te tend specify end time

-tw twin specify window time width

-noexist -nostarttalk suppress startup usage chatter-nostdin suppress command line input

-winfile wfile-appname name specify tksend application name

-gaps {segment|zero|interp|none}-comout comfile-geom WxH+X+Y-switchbuttons switch middle and right mouse buttons-showdetections show detections-showfm show first motions-iconic start up trace window as icon

-bg color trace background color

-fg color trace foreground color

-bga color arrival background color

-fga color arrival foreground color

-bgsa color selected arrival background color

-fgsa color selected arrival foreground color

-fgdt color detection foreground color

-fgtm color timemark foreground color

Waveforms 40

Page 45: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

tkdbpick [options] {dbname|-}pick arrivals and review waveforms from dbname-pf pf-sc sta:chan-ts_sift tstart_sift-te_sift tend_sift -ts tstart_display -tw twin_display -gaps {segment|zero|interp|none} -maxchannels maximum_channels_in_display -appname tkdbpick_application_name -comout comfile -geom WxH+X+Y -stam {css|seed} -trcrm {both|time|none} -ampm {auto|auto0|auto1|autoa} -bg tracewin_background_color -fg tracewin_foreground_color -cr tracecursor_foreground_color -fgcss sta_css_label_foreground_color -fgseed sta_seed_label_foreground_color -fgfil filter_label_foreground_color -bga arrival_background_color -fga arrival_foreground_color -bgsa selected_arrival_background_color -fgsa selected_arrival_foreground_color -timefm time_format_string -datefm date_format_string -phase_default default_phase_code -switchbuttons -noedit -nosort -noshowwfs -noshowarrs -noshowpreds -cliptraces -counts

trdisp [-g geom] [-r] [-s subset] [-w hours] data-base[.table] [start [range]]

display waveform data and arrivals from database or view

Waveforms 41

Page 46: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbheli [options] db sta chan tstart twinline nlines scalemake helicorder type plot of channel waveforms-f filter-o dborigin-ps psfile

Waveform Verificationdbversac database

compare sac file headers with CSS database

dbchkwf [ -v ] databasefile consistency check for wfdisc

dbcmpwf [-acmv] db1[.table] record1 db2[.table] record2

dbcmpwf [-acmsv] db1[.table] db2[.table]

dbcmpwf [-acmv] -i db1[.table] [db2[.table]]

dbcmpwf [-cmtv] db1[.table] db2[.table] t0 {t1|range}compare waveform files from two database records or tables.

dbversdwf [-s subset] [-T maxtdelta] [-dftuvwxX] databasecheck SEED format waveform files for consistency with wfdisc

Waveforms 42

Page 47: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Datascope Database Tools

Database Schemasdbbuild [-bv] [-p pf] db [input]

build new database with site, sitechan, sensor, instrument, stage and calibration tables

dbbuild_validate [-dsv] [file ..]verify that referenced parameter files contain all required fields

dbhelp [ db | s ]gui to explore schema for database db or schema s

dbdescribe { db | schema } [ table ]generate ascii formatted document describing schema, database, or database table

dbdoc dbgenerate troff formatted document describing schema for database db

dbfilenames [-v] dblist database tables and permissions

dbdesign [schema]create and/or edit Datascope schema files

dbinfer file [file...]build schema file from set of ascii example files

dbquery [-isv] [-f fld] db[.tbl] [query ...]query database/schema for parameters like field size

dbsnapshot [options] db [start_time [end_time|period]]create tar snapshot of database (for debugging)-d d copy output to dir d rather than tar file

-e e related to event evid e

-f file name of tar file

-n m max records (per table) to include

-r include response files-R include stage response files

-s s subset expression for stations/channels

-v more verbose

-w M minutes M of data before now

Creating and Editing Databasesdbe [-e] [-p pf] db[.table] [ db[.table] ...]

general purpose viewer/editor for databases

dberesp [db.table | -f response ..]run by dbe to plot response curves from database table or response files

Datascope Database Tools 43

Page 48: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

db_extfile_proc -m mode [-u] [-w nmax] [-t table] db.table

run by dbe to run arbitrary commands on database external files

db_textedit db.tablerun by dbe to edit external text files

db_xvimage db.tablerun by dbe to show external image files

db_showurl db.tablerun by dbe to show external web pages

remark_gui [table|view]run by dbe to add/show remarks

dbset [options] db[.table] field from [to]change value of attribute field throughout database-c ask before changing ('all' accepts all changes)-l use literal value for comparison-v show changes

dbconvert [-fv] [-s new_schema] db dbout[.table]create dbout (or dbout.table) from database db, using rules from dbconvert parameter file

dbcreate [-r refdb] [-s schema] [-iv] databasecreate database descriptor file

dbcp [options] dbin[.table] dboutcopy database dbin (or dbin.table) to database dbout-a alt specify alternate subdir for external file copies

-d make descriptor file for dbout which refer-ences dbin

-i prompt for permission to overwrite existing tables

-F override ../ exclusion (caveat emptor) -f copy external files (default changes references)-l create local symbolic links for external files-o quietly overwrite existing external files-s copy without correcting external file references -v verbose

dbadd [-afov] dbin.table dbout.table expr1 [expr2 ...]add rows to dbout.table using rows from dbin.table and expressions expr1, expr2, ...; with -a, add all fields from dbin.table, with -f ignore key duplica-tions, with -o overwrite duplications

Datascope Database Tools 44

Page 49: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbaddv [options] database.table [name value name value ...]

add records to table-c confirm each addition-i interactively-f ignore key duplication-v verbose

dbdelete [options] view [table ...]delete (or mark) all records in database view (or just records in table)-c require individual confirmations for each

record-m mark records only (no final crunch)-s save copy of original file-v verbose

dbcrunch [-nv] db [table ...]crunch out marked (null) records in database db, or just tables

dbdestroy [-ginkv] db[.tbl]destroy database or table by removing all associated files-g remove files which match glob of db.*-i confirm each file removal first-n show what would happen (don't do it)-k keep external database files-v verbosely

dbsplit [options] dbin dboutcopy records from database dbin which satisfy some subset expression into database dbout, using rules from parameter file.-d delete selected rows from dbin after copying to

dbout-f overwrite any existing output tables in dbout-k keep renamed backup of original tables

-p pf parameter file

-s subset records which satisfy expr are copied to dbout-v verbose

dbmerge [-vV] [-x tb1,tb2] dbin dboutmerge database dbin into database dbout (except for tables tb1, tb2, ...)

dbconcat_event db1 db2 [ db3 ...] dboutcombine multiple CSS 3.0 event databases db1, db2, ... (arrival, assoc, event, origin, and origerr tables) into single new database dbout

Datascope Database Tools 45

Page 50: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbfixids db idname [ idstart ]

dbfixids [-s server] [-i id1,...] [-x id2,...] db [ db2 ]renumber ids for idname (starting at idstart) in data-base db, or sync ids to idserver server-i ids only renumber these ids

-x ids don't renumber these ids

Creating Database Viewsdbsubset [-n name] [-v] aview expr

keep only records from aview satisfying expression expr

dbsort [options] aview [key ...]sort input aview by keys-o overwrite original table with sorted table

-n name save results into database.name

-r reverse sense of sort-u eliminate extra rows which are identical in sort

keys-v mention number of output records

dbjoin [options] aview [:key ...] table2 [[:key ...] table3 ...]join input aview with other tables, either by inferring join keys or by explicitly specifying join keys-o outer join

-n name save results into database.name

-v verbose

dbnojoin [-n name] [-v] aview [:key ...] table2create view of records from aview which do not join with table2

dbtheta [-c expr] [-n name] [-v] aview table2create view joining aview to table2 where expression expr (on joined record) is satisfied

dbseparate [-n viewname] [-v] aview table1create view containing only rows of base table table1 used in aview

dbsever [-v] [-n name] aview table2create new view which removes table2 from input aview

dbunjoin [-f] -o dbout aviewcreate new database dbout using base table records from aview

dbselect [options] aview [exp ..] [-pre exp exp ...] [-post exp exp ...] [-group field1 field2 .. [-pre exp exp ..] [-

Datascope Database Tools 46

Page 51: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

post exp exp ..]] [-group field1 field2 .. [-pre exp exp ..] [-post exp exp ..]]

print selected fields and expressions from input aview-b strip blanks from each field in output.

-F sep separator

-h add automatic headers to output-p print primary key-s allow expressions to modify database fields

with operator ":=".

db2xml [options] aview [name expr [name expr ...]]print database view as XML-d tag tag name for document root

-p primary keys only

-r tag tag name for each row

-v verbose

Verifying Databasesdbcheck [-vv] db[.table]

scans database (or table) for lines with invalid length

dbverify [options] db[.table]perform some consistency checks on database db (or table)-A t1,t2.. alternate keys need not be unique in t1, t2, ..

-c perform consistency checks

-C c1,c2,.. run only specific consistency checks c1,c2,...

-I t1,t2.. suppress table checks on t1, t2, ..

-i check that referenced foreign ids are present -j test 2-table joins from parameter file-k verify primary and secondary key are unique-l check that lastid table entries are valid

-N mx print maximum of mx failures for some tests

-O t1,t2.. perform table checks only on t1, t2, ..

-P t1,t2.. primary keys need not be unique in t1, t2, ..

-p external program tests from parameter file-r check attribute ranges-s check for shadowed database tables

-S n sample n records, not entire table

-t turn off all tests-u complain about unreferenced ids-v verbose-x check for existence of external files

-X pf use alternate parameter file

Datascope Database Tools 47

Page 52: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbcheck_responses [-t tolerance] [-v] database

dbcheck_responses [-t tolerance] [-v] -f response-file ...perform simple checks on response files from instrument and stage

dbdiff [options] db1[.table] db2[.table]find differences between two databases (or tables)-A absolute_tolerance -R relative_tolerance

allow floating point values to vary by some absolute or relative tolerance in indexes

-a absolute_tolerance -r relative_tolerance

allow floating point values to vary by some absolute or relative tolerance

-e print times as epoch seconds

-i name list of names to ignore

-l {exact|compare|ignore}for link fields

-N max_diffs show a maximum of max_diffs per table

-o compare records in order rather than by index

-w width-x {exact|compare|ignore|Program}

for external files

Miscellaneousdbcentral [-dln] [-q query] [-t time] [database_cluster

[task_nickname]]launch commands on commonly used databases

dbids [-p port] [-P pf] [-v] databaseidserver for Datascope databases

dbindex [-v] database[.table [keys..]]create static index(es) for static tables or databases (use with caution)

dbnextid db idnameget next available id for idname (in database db)

dbcalc [options] db.table [ record# | expression ]interactive interface to Datascope expression calcula-tor-c expr calculate single expression-e echo input to stdout

-r print reverse polish notation for expression-t show type of each piece of expression and

result

Datascope Database Tools 48

Page 53: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

dbremark [ -p ] database table field valueget/add remark from/to database (must contain remark table and commid)

dbfixchanids [-q] [+q] dbfix chanid attributes in wfdisc and arrival tables

dbfixtimeres db [expr]fix time residuals in assoc table (for records which satisfy expr)

dbfix_calib dbreplace null calib values in wfdisc with values from calibration table

Datascope Database Tools 49

Page 54: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Miscellaneous Utilitiesbuild [pf] [pf_dependent_arguments]

framework for constructing simple gui interfaces based on parameter files and perl scripts

children pid ...returns children of process pid

cleartmp [-nv] directory idlecleartmp removes files from directory which have not been used in over idle days, and finishes by removing any empty directories.

tksend [options] app_name [message]send message to program using tk send protocol-i read stdin for more messages-p wait for and print returned messages-verbose be more verbose-validate validate application name and return disposi-

tion and version number

-version {3|4|auto} select older or newer tksend protocol; default is

auto{matic}-wait wait for response

txform [-v] dir filenametext transform program

warp [-nv] commandrun command on opposite display (if machine has 2 displays)

Examples and TemplatesSee the example directory also.

mkmk [ - ]show prototype Antelope makefile (- suppresses comments)

manpage [ - ]show prototype Antelope man page (- suppresses comments)

template [example]get example from templates directory

Miscellaneous Utilities 50

Page 55: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Antelope Installationantelope_update [options] [url]

update local antelope installation from standard BRTT patches or alternative url-i ask before installing each patch-l just list unapplied patches -L list all patches to terminal with '*' if patch is

unapplied

-m mailto run silent, but send email if patches are needed

-n show what would happen, don't actually do it

-p proxy use proxy with password authentication

-q proxy use URL proxy

-Q don't ask about stopping realtime systems (caveat emptor)

-r id specify a different antelope release

-t terminal mode (no gui)-v verbose

check_license [-v] [license_filename]verify license is valid

register_antelope [-t]gui for requesting Antelope license

required_unix_programs check for programs required by Antelope

Path utilitiesabspath apath [...]

construct absolute path corresponding to input apath

relpath here thereconstruct relative pathname from here to there

cleanpath [-l] apatheliminates repeated slashes, unnecessary ./, and resolves symbolic links unless -l

concatpaths path p2 ...concatenate paths from command line or stdin to create complete path

datafile [-ae] {name | dir name | env dir name}show what files will be selected by datafile/datap-ath/datasearch(3) routines.

Miscellaneous Utilities 51

Page 56: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

Antelope facilitiesepoch [options] [ +format ] [ time/date components ]

convert time formats.-d show input as elapsed time, eg 1.5 days-e echo interactive input-l output in local time

-i tz specify an input timezone tz, eg US/Mountain

-o tz specify an output timezone tz, eg Japan

+format specify format of output (refer to epoch escapes table)

elog [-cdlnS] [-f fault] [message]exhibit behavior of elog error routines with message

elog -e errnoprint error message for numeric system error

elog -s signal#print signal description

pfe [-X] [-font font] [-level level] [{ - | pfname1 [pfname2 [...]]}]

parameter file navigator GUI-X don't expand references-font font for pf tree graphics-level default display level

pfcompare [options] pffind differences between local parameter file and remainder of pf files found along PFPATH-s show stock version (instead of local)-u show unique items-v verbose-V very verbose

pfdiff [-1t] [-o newpf] pf1 [pf2]compare parameter file pf1 to pf2 (or $ANTELOPE/data/pf/pf1 if pf2 is unspecified)-o interactively selects parameters from pf1 and

pf2 to construct pf, newpf-t runs tkdiff-1 limits depth of recursive comparison

pfecho [options] name [ param ...]print out parameters from parameter files-i interactive mode-q don't echo key-R show parameters overridden by later parameter

files-w show all pf files read-W show all filenames examined (may not exist)-x expand all references inside pf

Miscellaneous Utilities 52

Page 57: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

pfverify [-v] [pf-files]check resolution of all plain references in parameter files

pfwhich pfshow what files are read for pf

ttcalc method model phase distance depthprint travel time and slowness calculation results for method, model, and phases for an event at distance and depth.

gsregion [lat lon]geographic and seismic region numbers and names for lat, lon

dbsetrgn dbset seismic and geographic region codes in origin table for database db

trwfname [input]try out trwfname(3) patterns

comsim connectionmonitor, test and debug serial or ip communications

xunits [-amqv] [from [to]]convert values from one unit to another, eg newtons to lbs

Miscellaneous Utilities 53

Page 58: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

File utilitiesgrepsrc [options] [-cfhilMmpsTtvyw] [pattern [dir]]

look through certain files below dir for pattern; use-ful for finding occurrences of call to function, or for many other problems-i case insensitive-l show only filenames with matching lines.-v show find command, and list files searched.-w show all matches, not just word matches.restrict searches to certain files by using any combination of:-A include directories named junk and ending in --c c source files-C c++ source files-f fortran source

-g glob files matching glob

-h include files -M Makefile or makefile-m manual pages -P parameter files-p perl source -s shell source -T all text files-t tcl source -y (f)lex and yacc source

Miscellaneous Utilities 54

Page 59: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

ffilter [-BbCcDdelnpStuvVXxz] [-E s/from/to/] [-m re] [-r re] [paths]

filter list of files according to various optionsCombinatorial options-a autosplit input lines-b binary files-c in CVS-C not in CVS-d directory-e empty directories-l symbolic links-L is plain file and has multiple links-o is on this file system-O is on different file system from $cwd-p plain file-t text file-x executable-z zero size-v invert result of all tests Regular expression matching

-m re keep matching files

-r re reject matching files

Operations on filenames

-D dirname extract dirname

-B basename extract basename

-S suffix extract suffix

-E command perl command operating on filename

Other options-X execute each result-n only show command, don't execute-u print only unique paths

check_path [-v] [path]check path to ensure that 'other' users can traverse it

cmpdirs [options] dir1 dir2-c compare files-C ignore CVS directories

-i re ignore files/directories matching re

-l list format output-t compare only text files-r recursive-v more verbose

Miscellaneous Utilities 55

Page 60: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

xdiff [options] dir1 dir2compare files after eliminating expected discrepan-cies-a abs set absolute tolerance for numerical differences

-b ignore blanks-B keep blank lines with exception file -c ignore case differences (spiff only)-C treat as C files (spiff only)

-d diff specify the diff program to run

-D display specify the display to run tkdiff on.

-F treat as Fortran files (spiff only)-i case independent compare

-I re ignore files with names like regular expression e

-L skip files when both are symbolic links -o in comparing directories, ignore missing files

in the 2nd directory.-O in comparing directories, ignore missing files

in the 1st directory.-q only show files that are different, don't show

differences

-r rel set relative tolerance for numerical differences

-S treat as Bourne shell scripts (spiff only)-s suppress matching lines in the output-t use tkdiff to show files where there are differ-

ences-v be more verbose-V show each command run, and show each sub-

stitution when an exception file is provided.

-w width specify screen width when using sdiff-x exceptions file containing perl regular expressions

mapped to null before comparison-X don't ignore CVS directories

Programming aidesgetid [-aNv] < in > out

substitute special values into source files; used to centralize some info and help architecture indepen-dence

Miscellaneous Utilities 56

Page 61: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

ldlibs [options] namessuggest link libraries; provide information about object librariesModifying Options-f generate fortran ldlibs line (default is c)-i initialize database, eg, completely rebuild it-k rebuild database, if it's out of date-n don't use macros to collapse dependency list-v be more verbose-x specify entry points on command line, rather

than object files

-X lib1 lib2 show all multiply defined entry pts or global variables between lib1 and lib2

Different Modes

-D lib show refs defined in lib

-N lib show refs not defined in lib

-L lib show libraries which load lib

-l lib show libraries loaded by lib

-r lib1 lib2 show refs from lib1 which are resolved in lib2

-R a.o b.o .. lib show undefined refs from .o files which are resolved in lib

-S lib1 lib2 show shared undefined refs between lib1 and lib2

-s lib1 lib2 show shared definitions between lib1 and lib2

-T lib1 lib2 show needs unique in each library

-t lib1 lib2 show definitions unique in each library

-U lib show libraries which need lib

-u lib show libraries which are needed by lib

-V lib index a single library, verbosely

-w routine show what libraries define routine

-W routine show what libraries require routine

compile [options]used by BRTT to compile with optional optimiza-tion on different architectures

deposit [-rx] file dirinstalls file in directory dir with appropriate permis-sions; -r installs file with new name dest; -x makes installed file executable

deposit [-i re] idir dirinstalls directory idir into dir except for files match-ing re, CVS and .depends files

produce [-v] exec [exec2 ...]use standard headers from template directory to cre-ate executable script exec from files with proper suf-fix

Miscellaneous Utilities 57

Page 62: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

User Reference

installman [-nv] manpage dirinstall manpage into directory dir, modifying .TH line appropriately

fixman [-BInd] pagescheck man page, correct some problems, and sug-gest other changes

certify [options] [dir|testid ...]run regression tests-a with -u or -A, update all tests, even if they don't

fail.-A ask if correct result should be updated when a

failure occurs.

-c database use alternate database instead of ./certify

-C run cvs update before running the tests.-d rerun just the diff commands-e show the environment-f run failing tests only -D run dbx on the executable-G run gdb on the executable

-H dir run in the specified directory

-i set up; make directories input, data, results and correct; initialize certify database

-k keep results even if test is successful-l list tests-m send mail about failures, otherwise be quiet-M suppress the use of the watchmalloc library.-n show what tests would run -p compile with Purify before running the test-P Compile with Purify, but no x-windows-Q only show failing tests -q don't show errors in detail-R run certify in every subdirectory which con-

tains certify db-r cleanup directory by removing results and exe-

cutables-s stop at first failure-u update correct results from the output of this

run-U run the executable under ups

-x path add path to front of PATH environment vari-able

-X results add a line for each test to results file

Miscellaneous Utilities 58

Page 63: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

ScriptingLanguagesInterfaces

Page 64: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Contents

Perl Datascope Interface ................................. 1

Perl Orb Access............................................. 11

Perl System Information ................................ 15

Perl Trace Waveform Processing Interface.... 17

Perl Station-Channel Gather Interface........... 18

Perl History Interface ..................................... 19

Perl Vector Interface ...................................... 20

Perltk Bplot .................................................... 21

Tcl Datascope and Utilities ............................ 25

Tcl Orb Access .............................................. 32

Tk Brttplot ...................................................... 36

Tk Gpl ............................................................ 41

Tk Pixmap...................................................... 43

Tk Vogle......................................................... 44

Tcl/Tk Extensions .......................................... 50

Datascope PHP Interface .............................. 51

Orb PHP Interface ......................................... 60

PHP System Information ............................... 63

Matlab Interface ............................................. 65

Page 65: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perl Datascope Interfaceuse Datascope ;

% man perldb

Opening a Databasedbopen(database, permissions)

return database pointer to the database

dbopen_database(database, permissions)open database (or database.table or "-" for view from stdin), return database pointer

dbopen_table(database.table, permissions)open database.table (or "-" for view from stdin), return database pointer

dbcreate(filename, schema, dbpath, desc, detail)create database descriptor file filename with specified schema, dbpath, desc and detail

dbtmp(schema)return database pointer to temporary database with specified schema

dbclose(@db)close the database, freeing all resources

dbfree(@db)free resources for table or database

dblookup(@db, database, table, field, row)return database pointer for the specified database, table, field, and row.

Manipulating Fields and Recordsdbadd(@db [, record])

add the new record to the table in @db. If record is not specified, add the scratch record. return the new row number, or an error code < 0.

dbaddnull(@db)add null row to table

dbaddv(@db, field_name, value, [field_name, value, ...])add new row with the specified values to table

dbaddchk(@db[, record])Attempt to add new record, first checking for con-flict, like dbaddv

dbmark(@db)set the specified rows to all null values

dbdelete(@db)delete row from the database

Perl Datascope Interface 1

Page 66: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbcrunch(@db)delete all marked (null) rows from the specified table

dbtruncate(@db, n)truncate table to specified number of rows

dbdestroy(@db)delete all tables and the descriptor file for the speci-fied database, but not external files

dbget(@db [, 0])return [or copy to the scratch row] the specified field or row

dbgetv(@db, field_name [, field_name, ...])return values of the specified fields for @db

dbput(@db [, string])copy from scratch row [or from string] to specified field or row

dbputv(@db, field_name, value [, field_name, value, ...])save values into the specified fields for row @db

dbadd_remark(@db, remark)add comment in remark table for row @db

dbget_remark(@db)get any comment from remark table for row @db

Forming Viewsdbgroup(@db, key [, key, ...])

group the input table according to the specified keys

dbjoin(@db1, @db2 [, join-keys])return join of the two tables, using the join-keys if specified

dbmatches(@db1, @db2, hookname [, join-keys])return list of rows in db2 which match row @db1

dbnojoin(db1, db2 [, join-keys])return view of all rows in view @db1 which don't join to @db2

dbprocess(@db, commands)return new view which is the result of applying the dbprocess commands to the input view; possible operations are: dbopen, dbjoin, dbgroup, dbleftjoin, dbnojoin, dbselect, dbseparate, dbsever, dbsort, dbsubset, dbtheta, dbungroup

dbseparate(@db, table)return new view which consists of all the rows of the specified table which participate in the joined view @db

2 Perl Datascope Interface

Page 67: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dbsever(@db, table)return new view which consists of all the unique rows left after removing the specified table from joined view @db

dbsort(@db [, -u][, -r][, key, key..])sort the input table according to the specified keys, uniquely if -u, in reverse order if -r

dbselect(@db, expr[, expr[, expr..]])print table of expressions from view

dbselect_hdr(@db, expr[, expr[, expr..]])print headers for expressions

dbsubset(@db, expression)return new view which is the set of all rows which satisfy the expression

dbtheta(@db1, @db2, [expression])return new join view with all combinations of rows from the two tables which satisfy expression, or all combinations if no expression is specified

dbunjoin(@db, database)create new database, containing all the records refer-enced in the input view @db

dbsave_view(@db, name)save the view into file named database.name

Miscellaneous Datascope Functionsdbquery(@db, code)

query the database for information, e.g. dbquery(@db, dbRECORD_COUNT). see Datas-cope Constants for valid query codes.

dbex_eval(@db, expression)evaluate expression for particular row

dbcompile(@db, string)add new attributes or relations to the schema directly from the perl script

dbextfile(@db [, base-table])return the filename for an external file for particular row in view

dbnextid(@db, id_name)gets the next free id value for the specified database and id_name

dbstrtype(@db, string)classifies string, returning "strREAL", "strINTE-GER", "strNULL", "strSTRING", "strTIME", "str-FIELD", or "strUNKNOWN"

Perl Datascope Interface 3

Page 68: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbfind(@db, string [, first [,reverse]])find first row matching expression, starting with first; if reverse, search backwards

dbinvalid()return database pointer of dbINVALID

dbget_range(@bundle)returns start, end of range for bundle db pointer

dbbase(@db[, table])returns base table database pointer corresponding to record @db

Waveformstrsample(@db, $t0, $t1, $sta, $chan[, $apply_calib])

fetch waveform data from table @db for $sta/$chan between $t0 and $t1. returns time/value pairs If $apply_calib is non-zero, calib is applied.

trloadchan(@db, $t0, $t1, $sta, $chan)load data for $sta/$chan between time $t0 and $t1. returns database pointer to trace table.

trcopy(@dbout, @dbin)returns a temporary copy of a trace database table, possible appending to an existing table

trdata(@db[, $i0[, $npts]])returns $npts data points starting at $i0 from trace table record @db

trsplit(@tr)eliminate marked gaps inside the trace table @tr by splitting segments containing marked values

trsplice(@tr)glue together segments (if possible) in trace table @tr, eliminating overlapping segments.

trfilter(@tr, filter)apply specified filter to the traces; see trfilter(3)

trfree(@tr)free trace table memory.

trlookup_segtype(char)return units and description for segtype char

Error Handlingelog_init($0, @ARGV)

initialize the elog message routines

elog_log(msg)save message on the elog message log

4 Perl Datascope Interface

Page 69: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

elog_debug(msg)

elog_notify(msg)

elog_alert(msg)

elog_complain(msg)send debug, notify, alert, complain message to the elog facility

elog_die(msg)send message to the elog message facility and die

elog_callback(replacement)replace standard elog processing with perl routine replacement is called with two arguments: severity code and a string containing the elog log. it must return an integer; if return != 0, error log is cleared.

elog_string(n)return error log starting with message n

elog_clear()clear the elog message log

elog_mark()return the count of messages currently held in the error log

elog_flush(deliver, first)eliminate log messages after first, printing them if deliver is set

Parameter Filespfget(pfname, key)

return the value for the key from the parameter file pfname

pfget_boolean(pfname, key)return 0 or 1 depending on the value of key in the parameter file pfname

pfget_size(pfname, key)returns number corresponding to key in parameter file pfname, allowing suffix G, M, k, m or u.

pfget_time(pfname, key)return epoch time corresponding to key in parameter file pfname, using str2epoch

pfupdate(pfname)check and reread parameter file if file used along PFPATH changed

pffiles(pfname [, all])return list of file which make up parameter file object. If all is specified, return all possible filena-mes, including non-existent files.

Perl Datascope Interface 5

Page 70: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

pf2string(pfname)return string representation of the parameter file object pfname

pfnew(pfname)create a new empty parameter file object with name pfname

pfcompile(string, pfname)convert the specified string into parameter file object name pfname.

pfput(key, value, pfname)save the specified value into the pf object with name pfname under the specified key. The value is converted to string if it's scalar; when it's a reference to a perl array or hash, the entire perl array or hash is stored in the pf object.

pfwrite(filename, pfname)write out pf object pfname to filename

pfrequire(pfname, atime)require pf_revision_time from last file pfname is later than atime.

pfdel(pfname, key)delete named key from pf object pfname

Special functionsask(string)

pose question string at the controlling tty, and return the response

askyn(string)like ask, but require yes/no answer; return 0=false, 1=true

askynaq(string)like ask, but require yes/no/all/quit answer; return 0=false, 1=true, 2=all, 3=quit

yesno(s)return -1 if $s =~ /yes|ok|y|true|1|on|t/i, 0 if $s =~ /no|n|false|0|off|f/i, 1 otherwise

datafile(env, file)find the specified file by looking first at the environ-ment variable, then along the path

datapath(env, dir, file, suffix)find the specified file by looking first at the environ-ment variable, then along the path

makedir(d)make the complete directory path d (like "mkdir -p")

6 Perl Datascope Interface

Page 71: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

abspath(a)return the absolute path to the specified file a.

relpath(d, t)return relative path from directory f to t

cleanpath(p [, nolinks])normalize the input path p, removing extra "..", "//", and "./" strings. With second argument, resolve any symbolic links along the path.

concatpaths(a,b)concatenate the two paths a and b properly, adding a slash if necessary.

parsepath(a)return directory, file basename, and suffix for path a.

close_descriptors()close all file descriptors after stderr; useful after fork

strsignal(code)return name for signal, given the integer code

is_nfs(path)return true if path is on an nfs-mounted filesystem.

limit(resource, [limit2set])return the current resource limit, or set new resource limit; possible resources are:cputime filesize datasize stacksize coredumpsize vmemoryuse

grn(lat, lon)return the geographic region number

grname(lat, lon)return the geographic region name

srn(lat, lon)return the seismic region number

srname(lat, lon)return the seismic region name

sgsign(signer,data)returns signature for specified signer and data

sgverify(signer,data,signature)returns zero if signature is correct for signer and data

($out, $units) = units_convert(input,want)returns value and units for specified input and requested units

@list = units_match(input)returns list of units matching input

$errno = errno()returns system errno, resetting errno to zero

Perl Datascope Interface 7

Page 72: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

($result, $restriction) = legit_ip(pf,ip)checks ip address in valid_ip_addresses list from pf, returns 1 for legitimate ip, -1 if no parameter file, 0 if invalid ip

Simple Ring Buffersopenring(filename, id, depth, flags)

open or create new simple ring buffer in filename with (up to) 64 byte id field, maximum depth entries. if flags & 1 is set, open read-only, no locking; other-wise ring buffer must be on local filesystem. return handle to ring buffer.

newring(filename, id, depth, flags)create new simple ring buffer like openring, over-writing any old ring buffer

closering(rb)close specified ring buffer

pushring(rb, time, value)add time/value pair to ring (in time order)

getring(rb, i)return the i'th time/value pair from the ring; 0 is the most recent pair

avgring(rb, tdelta)return the average value in the ring rb for the latest tdelta seconds in the ring

minring(rb, tdelta)return the min value and the corresponding index in the ring rb for the latest tdelta seconds in the ring

maxring(rb, tdelta)return the max value and the corresponding index in the ring rb for the latest tdelta seconds in the ring

changedring(rb, tdelta)returns 1 if ring buffer values have changed in past tdelta seconds

countring(rb)return the number of time/value pairs in the ring

findring(rb, value, tdelta)findring searches the ring buffer rb over the speci-fied time period tdelta for the specific value.

Time Conversionnow()

return current time to (usually) microseconds accu-racy

8 Perl Datascope Interface

Page 73: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

is_epoch_string(string)return epoch time unless string is invalid; then returns undef and error message.

epoch2str(epoch, fmt [, timezone])return the epoch time formatted according to the fmt string and converted to timezone

str2epoch(string)return the epoch time corresponding to the free-form input time/date

strtime(epoch)return epoch time formatted like "4/23/2001 15:35:15.000"

strydtime(epoch)return epoch time formatted like "4/23/2001 (113) 15:35:15.000"

strdate(epoch)convert epoch time to date, eg "4/23/2001"

strtdelta(dt)convert the time-difference dt (in seconds) to string, eg "30:35 minutes"

strlocaltime(epoch)return epoch time formatted like "4/23/2001 15:35:15.000" in local timezone

strlocalydtime(epoch)return epoch time formatted like "4/23/2001 (113) 15:35:15.000" in local timezone

strlocaldate(epoch)convert epoch time to date, eg "4/23/2001" in local timezone

epoch(yearday)return the epoch time corresponding to the integer yearday

yearday(epoch)return the yearday corresponding to an epoch time

wait_for_time(time,verbose)wait for specified time

State Filesexhume(filename,reference,seconds)

specify filename of state file, reference to variable to be set when interrupted, and number of seconds to wait for program to terminate

Perl Datascope Interface 9

Page 74: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

resurrect(name, ref[, TIME_RELIC])select names and references to perl variables to save in state file. (Optionally specify the type, may be useful for epoch times)

bury()Save the state file.

Foreign Keysmap between CSS3.0 station/channel naming conventions and the different conventions of autodrm and SEED.

$sta = map_autodrm_netsta($anet, $fsta)

$chan = map_autodrm_chanaux($sta,$fchan,$aux)

($anet, $fsta) = autodrm_net($sta)

($fchan, $aux) = autodrm_aux(sta, chan)

$sta = map_seed_netsta($anet, $fsta)

$chan = map_seed_chanloc($sta,$fchan,$loc)

($snet, $fsta) = seed_net($sta)

($fchan, $loc) = seed_loc($sta,$chan)

finit_db(@db)cause foreign key routines above to use specified database @db

10 Perl Datascope Interface

Page 75: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perl Orb Accessuse orb;

% man perlorb

orbopen(name, perm)open the specified orbserver name with permission perm ("r", "w", "r&", or "w&"), returning the open file descriptor orb

orbclose(orb)close an orbserver connection

orbselect(orb, re)select packets with sourcenames which match the regular expression re.

orbreject(orb, re)reject packets with sourcenames which match the regular expression re.

orbseek(orb, which)position the orb connection packet pointer according to which; which may be an explicit pktid, or "ORB-CURRENT", "ORBPREV", "ORBNEXT", "ORBNEXT_WAIT", "ORBOLDEST", or "ORB-NEWEST".

orbposition(orb, from)position the orb connection packet pointer according to from; from may be "newest", "oldest", or any (UTC) time string recognized by str2epoch(3).

orbtell(orb)return the current orb connection position (pktid).

orbafter(orb, time)position the orb connection packet pointer to the first packet after the specified time. Time must be UTC epoch time in seconds, not string.

orbresurrect(orb, pktid, pkttime)restore orb position from state, save to state when bury is called

orbping(orb)test if the specified orb responds; return version number.

orbwait(orb, re, mintime, timeout)wait for all reading clients of orb with program name which matches the regular expression re to have read packets younger than mintime. If timeout is non-zero, then orbwait return with an error code if the timeout expires before the specified program catches up.

Perl Orb Access 11

Page 76: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

($pktid, $srcname, $pkttime, $pkt, $nbytes) = orbget(orb, which)

get single packet corresponding to which; this can be an explicit pktid, or "ORBCURRENT", "ORB-PREV", "ORBNEXT", "ORBNEXT_WAIT", "ORBOLDEST", or "ORBNEWEST".

($pktid, $srcname, $pkttime, $pkt, $nbytes) = orbreap(orb)

get the next packet from the orb; this is the fastest, most efficient way of reading packets.

($pktid, $srcname, $pkttime, $pkt, $nbytes) = orbreap_timeout(orb, maxseconds)

get the next packet from the orb, but return early if no packets have appeared in maxseconds. In this case, the returned pktid will be undef.

($pkttime, $pkt, $nbytes) = orbgetstash(orb, srcname)get stash packet corresponding to srcname

orbpkt_string(srcname, time, packet, nbytes)return forb(5) string representation of packet

orbput(orb, srcname, pkttime, pkt, nbytes)put the specified packet onto the orb.

orbput_nolag(orb, srcname, pkttime, pkt, nbytes, lagparams)

put the specified packet onto the orb, ensuring that no client matching the parameters in lagparams pf is too far behind

orbputx(orb, srcname, pkttime, pkt, nbytes)put the specified packet onto the orb, with return acknowledgement

orbstashselect(orb,select)set the stash select parameter

($name, $content, $desc) = suffix2pkttype(suffix)return name, content and description for packet type suffix.

orbstat(orb)Get the standard status values from the orb; this return an object with the following methods:address closes connections errors host maxdata maxpkts maxsrc messages nclients nsources opens orb_start pid port rejected started version when who

12 Perl Orb Access

Page 77: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

($when, @clients) = orbclients(orb)$when is scalar; @clients is list of client objects, one object per client. Each object has the following methods:address and bytes errors fd host lastpkt lastrequest mymessages nreads nreject nrequests nselect nwrites packets perm pid pktid port priority read reject select started thread what who

($old,$new,$max,$range,@laggards) = orblag(orb,match,reject)

returns oldest, newest, and pktid range, with list of clients matching match/reject parameter. Each ele-ment of list contains client lag, thread, who and what

orbsources(orb)return ($when, @sources). $when is scalar; @sources is list of source objects, one object per source. Each object has the following methods:active and nbytes npkts slatest slatest_time soldest soldest_time srcname

showPkt(srcname, pkttime, pkt, nbytes, mode)print out packet summary, depending on mode:1 hex dump2 unstuff, print all data samples3 unstuff, print no data samples4 just show the header information

unstuffPkt(srcname, pkttime, pkt, nbytes)unstuffPkt unstuffs the input packet, returning packet kind and packet object. the result code indi-cates what kind of packet was unpacked:kind kind of packet---- --------------Pkt_wf waveform packetPkt_st status packetPkt_db database rowPkt_pf parameter filePkt_cn control messagesPkt_rw binary dataPkt_ch character stringPkt_tp test packet

The packet object has the following methods which return various values from the c Packet structure:

Perl Orb Access 13

Page 78: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

parts, time, PacketType, nchannels, channels(i), pf, string, db, dfile, and version.The parts method returns (net, sta, chan, loc, suffix, subcode)The PacketType method returns the packet kind (also returned by unstuffPkt) and the corresponding description.The channels method takes an index (0..n-1) argu-ment and returns channel object with its own meth-ods:calib calper chan cuser1 cuser2 data duser1 duser2 iuser1 iuser2 iuser3 loc net nsamp samprate segtype sta time

The data method returns all the waveform data in list of integers.

split_srcname(srcname)return net, sta, chan, loc, suffix, and subcode corre-sponding to srcname

join_srcname(net, sta, chan, loc, suffix, subcode)return srcname for net, sta, chan, loc, suffix and sub-code

14 Perl Orb Access

Page 79: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perl System Information use sysinfo ;

% man perlsysinfo

my_ip()return ip address (eg, 207.174.76.135)

my_os()return os name (eg, SunOS)

my_hardware()return hardware string (eg, sun4u)

my_hostname()return hostname (eg, ament)

ip(dot-notation)return integer corresponding to dot-notation

ip2name(ip)looks up hostname for ip address

name2ip(hostname)looks up ip address for hostname

nomem(address,n)return first bad address if no memory in range address to address + n

%sysmem = sysmem()return physical memory, total swap space, and swap used

%loadavg = sysloadavg()return nproc, avg1m, avg5m, and avg15m: number of processes and 15, 5 and 1 minute load averages

@mounted = sysmounted()return list of mounted partitions; each element has mount point, filesystem type, and remote host and directory

pidcmdline(pid)return command line for specified pid

pidpwd(pid)return working directory for process pid

pidexecname(pid)return executable name for specified pid

%info = pidinfo(pid)return usage in percent, parent pid, user id, size in kilobytes, resident set size in kilobytes, run state, epoch start time, total cpu time, and total children cputime for process pid

Perl System Information 15

Page 80: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

$exists = pid_exists($pid)returns 1 if $pid exists

%statvfs = statvfs(path)return Mb_total, Mb_avail, inodes_avail, inodes_used on disk containing path, % disk and inodes used, and unique id

($ncpu, $idle, $user, $kernel, $iowait, $swap, @othercpus) = syscpu()

return number of cpus, and idle, user, kernel, iowait and swap time for each cpu.

$cwd = getcwd()return current working directory

16 Perl System Information

Page 81: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perl Trace Waveform Process-ing Interfaceuse Trace ;

% man trace

trace_findrange ( t0, dt, nsamp, [tstart [,tend]] )find range of data samples

trace_trim ( @dbtr, [tstart [,tend]] )trim internally flagged gap values from beginning and end of waveform

trace_findbad ( @dbtr, [tstart [,tend]] )return the number of internally flagged gap values and the fraction of these samples relative to the entire time window

trace_computestats ( @dbtr, applycalib, meanremove, [tstart [,tend]] )

return a set of statistics (absolute maximum value, signed max/min value, time of max value, amplitude of max value, period of max value, mean and stan-dard deviation) optionally applying calib to the results and removing a mean value before the statis-tics are computed

Perl Trace Waveform Processing Interface 17

Page 82: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Perl Station-Channel Gather Interfaceuse Scg ;

% man scg

scg_create ( @db, tstart, tend, ?option, value, ...?)create scg object-sta => sta_exprstation name sifting expression

-chan => chan_exprchannel name sifting expression

-coord => coord_flagobtain station coordinates flag

-ir => ir_flag obtain instrument responses flag

-orient => orient_flagobtain channel orientation angles flag

scg_destroy ( handle )free a scg object and destroy all associated resources

18 Perl Station-Channel Gather Interface

Page 83: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perl History Interfaceuse History ;

% man history

history_create ( maxnp, ?option, value, ...?)create history object-filename => filenameread from history state file

-tag => tag

history_free ( {-tag => tag|handle } )free a history object

history_add ( handle, time, value )add a point to a history object

history_eval ( handle, time )evaluate history object

history_get ( handle [,index] )get number of history points and the index'th time and value

history_get_maxmin ( handle )get history minimum and maximum time and value

Perl History Interface 19

Page 84: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Perl Vector Interfaceuse Vector ;

% man vector

vector_create ( ?option, value, ...?)create vector object-nx => nx number of X independent variable values

-ny => ny number of Y dependent variables

-tag => tag

vector_read ( filename, ?option, value, ...?, [ypos0 [,ypos1 [...]]])

read vector object from an ASCII file-loff => line_offoffset in lines to data

-xpos => xpos offset in words to X values

-lpos => lpos offset in words to labels

-tag => tag

vector_read_response_fap ( filename, ?option, value, ...?)

read vector object from an Antelope instrument response file-tag => tag

vector_copy ( handle, ?option, value, ...?)copy a vector object from another vector object-tag => tag

vector_free ( {-tag => tag|handle } )free a vector object

vector_append ( handle, index, xvalue, @yvalues [,label])append/insert to a vector object

vector_puty ( handle, index, @yvalues [,label])replace dependent variables and label in a vector object

vector_eval ( handle, xvalue )evaluate vector object dependent variables

vector_get ( handle )get vector type, number of X values and number of Y values

vector_get_point ( handle, index )get vector dependent variables and label

vector_get_maxmin ( handle, iy )get vector minimum and maximum X and Y values

vector_transform_edp ( handle, lonr, latr )transform vector coordinates using an equal dis-tance map projection

20 Perl Vector Interface

Page 85: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Perltk Bplotuse TK::Canvas

use TK::Bplot

% man bplot

$canvas->create('bpviewport', name, x, y, ?option, value, ...?)

create canvas viewport for graph-anchor => {n|ne|e|se|s|sw|w|nw|c}-tags => taglist-width =>widthwidth in pixels (0: rubber-band)

-height => height height in pixels (0: rubber-band)

-mleft => left margin-mright => right margin-mbottom => bottom margin-mtop => top margin-wtran => {none|edp|merc}coordinate system

-latr => reference latitude-lonr => reference longitude-xmode => {lin|log|time} -ymode => {lin|log}-xleft => x0 data-coordinate of left edge of plot

-xright => x1 data-coordinate of right edge of plot

-ybottom => ybottomdata-coordinate of bottom edge of plot

-ytop => ytop data-coordinate of top edge of plot

-fill => color background color for plot region

-fill_frame => colorbackground color for margins

Perltk Bplot 21

Page 86: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

$canvas->create('bpaxes', vpname, ?option, value, ...?)create axes associated with vpname-tags => taglist-fill_labels => colorx and y labels color

-fill_numbers => colornumbers color

-fill_axes => coloraxes color

-font_labels => fontlabels font

-font_numbers => fontnumbers font

-font_numbers_superscripts => fontexponent font

-xvisible => {0|1} draw and label xaxis ticks

-yvisible => {0|1} draw and label yaxis ticks

-linewidth => width-linewidth_small => width-mindx => dx-mindy => dy-xincrement => dx-xincrement_small => dx-xlabel => labellabel along x axis

-xformat => {auto|none|time}tick label style

-yincrement => dy-yincrement_small => dy-ylabel => labellabel along y axis

-yformat => {auto|none}tick label style

-axis_style => [nesw]*draw these sides of box

-tic_style => ([nesw][ioc])* ticks inward, outward, cen-ter

$canvas->create('bpgrid', vpname, ?option, value, ...?)canvas item to create a mesh of grid lines-tags => taglist-fill => color-fill_small => color-linewidth => width-linewidth_small => width-visible => {0|1}-visible_x => {0|1}-visible_xsmall => {0|1}-visible_y => {0|1}-visible_ysmall => {0|1}-mindx => dx-mindy => dy-xincrement => dx-xincrement_small => dx-yincrement => dy-yincrement_small => dy

22 Perltk Bplot

Page 87: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

$canvas->create('bptext', vpname, text, x, y, ?option, value, ...?)

create item to draw set of points or symbols-vector => handle|tagvector containing the points

-tags => taglist-symbol => {point|cross|x|triangle|square|circle|dia-

mond|star}-fill => color fill the symbols with this color

-outline => colordraw outline in this color

-linewidth => width-textforeground => color-font => font-size => size-visible => {0|1}-showsymbols => {0|1}-showtext => {0|1}

$canvas->create('bppolyline', vpname, ?option, value, ...?)

create item drawn with lines-vector => handle|tagvector containing the points

-thistory => handle|tag-tags => taglist-fill => color if specified, fill object with color

-outline => colordraw lines in this color

-linewidth => width-label => label-visible => {0|1}

$canvas->create('bppolypoint', vpname, ?option, value, ...?)

canvas item to plot text in data coordinates-tags => taglist-fill => color-font => font-visible => {0|1}-justification => {n|ne|e|se|s|sw|w|nw|c}-angle => angle

Perltk Bplot 23

Page 88: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

$canvas->create('bpmap', viewportname, ?option, value, ...?)

canvas item to plot world maps using equal distance projection-tags => taglist-fill_land => color-fill_water => color-coasts => color:linewidth-political => index:color:linewidth,...-rivers => color-visible => {0|1}-resolution => {auto|crude|low|intermediate|high|full}

24 Perltk Bplot

Page 89: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Tcl Datascope and Utilitiespackage require Datascope

% man Datascope

Opening a Databasedbopen db {r|r+}

open database db read-only (r) or read-write(r+); returns a db pointer

dbopen_table db[.table] {r|r+}open datbase table. The first argument may also be "-", allowing a view to be read from stdin. returns a db pointer

dbopen_database db[.table] {r|r+}open database db, or optionally a specific table. The first argument may also be "-", allowing a view to be read from stdin. returns a db pointer

dbclose dbclose the database db

dbfree dbfree memory resources and file descriptors for a database view/table

dblookup db database table field rowreturn a database pointer for the specified db, data-base, table, field, and row. row can be "dbALL", "dbNULL" or "dbSCRATCH", or a value corre-sponding to field; then the first row number where field == value is returned

dbtruncate db ntruncate the specified table to the first n rows

Manipulating Fields and Recordsdbadd db row

add the specified row to a table; return row number

dbaddnull dbadd a null row to the table; return row number

dbaddv db table field value [field value ...]add new row with specified field values; return row number

dbmark dbset the specified row to all null values

dbcrunch dbdelete marked (all null) rows from the table

Tcl Datascope and Utilities 25

Page 90: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbdelete dbdelete a row

dbget dbget a table, row, or field from a table

dbgetv db table row field [field ...]return a list with the specified values of the specified fields

dbput db valueput the specified value into the specified location.

dbputv db table row field value [field value ...]save the specified values into the specified fields.

Forming Viewsdbgroup db type field [field ..]

group the (sorted) input table by the specified fields

dbungroup dbreturns a view containing all the rows which the grouped view references.

dbjoin db1 db2 [keys]join the two tables (using the specified join keys)

dbjoin_tables dbreturns a list of tables for which some set of join keys with db can be inferred

dbjoin_keys db tablereturns the inferred join keys between db and table

dbnojoin db1 db2 [keys]returns view of all rows in db1 which do not join with table db2

dbmatches db1 db2 hook [keys ...]returns a list of rows in the table specified by db2 which match (join with) the row specified by db1

dbprocess db [command ...]construct a view as a series of standard operations. These include dbopen, dbjoin, dbgroup, dbleftjoin, dbnojoin, dbselect, dbseparate, dbsever, dbsort, dbsubset, dbtheta, dbungroup.

dbsever db tablereturns a new view which removes the specified table from the joined view db

dbseparate db tablereturns a new view containing only the rows from table which participate in the joined view db

26 Tcl Datascope and Utilities

Page 91: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dbsort [-r] [-u] db [fields ..]sort a table by fields, or the primary key if no fields are specified-r reverse the sense of the sort-u eliminate all rows in the output view with

duplicate field values

dbsubset db expressionreturns a db pointer to the rows from the specified table which satisfy expression

dbtheta db1 db2 [ expression ]theta join the specified tables db1 and db2

dbselect [-b] [-h] [-F separator] [-t] filename db [field ...]write selected fields from the input view to the spec-ified filename-b strip blanks from both ends of each field-h add headers-t convert times to readable times

dbsave_view [-f] db namesave the specified view as a table in the same data-base with the specified name-f Allow overwriting files of the same name

db2pipe db file [row# ...]send rows from a database view out a unix pipe

dbunjoin db outputunjoin the specified table, writing new tables into a new database named output

Miscellaneous Datascope Functionsdbeval db expression [type]

evaluate the specified expression, converting to the specified type

dbquery db codequery the database for various parameters

dbcompile db stringadd attributes and relations to a database by directly compiling schema file fragments

dbstrtype db stringreturns type of string: strREAL, strINTEGER, str-NULL, strSTRING, strTIME, strEXPR, strFIELD or strUNKNOWN

dbfind db first backwards expression [n]starting from first, locate the next (or nth) row in db satisfying the given expression; search down from first if backwards is non-zero.

Tcl Datascope and Utilities 27

Page 92: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbadd_remark db remarkadd the specified remark to the specified row

dbget_remark dbget the remark associated with the specified row

dbgetr db tz i n [expr [fmt]]return list of values for n rows beginning at row #i for expr optionally formatted using fmt; tz=0 may be 1 to use epoch2str for times, or a timezone code (eg, US/Mountain or LOCAL)

dbsetr db field first n expressionset the specified field in the specified table to the value of the expression in records first to first+n.

dbinvalid return a db pointer with all elements dbINVALID

dbnextid db nameget the next (integer) id for the specified name

Error Handlingelog_init args

initialize the elog routines with the command name and arguments

elog_log msgsave a message on the elog message log

elog_notify msgwrite a message other than an error message to the elog facility

elog_complain msgwrite an error message to the elog message facility for immediate output

elog_die msgwrite a message to the elog message facility and die

elog_clear clear the elog message log

clear_register flagclear the error register, optionally returning contents

elog_mark returns the count of messages currently held in the error log

elog_flush deliver firstget rid of messages after #first in the error log, print-ing them if deliver is a boolean true

28 Tcl Datascope and Utilities

Page 93: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Parameter Filespfget pf name

get value for name from parameter file pf

pfgetarr variable namereturn array for name (e.g. %pf#name) in variable

pfgetlist namereturn list for name (e.g. @pf#name)

pfput pf name valuesave the specified value into the parameter space

pfputarr pf name [array]save the specified array into the parameter space

pfputlist pf name [list]save the specified list into the parameter space

pfread pfforce rereading the parameter file

pfwrite pf filenamewrite the specified parameter file

Seismic Utility Functionscarsph x y z

convert from unit vector x y z to latitude, longitude in degrees

dbdist lat1 lon1 lat2 lon2return the angular distance between the specified locations. All units are degrees.

dblatlon lat lon delta azimuthreturn the latitude and longitude of the point at delta degrees in the direction azimuth from lat, lon

peterson {low|high} frequency rsptypereturn Peterson noise model values

sphcar lat lonconvert from latitude, longitude to unit vector x, y, z

read_response filenamereads a CSS3.0 instrument response file and returns a handle

free_response resphandlefrees the resources associated with a CSS3.0 instru-ment response object

eval_response resphandle freq_in_hzreturns the complex value of an instrument response object at a single frequency

Tcl Datascope and Utilities 29

Page 94: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

get_response resphandle {nstages | stage_types | paz stageno}

returns various parameters from an instrument response object

put_response resphandle stageno param_listputs a response stage into an instrument response object

Time Conversionnow

return current time

epoch yeardayconvert yearday (eg, 1999234) to epoch time

epoch2str epoch fmtconvert epoch time to a string according to specified fmt

str2epoch stringconvert time strings from many formats to epoch time

strtime epochconvert epoch time to a time string like "4/23/2001 15:35:15.000"

strydtime epochconvert epoch time to a time string like "4/23/2001 (113) 15:35:15.000"

strdate epochconvert epoch time to a date, eg "4/23/2001"

strtdelta dtconvert the time-difference dt (in seconds) to a string, eg "30:35 minutes"

yearday epochconvert from epoch time to yearday

Utility Functionsmakedir dir

make the directory hierarchy dir (like "mkdir -p")

writefile filename varwrite value of variable var to filename

datafile envname filereturns path for file under $ANTELOPE/data

is_nfs pathreturns true if path is nfs mounted

sig2str sigreturns a string describing the signal #sig

30 Tcl Datascope and Utilities

Page 95: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

tkcolor {colorname|#rrggbb|rrggbb|hue:light:sat}returns a legitimate tk color string

Tcl Datascope and Utilities 31

Page 96: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Tcl Orb Accesspackage require Orb

% man tclorb

Orbserver Communicationsorbopen orbname permission

open an orb connection

orbclose orbclose an orb connection for the specified orb descrip-tor

orbafter orb timeset the orb read pointer to the first packet after speci-fied time

orbseek orb whenceset the orb read pointer, returning the new read-posi-tion packet id.

orbtell orbreturns the current read/write position pktid fo the specified orb

orbping orbreturns the version number of the specified orb

orbselect orb exprread only sources matching expr, returning the cur-rent number of matches

orbreject orb exprdon't read sources matching expr, returning the cur-rent number of matches

orbreap reap_handleread a new orb packet from a previously started reap thread, returning a packet handle

orbreapstart orb [block]start reaping (reading) packets from orb, returning a read handle.

Orbserver Statusorbstat orb [args]

returns specified status information for orbaddress closes connections errors host maxdata maxpkts maxsrc messages nclients nsources opens orb_start pid port rejected started version when who

32 Tcl Orb Access

Page 97: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

orbgetdatasources orbreturns list of source names for orb

orbsources orbreturns handle for orb source status

orbsourcesfree handlefrees orbsources handle resources

orbgetnsources handlereturns the number of individual sources referenced by the sources_handle

orbgetsource handle n [args]returns specified source information for the n'th sourceactive nbytes npkts slatest slatest_time soldest soldest_time srcname

orbclients orbreturns handle for orb client status

orbclientsfree handlefrees orbclients handle resources

orbgetnclients handlereturns the number of clients for client handle

orbgetclient handle n [args]returns specified client information for the n'th sourceaddress bytes errors fd host lastpkt lastrequest mymessages nreads nreject nrequests nselect nwrites packets perm pid pktid port priority read reject select started thread what who written

Packet Handlingorbpfget pf_handle name

returns the value for parameter name from the refer-enced pf_handle

orbpfgetstr pf_handle [name]returns an ASCII string version of a parameter file object

orbpffree pf_handlefrees the parameter file object referenced by pf_handle

orbpktfree pktfrees the orb packet referenced by the pkt

Tcl Orb Access 33

Page 98: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

orbpktchanfree pktfree the specified unstuffed packet-channel

orbpktchangetcd1 packetchan_handlereturns CD1 status information for CD-1-format packet channels

orbpktchangethdr packetchan_handlereturns packet-channel header information

orbpktunstuffdata pktunstuff an orb packet pkt, returning a list of packet channels, or a database pointer, or a string, depend-ing on the packet

orbpktgetdb pkt dbunstuff a database packet pkt, returning a database pointer to the (scratch) record

orbpktgethdr pktreturns {pktid time srcname nbytes} for pkt

orbpktgetlog pktunstuffs log packet pkt, returning the log string

orbpktgetpf pktunstuffs pf packet pkt, returning a pf reference

str2orbpfpkt orb name stringwrites a parameter-file object defined by string as a parameter-file packet on orb

str2orbpfpkt2 orb srcname stringwrites a parameter-file object defined by string as a parameter-file packet on orb

Quanterra Specialorbpktgetqtping pkt

returns a string with the response to a qt2orb ping command

orbpktgetstatus pktreturns a string with qt2orb status information

orbqtpingsend orbsends a ping command to qt2orb via the specified command-orb

orbqtshell qtshell_handlehandle qtshell through orb

orbqtshellfree qtshell_handlefree a quanterra shell handle

orbqtshellstart cmdorbname netsta cmdstart a quanterra shell

34 Tcl Orb Access

Page 99: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

orbhelp print synopsis lines for orb Tcl commands

Tcl Orb Access 35

Page 100: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Tk Brttplotpackage require Brttplot

% man bplot_scg

% man bplot_vector

% man bplot_thistory

% man bplot_utils

% man brttplot

create_scg db tstart tend ?options?create a station-channel-gather data object for plot-ting with a viewport gpl object-net net_expr-sta sta_expr-chan chan_expr-coord coord_flag-ir ir_flag-orient orient_flag

destroy_scg scg_handledestroy a station-channel-gather data object

Vectorsvector_append vector_handle index xvalue ylist [label]

appends a vector element after an existing element

vector_create [ny] [-tag tag]create an empty generic data-vector object

vector_copy vector_handle [-tag tag]copy a vector object

vector_eval vector_handle xvaluecompute and return a y (dependent) value from a vector object

vector_free {-tag tag | vector_handle}destroys previously created vector objects

vector_get vector_handle {nx|ny|xy ix}get information relating to a vector handle

vector_maxmin vector_handle [iy]retrieve min and max x, min and max y from a vec-tor object

vector_puty vector_handle ix ylist [label]replace dependent values in a vector object

36 Tk Brttplot

Page 101: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

vector_read filename ?options?create a vector object from an input ASCII file-tag tag-loff line_off-xpos xpos-ypos ypos1 [ypos2] [...]-lpos lpos

vector_transform_edp vector_handle lonr latrtransform vector longitude-latitude coordinates to equal distance projection coordinates in place

Time Historiesthistory_add thistory time value

add time/value pair to thistory object

thistory_create maxnp [-tag tag] [-file file]create a thistory object, saving data in file

thistory_eval thistory timereturn value corresponding to time for thistory object

thistory_free {-tag tag | thistory}free thistory object, or all thistories tagged with tag

thistory_get thistory {np|ty it}return information from a thistory object

thistory_maxmin thistoryreturn max and min values for thistory object

Utilitieslatlon2edp latr lonr lat lon

convert latitude-longitude to equal distance projec-tion coordinates

edp2latlon latr lonr delx delyconvert equal distance projection coordinates to lati-tude-longitude

getviewportwcoords viewportName x ytransform a canvas pixel coordinate, x, y, to untrans-formed data world coordinates through viewport viewportName

hls2colorstring hue lightness saturation [gamma]convert color in hue-lightness-saturation[-gamma] to standard X-window rgb color string

Tk Brttplot 37

Page 102: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Plotting(canvas) create viewport name x y ?options?

create canvas window for graph-margin left right bottom topmargin widths in pixels

-anchor {n|ne|e|se|s|sw|w|nw|c}-tags taglist-width width width in pixels (0: rubber-band)

-height height height in pixels (0: rubber-band)

-wtran {none|edp|merc}-latr reference latitude-lonr reference longitude-xmode {lin|log|time} -ymode {lin|log}-xleft x0 data-coordinate of left edge of plot

-xright x1 data-coordinate of right edge of plot

-ybottom ybottomdata-coordinate of bottom edge of plot

-ytop ytop data-coordinate of top edge of plot

-fill color background color for plot region

-fill_frame colorbackground color for margins

38 Tk Brttplot

Page 103: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

(canvas) create axes viewport ?options?create axes associated with viewport-tags taglist-fill_labels colorx and y labels color

-fill_numbers colornumbers color

-fill_axes color axes color

-font_labels fontlabels font

-font_numbers fontnumbers font

-font_numbers_superscripts fontexponent font

-xvisible {0|1} draw and label xaxis ticks

-yvisible {0|1} draw and label yaxis ticks

-linewidth width-linewidth_small width-mindx dx-mindy dy-xincrement dx-xincrement_small dx-xlabel label label along x axis

-xformat {auto|none|time}tick label style

-yincrement dy-yincrement_small dy-ylabel label label along y axis

-yformat {auto|none}tick label style

-axis_style [nesw]*draw these sides of box

-tic_style ([nesw][ioc])* ticks inward, outward, center

(canvas) create grid viewport ?options?canvas item to create a mesh of grid lines-tags taglist-fill color-fill_small color-linewidth width-linewidth_small width-visible {0|1}-visible_x {0|1}-visible_xsmall {0|1}-visible_y {0|1}-visible_ysmall {0|1}-mindx dx-mindy dy-xincrement dx-xincrement_small dx-yincrement dy-yincrement_small dy

Tk Brttplot 39

Page 104: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

(canvas) create polypoint viewport ?options?create item to draw set of points or symbols-vector handle|tagvector containing the points

-tags taglist-symbol {point|cross|x|triangle|square|circle|dia-

mond|star}-fill color fill the symbols with this color

-outline color draw outline in this color

-linewidth width-textforeground color-font font-size size-visible {0|1}-showsymbols {0|1}-showtext {0|1}

(canvas) create polyline viewport ?options?create item drawn with lines-vector handle|tagvector containing the points

-thistory handle|tag-tags taglist-fill color if specified, fill object with color

-outline color draw lines in this color

-linewidth width-label label-visible {0|1}

(canvas) create ptext viewport textstring x y ?options?canvas item to plot text in data coordinates-tags taglist-fill color-font font-visible {0|1}-justification {n|ne|e|se|s|sw|w|nw|c}-angle angle

(canvas) create map viewport ?options?canvas item to plot world maps using equal distance projection-tags taglist-fill_land color-fill_water color-coasts color:linewidth-political index:color:linewidth,...-rivers color-visible {0|1}-resolution {auto|crude|low|intermediate|high|full}

Tk Brttplot 40

Page 105: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Tk Gplpackage require Tkgpl

% man tkgpl

tkgpl pathName widgetNamespace dbpick dbnamecreates a new gatherplot trace display tk widget in the style of dbpick(1)-pf pfname-sc sta:chan-ts_sift tstart_sift-te_sift tend_sift-ts tstart_display-tw twin_display-gaps {segment|zero|interp|none}-maxchannels maximum_channels_in_display-comout comfile-geom WxH+X+Y-stam {css|seed}-trcrm {both|time|none}-ampm {auto|auto0|auto1|autoa}-bg tracewin_background_color-fg tracewin_foreground_color-cr tracecursor_foreground_color-fgcss sta_css_label_foreground_color-fgseed sta_seed_label_foreground_color-fgfil filter_label_foreground_color-bga arrival_background_color-fga arrival_foreground_color-bgsa selected_arrival_background_color-fgsa selected_arrival_foreground_color-timefm time_format_string-datefm date_format_string-phase_default default_phase_code-switchbuttons -noedit -nosort -noshowwfs -noshowarrs -noshowpreds -cliptraces -counts -palign -v

(tkgpl) bind {arrivals2|arrivals3} menuPathnamebinds mouse button events in arrival flags to popup menus

Tk Gpl 41

Page 106: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

gplcolor colornamereturns a legitimate tk color string

Tk Gpl 42

Page 107: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Tk Pixmappackage require Pixmap

pixmap create giffilecreates a new pixmap object from a gif file image

pixmap pixmap_handle widthreturns the width of a pixmap object

pixmap pixmap_handle heightreturns the height of a pixmap object

pixmap pixmap_handle ncolorsreturns the number colors in a pixmap object

(canvas) create pixmap ?options?creates a new canvas item pixmap image from a pix-map object-pixmap pixmap_handle-anchor anchor-tags tags

Tk Pixmap 43

Page 108: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Tk Voglepackage require Vogle

% man tkvogle

Device Related Commandsgraphic widget-name

create graphic widget for drawing

g_init deviceName(re)-initialize the Vogle device deviceName. For example, to initialize the Vogle postscript device.See also: g_newdev, g_getdev, g_exit, g_output, graphic

g_exit deviceNameReset the current Vogle graphics device.

g_output fileNamedirect output to fileName instead of stdout (for post-script)

g_newdev deviceNamere-intialize Vogle to use a new device without changing the current viewport attributes.

g_getdev g_getdev returns the name of the current Vogle graphics device.

g_getdepth g_getdepth returns the number of bit planes for the current device.

General Commandsg_clear

Flood the device with the current color. Clipping areas, viewports, etc. are ignored.

g_color colorNameSet the current color. black 0 red 1 green 2 yellow 3 blue 4 magenta 5 cyan 6 white 7

g_clipping booleanIf boolean is true turn clipping on. If it is false turn clipping off.

Tk Vogle 44

Page 109: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Viewport Commandsg_viewport left right bottom top

set the current viewport using screen coordinates.

g_pushviewport push the current viewport onto the stack.

g_popviewport pop the topmost element from the viewport stack

g_getviewport returns the current viewport {left right bottom top}.

g_getaspect returns the aspect ratio for the current device. (ratio of width to height)

g_getfactors [ width [ height ]]returns the width and height factor of the current device.widthfactor = (widthOfDevice / min(widthOfDe-vice, heightOfDevice))heightfactor = (heightOfDevice / min(widthOfDe-vice, heightOfDevice))

Attribute Stack Commandsg_pushattributes

places a copy of the current attributeList (color, fill-style, hatchstyle, textCentering, textKerning, textHeight, textWidth, and textFont) on the top of the attribute stack.

g_popattributes restores attributes from attribute stack

Projection Commandsg_ortho left right top bottom [ near [ far ]]

Define a parallel projection, 3d if near and far are supplied, 2d otherwise

g_perspective fieldOfView aspect near farSpecify a perspective viewing pyramid in world coordinates

g_window left right top bottom near farSpecify a perspective viewing pyramid in world coordinates

Matrix Stack Commandsg_pushmatrix

push the current transform matrix on the the stack

Tk Vogle 45

Page 110: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

g_popmatrix restore the transformation matrix from the stack

Viewpoint Commandsg_polarview distance azimuth increment twist

specify the viewers position in polar coordinates

g_up ensure the Y axis is pointing up

g_lookat viewX viewY viewZ posX posY posZ twistspecify the viewer position

g_move x y [ z ]move to point x,y,z

g_rmove x y [ z ]moves a displacement x, y, z from current position

g_smove x ymoves to point x,y using screen coordinates

g_rsmove x ymoves a displacement x,y in screen coordinates

Drawing Commandsg_draw x y [ z ]

draw to x, y, z

g_rdraw x y [ z ]draw to current position + x, y, z

g_sdraw x ydraw to x, y in screen coordinates

g_rsdraw x ydraw to current position + x, y in screen coordinates

Arcs and Circlesg_circleprecision numberOfSegments

specify number of line segments to use to draw a circle

g_arc x y radius startAngle endAngledraw an arc with center x, y from startAngle to endAn-gle

g_sector x y radius startAngle endAngledraw a sector with center x, y from startAngle to endAngle

g_circle x y radiusdraw a radius circle with center x, y

Tk Vogle 46

Page 111: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Rectangle and Polygon Commandsg_rect x y x2 y2

draw a rectangle with corners x y and x2 y2

g_polyfill flagturn polygon filling on or off

g_polyhatch flagturn on/off polygon hatching

g_hatchangle angleset the angle for the hatch lines

g_hatchpitch angleset the pitch for the hatch lines

g_poly x y z...xN yN zNconstruct a 3 dimensional polygon

g_poly2 x y...xN yNconstruct a 2 dimensional polygon

g_makepoly starts construction of a polygon constructed with g_move, g_draw

g_closepoly completes construction of a polygon started by g_makepoly

g_backface flagturn on/off culling of backface polygons

g_backfaceclockwise flagif flag is true, direction of backfacing is set to clock-wise; otherwise the direction is counterclockwise

Text Commandsg_font fontName

The following software fonts are supported:astrology cursive cyrillic futura.l futura.m gothic.eng gothic.ger gothic.ita greek japanese markers math.low math.upp meteorology music script symbolic times.g times.i times.ib times.r

g_numchars Return the number of characters in the current font

g_textsize width heightset the maximum size of a character in the current font in world units

g_textangle angleset the text angle

Tk Vogle 47

Page 112: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

g_fixedwidth flagturns fixedwidth text on or off

g_centertext flagif true, text is drawn centered on the current graph-ics position, otherwise left justified

g_getcharsize char [ wVar [ hVar ]]get the width and height of character char

g_fontsize [ wVar [ hVar ]]get the maximum width and height of a character in the current font

g_drawstr stringdraw the text in string at the current position

g_strlength stringreturn the length of string in world units

g_boxtext x y w h stringdraw string to fit in the box with bottom left hand corner at x, y, width w, and height h

g_boxfit w h numberOfCharsset scale for text so that a string of characters in the font fit in box of width w, height h

Transformation Commandsg_identtrans

resets the current transform to the identity matrix. (screen units and world units become equivalent)

g_translate x y [ z ]alter the current transform so points are moved dis-tance x,y,z

g_scale xScale yScale [ zScale ]scale the current transform by xScale, yScale, zScale

g_rotate angle axisrotate the current transform angle degrees around axis: x, y, or z

Point Commandsg_point x y [ z ]

draw a point at x y z in world units

Object Commandsg_makeobj objectID

begin construction of an object with identifier objec-tID

Tk Vogle 48

Page 113: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

g_closeobj close the object begun with the g_makeobj com-mand

g_genobj return a unique objectID identifier

g_getopenobj return identifier for the object currently under con-struction

g_loadobj objectID fileNameload the object in fileName into objectID

g_saveobj objectID fileNamesave the object objectID into fileName

Double Bufferingg_backbuffer

draw in the offscreen buffer

g_frontbuffer draw in the onscreen buffer

g_swapbuffers copy the offscreen buffer to the onscreen buffer

Other Commandsg_getgp [ x [ y [ z ]]]

return current position in world coordinates, option-ally saving in x, y, z

g_toscreen xArg yArg [ xVar [ yVar ]]returns current screen coordinates for device coords xArg, yArg

g_toworld xArg yArg [ xvar yvar ]return the current world coordinates for device coor-dinates xArg yArg

Tk Vogle 49

Page 114: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Tcl/Tk Extensions% man tcl_packages

atcl Tcl shell

awish Tk shell

package require XXX

Tclx

Tkx extended tcl/tk -- variety of extensions to unix func-tions

BLT primarily 2d graphics

Itcl object oriented extensions

Itk object oriented widget extensions

Iwidgets extended widgets

Brttplot extensions for drawing graphs on a tk canvas.

Datascope Datascope database extensions

Dbe extensions for implementing dbe

Orb extensions for reading and writing to an orbserver

Pixmap extension for pixmaps (used in dbevents)

Rtd extension for real time trace display

Rtm extensions for implementing rtm

Ttgrid extensions for the time travel grid file used by orbas-soc and dbgrassoc

Vogle 3-d graphics extension for "Very Ordinary Graphics Library"

Tcl/Tk Extensions 50

Page 115: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Datascope PHP Interfacedl( 'Datascope.so' );

% man datascope_php

Opening a Databaseds_dbopen(database, permissions)

returns a database pointer to the database

ds_dbopen_database(database, permissions)returns a database pointer to the database or table

ds_dbopen_database(database, permissions)returns a database pointer to the specified table ("-" for stdin)

dblookup($db, database, table, field, row)returns a database pointer for the specified database, table, field, and row.

ds_dbtmp($schema)return a database pointer to a temporary database of the specified schema

ds_dbcreate($filename [, $schema [, $dbpath [, $descrip-tion [, $detail]]]])

create a database descriptor in the specified filename

ds_dbclose($db)close a database

dbfree($db)free memory for a database view

dbdestroy($db)destroy all tables of a database

dbtruncate($db, $nrecords)truncate a database table to the specified length

dbdelete($db)delete rows from a database

dbmark($db)mark rows for deletion

dbcrunch($db)remove marked (null) rows from a database table

Manipulating Fields and Recordsdbaddv($db, field_name, value, [field_name, value, ...])

add a new row with the specified values to the data-base

dbaddnull($db)add a new null row to the database.

Datascope PHP Interface 51

Page 116: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dbadd($db [, $record])add a new row to the database from the scratch record or from the specified string.

dbputv($db, field_name, value, [field_name, value, ...])change the fields for an existing row to the specified values

dbput($db [, string])put a raw field or an entire record into database from the scratch record [or the specified string]

dbgetv($db, field_name [, field_name, ...])returns the values of the specified fields for a partic-ular rows

dbget($db [, 0])get a raw field or an entire record database from the [or load it into the scratch record]

dbadd_remark($db, remark)add comment in remark table for the specified row

dbget_remark($db)get any comment from remark table for the specified row

db2xml($db [, string flags [, string rootnode [, string rown-ode [, array fields [, array expressions]]]]])

returns an XML structure corresponding to a view

Forming Viewsdbprocess($db, commands)

returns a new view which is the result of applying the dbprocess commands to the input view; possible operations are: dbopen, dbjoin, dbgroup, dbleftjoin, dbnojoin, dbselect, dbseparate, dbsever, dbsort, dbsubset, dbtheta, dbungroup

dbsort($db [, -u][, -r][, key, key, ...])sort a view by the specified fields

dbgroup($db, key [, key, ...])group the input view according to the specified keys

dbungroup($db)separate a grouped view into its component rows

dbsubset($db, expression)returns a new view which is the set of all rows which satisfy the expression

dbbase($db, tablename)returns the row of the specified base table corre-sponding to the row in the input view

Datascope PHP Interface 52

Page 117: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dblist2subset($db [, list])returns a new view with the listed records, or with the range indicated by the input grouped bundle if no list is specified

dbget_range($db)returns the index of the first, and one plus the index of the last element in a range of rows represented by a database pointer

dbseparate($db, table)returns a view containing records from the specified table that are in the input view

dbsever($db, table)return a view that omits the specified table

dbjoin($db1, $db2, ['-outer'], [join-keys])create a new view from the input views, using join keys if specified

dbtheta($db1, $db2, [expression])create a new view with all combinations of rows, matching expression if specified

dbnojoin($db1, $db2, [join-keys])return view with all rows in db1 which don't join to db2

dbunjoin($db, database)create a new database from the records of the input view

dbwrite_view($db, $filename)save a database view to a file

dbread_view($filename [, $viewname])read a database view from the given filename

dbsave_view($db)save a database view as part of the database

Handling Waveform Datatrloadchan($db, t0, t1, sta, chan)

load a channel of waveform data into a Datascope trace object

trsample($db, t0, t1, sta, chan [, apply_calib])load a channel of waveform data into a PHP array of alternating epoch-time and data-value

trsamplebins($db, t0, t1, sta, chan, binsize [, apply_calib])same as trsample, but the data points are grouped into bins of binsize samples and the epoch-time,min,max for each group is returned

Datascope PHP Interface 53

Page 118: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

trapply_calib($tr)multiply waveform data in trace object by calib value

trextract_data($tr)extract waveform data into a PHP array

trdata($tr [, i0 [, npts]])extract waveform data into a PHP array, specifying the starting index $i0 and maximum number of points to return if desired

trdatabins($tr, binsize [, i0 [, npts]])same as trdata, but the data points are grouped into bins of binsize samples and the min, max for each group is returned

trsplit($tr)break up waveform records at marked bad data

trsplice($tr)splice together data segments

trfilter($tr, filter)filter data in-place according to the given filter-description string

trfree($tr)free a Datascope trace-object structure

trdestroy($tr)destroy a Datascope trace-object structure

trtime2samp(double time0, double samprate, double time1)

find the index of a sample given its timestamp

trsamp2time(double time0, double samprate, int isamp)find the timestamp of a sample given its index

trsamprate(double time0, int nsamp, double endtime)find the sample rate of a time-series given its other attributes

trnsamp(double time0, double samprate, double endtime)find the number of samples in a time-series given its other attributes

trendtime(double time0, double samprate, int nsamp)find the end-time of a time-series given its other attributes

Error Handlingelog_init(argc, argv)

Initialize the elog message routines

elog_log(msg)save message on the elog message log

Datascope PHP Interface 54

Page 119: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

elog_debug(msg)send a debug message to the elog facility

elog_notify(msg)send a notification message to the elog facility

elog_alert(msg)send an alert message to the elog facility

elog_complain(msg)send a complaint to the elog facility

elog_die(msg)send a fatal message to the elog facility and exit

elog_string(n)return error log starting with message n

elog_clear()clear the elog message log

elog_mark()return the count of messages currently held in the error log

elog_flush(deliver, first)eliminate log messages after first, printing them if deliver is set

elog_callback(replacement)replace the standard elog processing with the named PHP replacement function (this function takes two arguments, an integer severity code and a string con-taining the log messages, and returns an integer which, if nonzero, will cause the log to be cleared)

Miscellaneous Datascope Functionsdbquery($db, code)

query the database for information, e.g. dbquery($db, "dbRECORD_COUNT"). see Datas-cope Constants for valid query codes.

dbnrecs($db)query the database for number of records in a table or view (same as dbquery for dbRECORD_COUNT)

dbex_eval($db, expression)evaluate expression for a particular row

dbcompile($db, string)dynamically add new attributes or relations to the schema

dbnextid($db, id_name)get the next free id value for the specified id_name

Datascope PHP Interface 55

Page 120: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dbinvalid()return a database pointer of dbINVALID

dbstrtype($db, string)classifies string, returning "strREAL", "strINTE-GER", "strNULL", "strSTRING", "strTIME", "str-FIELD", or "strUNKNOWN"

dbextfile($db [, base-table])return the filename for an external file for a particu-lar row in a view

dbfind($db, expression, [, first [, reverse]])find a record matching an expression

dbmatches($dbk, $dbt, $hookname [, join-keys])return row numbers of records in $dbt that match the single row $dbk

Parameter Files pfget(pfname, key)

return the value for the key from the parameter file pfname

pfget_boolean(pfname, key)return 0 or 1 depending on the value of key in the parameter file pfname

pfupdate(pfname)reread a parameter file if necessary

pffiles(pfname [, all])List the files which make up a parameter file object. If all is specified and nonzero, list all possible filena-mes, including non-existent files.

pf2string(pfname)return a string representation of a parameter file object

pfrequire(pfname, atime)require pf_revision_time from last file pfname to be later than atime

pfcompile(string, pfname)convert the specified string into a parameter file object

pfput(key, value, pfname)insert key/value pairs into a parameter file object

pfdel(pfname, key)remove the specified parameter from a parameter file object, returning the value

pfwrite(filename, pfname)write a parameter file object to the specified file

Datascope PHP Interface 56

Page 121: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

pf2xml(pfname [, flags [, prolog [, name]]])convert a parameter file to xml

Time Conversionstrtdelta(dt)

convert the time-difference dt (in seconds) to a string, eg "30:35 minutes"

strtime(epoch)convert an epoch time to a string date and time

strydtime(epoch)convert an epoch time to a string date and time including julian day

strdate(epoch)convert an epoch time to a string date

strlocaltime(epoch)convert an epoch time to a string date and time in local timezone

strlocalydtime(epoch)convert an epoch time to a string date and time including julian day, in local timezone

strlocaldate(epoch)convert an epoch time to a string date in local time-zone

now()return epoch time according to local system clock

is_epoch_string(timestring)return an epoch time equivalent of a valid timestring, or an empty result if translation fails

epoch2str(epoch, format [, timezone])return a string equivalent of an epoch time, option-ally converting to the specified timezone

str2epoch(timestring)return the Unix epoch-time equivalent of a time string

epoch(yearday)return the Unix epoch-time equivalent of an integer julian day

yearday(epoch)return the integer julian-day corresponding to the given epoch time

Datascope PHP Interface 57

Page 122: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Instrument Response Routinesdbresponse(filename)

return a PHP resource representing the response curve in $filename

eval_response($response, omega)return a two-element array of the real and imaginary response at $omega

Special Functionsyesno(s)

return -1 for yes,ok,true,1,y,on,t; 0 for no,n,false,0,off,f; 1 otherwise

makedir(d)make the complete directory path

make_pathdirs(f)make the complete directory path assuming the last element is a filename

datafile(env, file)find the specified file by looking first at the environ-ment variable, then along the path

datapath(env, dir, file, suffix)find the specified file by looking first at the environ-ment variable, then along the path

abspath(a)return the absolute path to the specified file

relpath(from,to)return the path to the file 'to' relative to the directory 'from'

cleanpath(p [, nolinks])return the path resolving any relative elements, and symbolic links if requested

concatpaths(a, b)properly concatenate two path elements

parsepath(a)split a pathname into directory, filename base, and suffix (if present)

grn(lat, lon)return geographic region number based on location

grname(lat, lon)return geographic region name based on location

srn(lat, lon)return seismic region number based on location

Datascope PHP Interface 58

Page 123: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

srname(lat, lon)return seismic region name based on location

Foreign Keys map between CSS3.0 station/channel naming conventions and the dif-ferent conventions of autodrm and SEED.

sta = map_autodrm_netsta(anet, fsta)

chan = map_autodrm_chanaux(sta, fchan, aux)

(anet, fsta) = autodrm_net(sta)

(fchan, aux) = autodrm_aux(sta, chan)

sta = map_seed_netsta(snet, fsta)

chan = map_seed_chanloc(sta, fchan, loc)

(snet, fsta) = seed_net(sta)

(fchan, loc) = seed_loc(sta, chan)

finit_db($db)cause foreign key routines above to use specified database $db

Datascope PHP Interface 59

Page 124: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Orb PHP Interface dl( 'Orb.so' );

% man orb_php

orbopen(name, perm)open an orbserver connection

orbclose(orbfd)close an orbserver connection

orbping(orbfd)return the version number of the orbserver

orbtell(orbfd)return the pktid of the orbserver's current position

orbposition(orbfd, from)return the pktid after repositioning the orb to the position specified by the 'from' string ('newest', 'old-est', or any str2epoch(3) time string)

orbseek(orbfd, which)return the pktid after repositioning the orb to the specified packet (given either as a packet-id or as one of ORBCURRENT, ORBPREV, ORBNEXT, ORBNEXT_WAIT, ORBOLDEST, ORBNEWEST)

orbwait(orbfd, re, mintime, timeout)wait for clients matching the specified regular expression all to have read packets younger than mintime, optionally limited by a timeout. Returns 0 if no wait is necessary, positive if a wait was neces-sary, and negative if an error occurred (including expiration of timeout)

orbafter(orbfd, time)return the pktid after repositioning the orb to the next packet after the specified time. The time must be in epoch seconds

orbselect(orbfd, regex)subset the source-names for those matching regex

orbreject(orbfd, regex)reject the source-names matching regex

(pktid, srcname, time, packet, nbytes) = orbreap(orbfd)get the next packet from the orb

(pktid, srcname, time, packet, nbytes) = orbreap_nd(orbfd)

get the next packet from the orb, returning if none is available

Orb PHP Interface 60

Page 125: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

(pktid, srcname, time, packet, nbytes) = orbreap_timeout(orbfd, maxseconds)

get the next packet from the orb, returning if timeout is exceeded

(pktid, srcname, time, packet, nbytes) = orbget(orbfd, which)

get a single packet from the orb, specified as in orb-seek

orbput(orbfd, srcname, time, packet, nbytes)put a single packet on the orb

pktid = orbputx(orbfd, srcname, time, packet, nbytes)put a single packet on the orb and return the packetid

pktstring = orbpkt_string(srcname, time, packet, nbytes)return an forb(5) representation of an orb packet

(result, pkt) = unstuffPkt(srcname, time, packet, nbytes)unstuff a single packet, returning a result code and a packet objectkind kind of packet---- --------------Pkt_wf waveform packetPkt_st status packetPkt_db database rowPkt_pf parameter filePkt_cn control messagesPkt_rw binary dataPkt_ch character stringPkt_tp test packet

The packet object has the following methods which return various values from the c Packet structure: parts, time, PacketType, nchannels, channels(i), pf, string, db, dfile, and version.The parts method returns (net, sta, chan, loc, suffix, subcode)The PacketType method returns the packet kind (also returned by unstuffPkt) and the corresponding description.The channels method takes an index (0..n-1) argu-ment and returns channel object with its own meth-ods:calib calper chan cuser1 cuser2 data duser1 duser2 iuser1 iuser2 iuser3 loc net nsamp samprate segtype sta time

The data method returns all the waveform data in a list of integers.

Orb PHP Interface 61

Page 126: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

orbstat(orb)Get the standard status values from the orb; this return an object with the following methods:address closes connections errors host maxdata maxpkts maxsrc messages nclients nsources opens orb_start pid port rejected started version when who

(when, sources ) = orbsources(orb)return the query time and a list of source objects, one object per source. Each object has the following methods:active nbytes npkts slatest slatest_time soldest soldest_time srcname

(when, clients) = orbclients(orb)return the query time and a list of client objects, one object per client. Each object has the following methods:address bytes errors fd host lastpkt lastrequest mymessages nreads nreject nrequests nselect nwrites packets perm. pid pktid port priority read reject select started thread what who

pforbstat(orbfd, flags)create a nested PHP array containing orb metadata

split_srcname(srcname)split an orb source-name into net,sta,chan,loc,suf-fix,subcode

join_srcname(net, sta, chan, loc, suffix, subcode)return an orb source-name created from the compo-nent pieces provided

(name, content, desc ) = suffix2pkttype(suffix)return name, content type and description for a given packet-type suffix

Orb PHP Interface 62

Page 127: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

PHP System Information dl( 'sysinfo.so' );

% man sysinfo_php

my_ip()return ip address (eg, 209.193.47.96)

my_os()return os name (eg, SunOS)

my_hardware()return hardware string (eg, sun4u)

my_hostname()return hostname (eg, yukon)

ip2name(ipaddress)translate a dot-notation IP address to hostname

name2ip(hostname)translate a hostname to dot-notation IP address

ip(ipaddress)translate a dot-notation IP address to equivalent plain-integer address

pidexecname(pid)return the executable name for a process-id

pidcmdline(pid)return the command line for a process-id

pidpwd(pid)return the process working directory for a process-id

pid_exists(pid)return true if the given process-id is running

pidinfo(pid)return an associative array of statistics for a process-id

nomem(address, nbytes)test a memory address for validity, returning the first bad address if the location is invalid, zero otherwise

sysloadavg()return 1, 5, and 15-minute system load-averages and number of processes

sysmem()return an associative array with total, used, and physical memory in MB

sysmounted()return mount-point, file-system type, remote host, and remote source for all mounted filesystems

PHP System Information 63

Page 128: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

syscpu()return the number of cpus, then percent of time spent in idle, user, kernel, iowait, and swap for the first cpu, then for successive cpu's if present

statvfs(path)return an associative array with filesystem informa-tion about a path

PHP System Information 64

Page 129: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

Matlab Interface

Getting Helpdoc antelope

launch web-browser with html documentation

helpwin antelopelaunch Matlab help tool

help antelopestandard Matlab help

help antelope/exampleslist of example scripts using Antelope toolbox

doc COMMAND_NAMEweb-browser help on specified command

helpwin COMMAND_NAMEMatlab help-tool help on specified command

help COMMAND_NAMEstandard Matlab help for specified command

Initializationsetup_antelope

Set the Matlab path to point to the Antelope tools, examples, and scripts

Opening a DatabaseDBPTR = dbopen(FILENAME, OPENTYPE)

open a Datascope Database

DBPTR = dblookup(DBPTR, DATABASE, TABLE, FIELD, RECORD)

aim a Datascope database pointer as specified

DBPTR = dblookup_table(DBPTR, TABLE)aim a Datascope database pointer at a specified table

dbclose(DBPTR)close a Datascope database

Manipulating Fields and FecordsS = db2struct(DBPTR [, FIELD [, FIELD, ... ]])

convert a database view to a Matlab structure array

RECORD_NUMBER = dbadd(DBPTR, RECORD)add a record to a Datascope database

RECORD_NUMBER = dbaddnull(DBPTR)add a null record to a Datascope database

dbaddv(DBPTR, FIELD, VALUE [, FIELD, VALUE ... ])add values to a Datascope database

Matlab Interface 65

Page 130: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

dbcrunch(DBPTR)crunch out null rows in a Datascope database table

dbdelete(DBPTR)delete the specified record in a Datascope database

RECORD = dbget(DBPTR [, 'dbSCRATCH'])get a table, record, or field from a database

[VALUE, VALUE, ...] = dbgetv(DBPTR, FIELD [, FIELD, ...])

get the specified values from a Datascope database

DBPTR = dbinvalid()create an invalid database pointer

dbmark(DBPTR)set the specified Datascope database rows to null

dbput(DBPTR, VALUE)put the specified value into a Datascope database

dbputv(DBPTR, FIELD, VALUE [, FIELD, VALUE ... ])put the specified values into a Datascope database

Forming Viewsdbfree(DBPTR)

Free resources used by a Datascope database view

DBPTR = dbjoin(DBPTR1, DBPTR2 [, PATTERN1 [, PATTERN2]] [, 'outer'])

join the specified Datascope database tables

DBPTR = dbnojoin(DBPTR1, DBPTR2 [, PATTERN1 [, PATTERN2]])

find records in DBPTR1 which do not join with DBPTR2

DBPTR = dbprocess(DBPTR, STATEMENT_LIST)construct a view as a series of standard operations

DBPTR = dbgroup(DBPTR, GROUPFIELDS, [TYPE])group a sorted table by the specified fields

DBPTR = dbungroup(DBPTR)ungroup a grouped database view into its compo-nent records

DBPTR = dbsort(DBPTR [, FIELD, FIELD,...])sort the specified Datascope database table

DBPTR = dbsubset(DBPTR, EXPRESSION)subset a Datascope database table

DBPTR = dblist2subset(DBPTR [, LIST])create a new subset view given a list of record num-bers

Matlab Interface 66

Page 131: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

DBPTR = dbtheta(DBPTR1, DBPTR2 [, EXPRESSION] [, 'outer'])

theta-join two Datascope database tables

dbunjoin(DBPTR, OUTPUT)unjoin the specified Datascope database view

dbsever(DBPTR, TABLE)remove a table from a joined view

dbseparate(DBPTR, TABLE)extract a subset view of a base table from a joined view

DBPTR = dbread_view(FILENAME [, VIEWNAME])read a Datascope database view from a file

dbsave_view(DBPTR)save a datascope database view in the main database

dbwrite_view(DBPTR, FILENAME)write a datascope database view to the specified file

Getting Information About the DatabaseDBPTR = dbjoin_keys(DBPTR1, DBPTR2

**or**DBPTR, TABLE1, TABLE2)show the inferred join keys between two database tables

QUERY_RESULT = dbquery(DBPTR, CODE)query a Datascope database for various parameters

NRECS = dbnrecs(DBPTR)get the number of records in a Datascope table or view

Evaluating ExpressionsRESULT = dbeval(DBPTR, EXPRESSION [, TYPE])

evaluate an expression on a Datascope database

Handling Waveform DataENDTIME = tr_endtime(TIME, SAMPRATE, NSAMP)

calculate endtime from time, sample rate, and num-ber of samples

N = tr_nsamp(TIME, SAMPRATE, ENDTIME)calculate number of samples from time, sample rate, and endtime

TIME1 = tr_samp2time(TIME0, SAMPRATE, N_INDEXED_BY_1)

calculate sample time from sample index

Matlab Interface 67

Page 132: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

SAMPRATE = tr_samprate(TIME, NSAMP, ENDTIME)calculate sample rate from time, endtime, and num-ber of samples

N_INDEXED_BY_1 = tr_time2samp(TIME0, SAM-PRATE, TIME1)

calculate sample index from sample time

trapply_calib(TRPTR)multiply trace-object waveform data by calib value

trdestroy(TRPTR)free trace object and its associated memory

DATA = trextract_data(TRPTR)read a copy of data from a trace object into a matrix

trfilter(TRPTR, FILTER_STRING)apply time-domain filters to trace data

trfree(TRPTR)free memory for part of a trace object

[DATA, NSAMP, T0, T1] = trgetwf(DBPTR [, REQS, REQE])

read trace data from database into matrix

trinsert_data(TRPTR, DATA)put data from a Matlab matrix into a trace-object

TRPTR = trload_css(DBPTR, TIME, ENDTIME [, TRPTR] [, TABLE])

load waveform data from CSS database into trace object

TRPTR = trload_cssgrp(DBPTR, TIME, ENDTIME [, TRPTR] [, TABLE])

load waveform data from grouped CSS database into trace object

TRPTR = trnew()create a new trace-object

trputwf(DBPTR, DATA)save waveform data into a file

trrotate(TRPTR, PHI, THETA, NEWCHANS)three-component rotation of trace object

trrotate_to_standard(TRPTR, NEWCHANS)rotate three-component trace data to standard coor-dinates

trsave_wf(TRPTR, DBPTR, DATATYPE, WFNAME [, 'overwrite' | 'append'])

save trace-object waveform data to a new database

trsplice(TRPTR, TOLERANCE)splice together data segments

Matlab Interface 68

Page 133: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

trwfname(DB [, PATTERN])generate external file names

S = tr2struct(TR)Generate an exportable structure of waveform data

Error Handlingclear_register([ 'print' ])

clear the Datascope error register

elog_init([ARGV0])initialize the error-logging facility

elog_log(MSG)save a message on the elog message log

elog_alert(MSG)

elog_complain(MSG)

elog_debug(MSG)

elog_notify(MSG)send alert, complain, debug, notify message to the elog facility

elog_die(MSG)send message to the elog facility and kill the Matlab interpreter

elog_clear()clear the elog message log

elog_flush(DELIVER, FIRST)eliminate log messages after the FIRST, printing them if DELIVER is set

elog_mark()return the count of messages currently held in the error log

elog_string(N)return error log starting with message N

Instrument Response RoutinesR = dbresponse(FILE)

dbresponse class constructor

RESPONSE = eval_response(DBRESPONSE, OMEGA)dbresponse evaluation routine

RESPONSE_PARTS = parse_response(DBRESPONSE)return internal contents of a response object

DIFFERENT = compare_response(DBRESPONSE1, DBRESPONSE2)

dbresponse comarison routine

Matlab Interface 69

Page 134: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

clear(DBRESPONSE)dbresponse elimination routine

free_response(DBRESPONSE)dbresponse elimination routine

Computational-geometry GridsCGG = cggrid(FILE)

CGG = cggrid(X, Y, Z)cggrid (Computational-geometry grid) class con-structor

DX = cggrid_dx(CGG)x-spacing for cggrid object

DY = cggrid_dy(CGG)y-spacing for cggrid object

NX = cggrid_nx(CGG)number of points in x-direction for cggrid object

NY = cggrid_ny(CGG)number of points in y-direction for cggrid object

[TRIPLETS, NX, NY] = cggrid_get(CGG)get ordered triplets representing cggrid object

[X, Y, Z] = cggrid_getmesh(CGG)get X,Y,Z coordinate meshes representing cggrid object

VAL = cggrid_probe(CGG, X, Y)probe the cggrid for the value at a given point

cggrid_write(CGG, FORMAT, FILE)write a cggrid object to a file

cggrid2db(CGG, DBPTR, RECIPE_NAME, GRID_NAME, OUTPUT_FILE, FMT, UNITS, QGRIDTYPE, AUTH [, 'overwrite'])

write a cggrid object to a database

cggrid_free(CGG)cggrid elimination routine

Parameter FilesPF = dbpf()

PF = dbpf(PFNAME)

PF = dbpf(PF, STRING)dbpf (Parameter File) class constructor

STRING = pf2string(DBPF)convert a parameter file object to a string

STRUCT = pf2struct(DBPF [, 'recursive' ])convert a parameter file object to a Matlab struct

Matlab Interface 70

Page 135: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

FILENAMES = pffiles(PFNAME [, 'all' ])list file corresponding to parameter file PFNAME

clear(DBPF)dbpf elimination routine

pffree(DBPF)dbpf elimination routine

RESULT = pfget(DBPF, NAME [, 'recursive' ])get a generic parameter from a parameter file object

PF = pfget_arr(DBPF, NAME [, 'recursive' ])get an associative array from a parameter file object

BOOLEAN = pfget_boolean(DBPF, NAME)get a boolean value from a parameter file object

NUM = pfget_num(DBPF, NAME)get a numeric value from a parameter file object

STRING = pfget_string(DBPF, NAME)get a string from a parameter file object

LIST = pfget_tbl(DBPF, NAME [, 'recursive' ])get an ordered list from a parameter file object

KEYS = pfkeys(DBPF)find the parameter names in a parameter file object

NAME = pfname(DBPF)find the name of a top-level parameter file object

pfput(DBPF, NAME, VALUE)put a value into a parameter file object

pfput_boolean(DBPF, NAME, VALUE)put a boolean value into a parameter file object

RESULT = pfresolve(DBPF, NAME [, 'recursive' ])alternate interface to retrieve parameters

TYPESTRING = pftype(DBPF)find the type of a parameter file object

[PF, MODIFIED] = pfupdate(DBPF)refresh a Dbpf object to reflect changes in the file

pfwrite(DBPF, FILENAME)save a parameter file object to a file

Real-time System ConnectionsPKTID = orbafter(ORBFD, TIME)

set ORB connection to first packet after a specified time

orbclose(ORBFD)close a connection to an Antelope object-ring-buffer

Matlab Interface 71

Page 136: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

[RESULT, TIME, SRCNAME, PKTID, TYPE] = orb-get(ORBFD [, CODE|PKTID])

get packets from an Antelope ORB connection

ORBFD = orbopen(ORBNAME, OPENTYPE)open a connection to an Antelope object-ring-buffer

VERSION = orbping(ORBFD)ask for the version number of an Antelope ORB server

[RESULT, TIME, SRCNAME, PKTID, TYPE] = orbreap(ORBFD [, 'nodelay'])

get successive packets from an Antelope ORB con-nection

NSOURCES = orbreject(ORBFD, REGEX)reject sources on an Antelope ORB read connection

PKTID = orbseek(ORBFD, CODE **or**PKTID)set an ORB Read connection to the specified posi-tion

NSOURCES = orbselect(ORBFD, REGEX)select sources on an Antelope ORB read connection

PKTID = orbtell(ORBFD)ask for the current read-position on an Antelope ORB

Seismic Travel Times[SLOWNESS, PHASENAMES] = arr_slowness(DELTA,

DEPTH)Returns predicted seismic phase slownesses in sec/km

[TIMES, PHASENAMES] = arrtimes(DELTA, DEPTH)Returns predicted seismic phase arrival times

Special Functionsdbadd_remark(DBPTR, REMARK)

add a remark to a CSS3.0 database table

[FILENAME STATUS] = dbextfile(DBPTR, TABLE-NAME)

Compose a filename from the specified Datascope database record

[FILENAME STATUS] = dbfilename(DBPTR)compose a filename from a database record

IRECORD = dbfind(DBPTR, EXPRESSION [, FIRST [, COUNT]] [, 'backwards'])

locate a database row satisfying some condition

Matlab Interface 72

Page 137: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Scripting Reference

REMARK = dbget_remark(DBPTR)get a remark from a CSS3.0 database table

ID = dbnextid(DBPTR, IDNAME)get the next integer id for id field from a database

[DIR, BASE [,SUFFIX]] = parsepath(PATH)separate a pathname into component parts

Time ConversionTIMESTRING = epoch2str(EPOCH, FORMAT)

convert epoch time to a string

EPOCH = str2epoch(TIMESTRING)convert a string to epoch time

STRDATE = strdate(EPOCH)convert an epoch time to its corresponding date

STRTDELTA = strtdelta(EPOCH)convert an epoch time difference to an elapsed time

STRTIME = strtime(EPOCH)convert an epoch time to a string date and time

STRYDTIME = strydtime(EPOCH)convert an epoch time to a string date and time, including day of year

YEARDAY = yearday(EPOCH)convert an epoch time to a yearday value

TIMESTRING = zepoch2str(EPOCH, FORMAT, TZ)convert epoch time to a string, specifying time-zone

MiscPID = getpid()

get the process-id of the calling process

Matlab Interface 73

Page 138: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

CompiledLanguagesInterfaces

Page 139: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Contents

libstock : General Utilities ................................ 1

libcoords : Time and Space ........................... 25

libds : Database Operations .......................... 27

libtr : Waveform Manipulation ........................ 32

libtrvltm : Travel Times ................................... 39

libresponse : Instrument Response ............... 40

liborb : Orbserver Access .............................. 41

libPkt : Orb Packets ....................................... 44

libpforbstat : Orb Status Parameter Files....... 46

libxtra : Miscellaneous ................................... 47

libbrttpkt : Packet Processing ........................ 48

libbrttutil : BRTT Utilities ................................ 52

libmappts : Map Data Utilities ........................ 55

libproj : Map Projections ................................ 57

libtks : Tk Send IPC ....................................... 60

libwffil : Filter Waveforms ............................... 61

libwffilave : Averaging Filters ......................... 62

libwffilbrtt : BRTT Filters ................................ 63

Fortran Interfaces .......................................... 64

Page 140: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libstock : General Utilities implements variety of general purpose programming utilities

include "stock.h"ldlibs=$(STOCKLIBS)

Parameter Filesint pfread(char *name, Pf **pf)

read parameter space name into pf, returning 0 for success.

int pfupdate(char *name, Pf **pf)check files which compose parameter space name, reread and return 1 if changed; on first read, pf must = 0

Tbl *pffiles(char *name, int all)return list of files which compose name

int pfload(char *env, char *dir, char *fname, Pf **pf)read single parameter file found by datapath(3) into pf

int pfcompile(char *s, Pf **pf)read parameter space from string s into pf

int pfwrite(char *fname, Pf *pf)write parameter space pf to the file fname

int pfin(FILE *in, Pf **pf)read parameter space from file in into pf

int pfout(FILE *out, Pf *pf)write parameter space pf to file out

char *pf2string(Pf *pf)return new string representation of pf

Pf *pfnew(int type)start a new parameter space

void pffree(Pf *pf)free resources for pf

Pf *pfdel(Pf *pf, char *name)remove branch for name from pf, returning the deleted branch

int pfconfig("ask", char *(*askx)(char*))replace default &ask routine with new version askx

int pfget(Pf *pf, char *name, void **result)put value for name from pf in result, returning type

libstock : General Utilities 1

Page 141: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int pfresolve(Pf *pf, char *name, int create, Pf **result)put value for name from pf into result, allowing extended syntax like arr{name}[3], returning type

int pfeval(Pf *pf, char *name, char **result)put value for name from pf into result, allowing extended syntax like arr{name}[3], but returning only scalar values

int pfget_boolean(Pf *pf, char *name)return boolean value for name from pf

double pfget_double(Pf *pf, char *name)return double value for name from pf

long pfget_int(Pf *pf, char *name)return integer value for name from pf

char *pfget_string(Pf *pf, char *name)return string value for name from pf

double pfget_time(Pf *pf, char *name)return epoch time for name from pf

double pfget_size(Pf *pf, char *name)return size for name from pf, interpreting suffix of G (10^9), M (10^6), or k (10^3)

Tbl *pfkeys(Pf *arr)return list of keys for pf arr

Arr *pfget_arr(Pf *pf, char *name)return array value for name from pf

Tbl *pfget_tbl(Pf *pf, char *name)return list value for name from pf

long pfmaxtbl(Pf *list)return the number of elements in the pf list

void pfput(Pf *pf, char *name, void *value, int t)put a value (of type t) into pf under name

int pfset(Pf *pf, char *name, char *value)put a character value into pf under name, allowing extended syntax like arr{name}[3]

void pfput_boolean(Pf *pf, char *name, int value)put boolean value into pf under name

void pfput_double(Pf *pf, char *name, double value)put double value into pf under name

void pfput_int(Pf *pf, char *name, long value)put integer value into pf under name

void pfput_string(Pf *pf, char *name, char *value)put string value into pf under name

2 libstock : General Utilities

Page 142: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

void pfput_time(Pf *pf, char *name, double time)put readable time into pf under name

void pfput_arr(Pf *pf, char *name, Arr *value)put array value into pf under name

void pfput_tbl(Pf *pf, char *name, Tbl *value)put list value into pf under name

int pfcmp(Pf *pf1, Pf *pf2)return 0 if pf1 and pf2 are identical, 1 otherwise

Pf *pfdup(Pf *old)duplicates(clones) a parameter file space

int pfrequire(char *pfname, char *atime)require pf_revision_code later than atime

Associative ArraysArr *newarr(int (*cmp)(char*, char*))

create a new associative array with string compare routine cmp; if cmp=0, use strcmp().

Arr *duparr(Arr *arr, void *(*adup)(void*))return duplicate (clone) of the array arr using the adup routine to duplicate individual values.

int freearr(Arr *arr, void (*afree)(void*))free array arr, calling afree on each value of the array

void *setarr(Arr *arr, char *key, void *val)set the value for key in arr to val, returning previous value

void *getarr(Arr *arr, char *key)return the value for key in arr

void *delarr(Arr *arr, char *key)delete the key, value pair for key in arr, returning value

long cntarr(Arr *arr)return the number of key, value pairs in arr

Tbl *keysarr(Arr *arr)return list of all the keys in arr

Tbl *valsarr(Arr *arr)return list of all the values in arr

int applyarr(Arr *arr, void (*f)(char *key, void *value, void *p), void *p)

apply function f to each key, value pair in arr

Tbl *arrgrep(Arr *arr, char *s)match each key of arr as a regular expression against string s, returning list matching keys

libstock : General Utilities 3

Page 143: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Tbl *greparr(char *re, Arr *arr)return list of all keys in arr which match regular expression re

ListsTbl *newtbl(long n)

return a new list with n elements

Tbl *inittbl(long left, long right, int direct, void *null, int sz)

return a new direct list with specified null value and elements of sz bytes

void freetbl(Tbl *tbl, void (*tfree)(void*))free memory used by list tbl, calling tfree on each element

long maxtbl(Tbl *tbl)return number of elements in list tbl

Tbl *duptbl(Tbl *tbl, void *(*tdup)(void*))return duplicate (clone) of the list tbl using the tdup routine to duplicate individual elements.

void clrtbl(Tbl *tbl, void (*tfree)(void*))empty an existing list tbl, calling tfree on each ele-ment

void trunctbl(Tbl *tbl, long last, void (*tfree)(void*))shorten a list tbl to contain only last elements, call-ing tfree on other elements

long settbl(Tbl *tbl, long index, void *value)set element #index of list tbl to value

void *gettbl(Tbl *tbl, long index)return value for element #index of list tbl

long instbl(Tbl *tbl, long index, void *value)insert element value at position index of list tbl, shift-ing other element to the right

void *deltbl(Tbl *tbl, long index)delete element #index from list tbl, returning the deleted element

void *poptbl(Tbl *tbl)remove last element from list tbl, returning that ele-ment

void *shifttbl(Tbl *tbl)remove first element from tbl, returning that element

long pushtbl(Tbl *tbl, void *value)append an element value to the end of the list tbl

long unshifttbl(Tbl *tbl, void *value)insert an element value at the front of the list tbl

4 libstock : General Utilities

Page 144: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int filetbl(char *name, char *id, long n, void *null, int sz, Tbl **tbl)

read or create a list in file name with n elements of sz bytes, returning the tbl

Tbl *readtbl(char *name, char **id, int rw)read a list from file name

int savetbl(Tbl *tbl, char *name, char *id)write a list tbl to file name

Tbl *greptbl(char *re, Tbl *tbl)search each element of list tbl with regular expres-sion re, returning new list of matching rows

Tbl *tblgrep(Tbl *tbl, char *s)considering each element of list tbl as a regular expression, return a new list of elements which match string s

void sorttbl(Tbl *tbl, int (*cmp)(char*, char*, void*), void *pvt)

sort a list tbl using the comparison function cmp

long searchtbl(char *key, Tbl *tbl, int (*cmp)(char*, char*, void*), void *pvt, long *ns, long *ne)

search a sorted list tbl for key using a binary search and comparison function cmp; return count and range ns <= i <= ne of matches

int applytbl(Tbl *tbl, int (*f)(void*, void*), void *pvt)apply function f to each elements of list tbl

Tbl *strtbl(char *s1, ...)create a new list from a variable argument list of strings, terminated with NULL

char *jointbl(Tbl *tbl, char *s)return a new string containing all elements of list tbl, separated by string s.

long cattbl(Tbl *dst, Tbl *src)append list src to list dst

int cmptbl(Tbl *tbl1, Tbl *tbl2)return 0 if lists tbl1 and tbl2 are identical

int newmorphtbl(Tbl *list, Morphtbl **map)create a new Morphtbl: a list of patterns and substi-tutions

int morphtbl(char *old, Morphtbl *map, int flags, char *r)apply the patterns and substitutions in map to the string old, leaving the result in r. flags may contain MORPH_PARTIAL and/or MORPH_ALL. if MORPH_PARTIAL is set, the pattern need not match the entire string. if MORPH_ALL is set, all

libstock : General Utilities 5

Page 145: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

the patterns are applied; otherwise replacement stops at the first matching pattern

void freemorphtbl(Morphtbl *map)free Morphtbl map

Sorted ListsStbl *newstbl(int (*cmp)(void *a, void *b))

create a new sorted list

void *addstbl(Stbl *stbl, void *key)add an element key to sorted list stbl

void *delstbl(Stbl *stbl, void *key)delete element key from sorted list stbl

int freestbl(Stbl *stbl, void (*sfree)(void*))free sorted list stbl, calling sfree for each element

void *getstbl(Stbl *stbl, long i)return i'th element from sorted list stbl

void *tststbl(Stbl *stbl, void *key)test if element corresponding to key exists in sorted list stbl

long maxstbl(Stbl *stbl)return the number of elements in sorted list stbl

Tbl *tblstbl(Stbl *stbl)return list of all elements in a sorted list (should be freed with freetbl(tbl,0))

int applystbl(Stbl *stbl, int (*f)(void*, void*), void *pvt)call function f for each element of sorted list stbl

Id MapsStbl *newidmap(void)

create a new id map, mapping one set of positive integers to another

void freeidmap(Stbl *map)free idmap map

long idset(Stbl *map, long key, long x)set the value of key in map to x; any previous value for key is returned, or -1

long idget(Stbl *map, long key)return the value of key in map, or -1 if it's not set

Bit VectorsBitvector *bitnew()

create a new bit vector

6 libstock : General Utilities

Page 146: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

void bitfree(Bitvector *b)free a bit vector

int bitclr(Bitvector *b, long index)clear bit index of bit vector b

int bitset(Bitvector *b, long index)set bit index of bit vector b

int bittst(Bitvector *b, long index)test bit index of bit vector b

long bitmax(Bitvector *b)return current allocated size of b

Bitvector *bitnot(Bitvector *b)return the bitwise NOT of b

Bitvector *bitand(Bitvector *b1, Bitvector *b2)return the bitwise AND of b1 and b2

Bitvector *bitor(Bitvector *b1, Bitvector *b2)return the bitwise OR of b1 and b2

Bitvector *bitxor(Bitvector *b1, Bitvector *b2)return the bitwise eXclusive-OR of b1 and b2

int bitcmp(Bitvector *b1, Bitvector *b2)compare two bit vectors

Simple Ring BufferRingBuffer *openring(char *filename, char *id, int depth,

int flags)open (or create) a simple ring buffer in filename with size depth

int newring(char *filename, char *id, int depth, int flags)create (or reinitialize) a simple ring buffer in file-name with size depth

void closering(RingBuffer *rb)close the ring buffer rb

int pushring(RingBuffer *rb, double time, double value)push a time/value pair onto the ring buffer rb

int getring(RingBuffer *rb, int i, double *time, double *value)

get the i'th time/value pair from the ring buffer rb

int countring(RingBuffer *rb)return the number of pairs in the ring buffer

double maxring(RingBuffer *rb, double tdelta, int *index)return the maximum value and its index within tdelta from the ring buffer rb

libstock : General Utilities 7

Page 147: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

double minring(RingBuffer *rb, double tdelta, int *index)return the minimum value and its index within tdelta from the ring buffer rb

double avgring(RingBuffer *rb, double tdelta)return the average value over tdelta from the ring buffer rb

int findring(RingBuffer *rb, double value, double tdelta)find the index of ring buffer entry which has the specified value within tdelta entries

int changedring(RingBuffer *rb, double tdelta)return 1 if the value has changed over the period tdelta

Time conversionint is_epoch_string(char *s, double *e)

return true if string s can be interpreted as a time, returning epoch time e

int is_timezone(char *name)returns 1 if file corresponding to name is found, 0 otherwise

double now()return current epoch time, to clock resolution (typi-cally microseconds)

void wait_for_time(double time, int verbose)sleep until specified epoch time

void snooze(double dt)sleep (using nanosleep) for specified dt

char *epoch2str(double e, char *f)return freshly allocated string containing epoch time e formatted according to format f

char *zepoch2str(double epoch, char *f, char *timezone)return freshly allocated string containing epoch time e formatted according to format f for timezone; if tim-ezone == 0, use UTC, if timezone == "", use $TZ

char *strdate(double e)return string representing date portion of epoch time

char *strtime(double e)return string representing epoch time

char *strydtime(double e)return standard string representing epoch time

char *strlocaldate(double e)return string representing date portion of local time-zone time

8 libstock : General Utilities

Page 148: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

char *strlocaltime(double e)return string representing local timezone time

char *strlocalydtime(double e)return string representing local timezone time with yearday

char *strtdelta(double e)return a string representation of elapsed time

double epoch(int yearday)convert yearday to epoch time

long yearday(double e)return yearday corresponding to given epoch time

Error handlingint elog_init(int argc, char **argv)

initialize elog routines

void elog_log(int flag, char *format, ...)save the message specified by sprintf style format and arguments to internal error log; add system error message if flag!=0

void elog_debug(int flag, char *format, ...)

void elog_notify(int flag, char *format, ...)

void elog_alert(int flag, char *format, ...)

void elog_complain(int flag, char *format, ...)deliver the message specified by sprintf style format and arguments, along with any messages on the error log. include system error message if flag!=0

void elog_die(int flag, char *format, ...)

void elog_fault(int flag, char *format, ...)deliver the message specified by sprintf style format and arguments, along with any messages on the error log. include system error message if flag!=0. exit with error code 1

char *elog_string(int first)return new string reproducing the entire error log

char *elogstr(int severity, int flag, char *fmt, ...)return new string corresponding to single elog call, without adding to error log

void elog_clear()clear the log of error messages

int elog_mark()return the number of messages in the error log

libstock : General Utilities 9

Page 149: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

void elog_flush(int deliver, int first)flush elog messages from first, printing them if deliver is non-zero

void elog_truncate(int n)truncate error log to n messages

void elog_print(FILE *file, int first)print the error log from first to the end

int elog_query(enum Elog_code code, int severity, void **value)

retrieve various parameters from elog interface

int elog_set(enum Elog_code code, int severity, void *value)

set various parameters for elog interface

Filename and Path Manipulationint abspath(char *relp, char *absp)

return absolute path absp for the relative path relp

int relpath(char *fromdir, char *tofile, char *relp)return a relative path relp from fromdir to tofile

int cleanpath(char *path, int flags, char *new)remove unnecessary '/', '..', and '.' strings from path, returning the result in new; if flags is 1, resolve inter-mediate symbolic links

char *concatpaths(char *seg1, *seg2, ...)concatenate path segments seg1, seg2, ..., return the result in a new string

int fspath(char *path, char *host, char *filesystem)return host and filesystem corresponding to path

InfoPath *infopath(char *path)return info about path including disk space and inodes available

int freespace(char *path, double mbavail)returns 1 if filesystem where path resides has more than mbavail Mbytes available

int samepath(char *path1, char *path2)returns 1 if path1 and path2 resolve to same file or directory

char *homedir(char *user)return the home directory of the specified user.

unsigned long filesize(char *path)return file size for plain file, 0 otherwise

unsigned int filemode(char *path)return file mode for file path

10 libstock : General Utilities

Page 150: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int is_present(char *path)return 1 if path exists, 0 otherwise

int is_empty(char *path)for plain file, return 1 if file has size zero for direc-tory, return 1 if directory contains no files

int is_file(char *path)return 1 if path is plain file, 0 otherwise

int is_filename(char *path)return 1 if path begins with "/", "./" or "../"; 0 oth-erwise.

int is_writable_file(char *path)return 1 if path is writable or if not present but direc-tory is writable

int is_dir(char *path)return 1 if path is directory, 0 otherwise

int is_nfs(char *path)return 1 if path is on nfs mounted filesystem, 0 oth-erwise

int is_changed(char *path)return 1 on first call and when mod time changes, or zero if file does not exist

int is_timezeone(char *name)return 1 if name is valid time zone

Tbl *dirfiles(char *dir, int flag)return list of files in dir; if flag==1, only files, if flag==2, only dirs

int fstraverse(char *dir, int flag, int (*user)(char*, stat*, void*), void *pvt)

run user routine on each file below dir; flag=FS_ONLY_DIR, FS_ONLY_FILE, FS_DEPTH_FIRST

void parsepath(char *path, char *d, char *b, char *s)separate path into directory d and basename b, and suffix s if s!=0

int makedir(char *dir)make complete directory path dir (like "mkdir -p")

int make_pathdirs(char *path)make all directories to path (like "mkdir -p `dirname path`")

long mapfile(char *name, Arr **arr, char **addr)return memory address addr for file name, mmap-ping it when not present in arr

libstock : General Utilities 11

Page 151: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int unmapfile(char *name, Arr **arr)unmap file name, removing it from arr

int mkfile(char *name, ulong nbytes, char *init, int initsize)make file name nbytes long initialized with the first initsize bytes of init, otherwise zero

Stringsint blank(char *s)

return non-zero if string is entirely spaces

int whitespace(char *s)return non-zero if string is entirely whitespace

void copystrip(char *dest, char *source, long n)copy a string, stripping leading and trailing blanks

void strtrim(char *s)trim leading and trailing whitespace from string s

char *intactline(FILE *file, char **aline, long *size)read entire line from file into resizable buffer aline with current size

void chomp(char *s)remove trailing linefeed from string s if present

void strtr(char *s, char *from, char *to)substitute chars in s using lists in from and to

void str2lower(char *s)

void str2upper(char *s)convert string s to all lower/upper case

char *okstr(char *s)if s != 0, return s otherwise null

void strsub(char *old, char *s, char *sub, char *r)replace all occurences of string s in old with sub, leaving result in r

void regsubstitute(char *old, char *sub, regmatch_t *matches, char *new)

given results matches of regexec, substitute sub in old, returning result in new

int patsub(char *old, regex_t *pat, char *sub, char *r)replace first occurence of regular expression pat in string old with sub, leaving result in r

int nstrcmp(char *a, char *b)return 0 if a==b==0, 1 if only one of a, b is null, oth-erwise strcmp(a,b)

int strmatches(char *s, char *pattern, Hook **hook)return 1 if entire string s matches the regular expres-sion pattern

12 libstock : General Utilities

Page 152: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int strcontains(char *s, char *pattern, Hook **hook, long *start, long *nchars)

return 1 if string s contains the regular expression pattern; the index and number of matching chars nchars are returned.

Tbl *split(char *s, int c)return list of fields of s which are delimited by the char c

void sncopy(char *dst, char *src, long n)copy n chars from string src to dst with no trailing null, padding with spaces if necessary

void szcopy(char *dst, char *src, long n)copy n chars from string src to dst, then append null

char *strconcat(char *s, ...)return the result of concatenating all the input strings (terminate list with NULL)

char *strjoin(int c, char *s, ...)return the result of concatenating all the input strings separated by c (terminate list with NULL)

long pushstrc(void **sbuf, int c)

long pushstrn(void **sbuf, char *s, long n)

long pushstr(void **sbuf, char *s)add the string s (or char c) to the string buffer sbuf, creating sbuf if *sbuf == 0, returning new length

char *popstr(void **sbuf, int sfree)retrieve the entire string from sbuf, freeing sbuf if sfree != 0

char *strdbl(double x, char *buf)formats the input double x into a compact and con-venient string

Sorting and Searchingvoid isort(char *a, long n, int size, int (*cmp)(char*, char*,

void*), void *pvt)sort list a of n elements each size bytes using the comparison function cmp and an insertion sort implementation

void quicksort(char *a, long n, int size, int (*cmp)(char*, char*, void*), void *pvt)

sort list a of n elements each size bytes using the comparison function cmp and a quick sort imple-mentation

libstock : General Utilities 13

Page 153: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

void shellsort(char *a, long n, int size, int (*cmp)(char*, char*, void*), void *pvt)

sort list a of n elements each size bytes using the comparison function cmp and a shell sort implemen-tation

long ssearch(char *key, int keysize, char *index, long nkeys, int unique, int (*cmp)(char*, char*, void*), void *pvt, long *ns, long *ne)

search sorted index for key with binary search, where keys are size bytes and comparison function cmp. return number of matches and the index range ns <= i <= ne of matches. unique indicates index has no duplicate entries

User Interactionchar *ask(char *format, ...)

query user for a response

char *asknoecho(char *format, ...)query user for a response with no echo

int askyn(char *format, ...)query user for a yes/no response

int askynaq(char *format, ...)query user for a yes/no/all/quit response

int yesno(char *s)check string for various ways of meaning yes or no

int fdkey(int fd)tests file descriptor for pending input

int fdwait(int fd, int msec)wait up to msec milliseconds for pending input

int is_tty(int fd)return 1 if fd is open to a terminal, 0 otherwise.

int tty_byline(int fd)

int tty_immediate(int fd)set line protocol buffering mode

int tty_echo(int fd)

int tty_noecho(int fd)set line protocol echo mode

int tty_reset(int fd)reset terminal to initial state (before first tty_* call above)

char *getaline(FILE *file, char *aline, long n)reads a line from file, replacing any terminal linefeed with a null byte

14 libstock : General Utilities

Page 154: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Hexadecimal Dumpsvoid hexdump(FILE *file, void *mem, int n)

write a hex and ascii dump of n bytes of buffer mem

char *hexdump_string(long base, void *mem, int n)return string containing hex dump of buffer mem, labelling the address of mem as base.

int read_hexdump(FILE *file, char *mem, int n)read at most n bytes of a hex dump from file into mem

void asciidump(FILE *file, char *mem, int n)write ascii dump of n bytes of buffer mem, with escaped non-printing chars

int read_asciidump(FILE *file, char *mem, int n)read at most n bytes of a ascii dump from file into mem

void *nomem(void *mem, int n)returns first address in range mem to mem+n that is invalid, 0 otherwise (non-functional in Linux)

int hex2int(char c)return the integer value of a hexadecimal char

int printable(char *mem, int l)return 1 if all l bytes at mem are printable

void printable_string(char *buf, int p, char *mem, int n)copies n bytes from mem to p-byte buf, replacing unprintable chars with hex

long hex2mem(char *hex, void *vmem)convert hexadecimal character string hex into binary in vmem

void mem2hex(void *vmem, int n, char *s)convert n bytes at vmem into hexadecimal character string

Byteswap RoutinesOver 250 routines for byteswapping, with names chosen to indicate source and destination type and architecture, for example: #include "swapbytes.h"

libstock : General Utilities 15

Page 155: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int mf2hd(void *vfrom, double *to, int n)

int uhs2vb(short *from, void *vto, int n)

int vt2hi(void *vfrom, int *to, int n)

int hi2mt(int *from, void *vto, int n) Leading u means unsigned input and output, next 2 chars indicate source architecture and data type, and last 2 chars indicate destination architecture and data type.

Architecture codes h current host a Intel StrongARM. m Motorola/SPARC v Vax/IntelType codes code type bits b byte/char 8 s short 16 t 3-byte 24 i int 32 l long long 64 f float 32 d double 64

char *align_double(char *a)align an address a to a multiple of double

char *align_long(char *a)align an address a to a multiple of long

char *align_int(char *a)align an address a to a multiple of int

Compression and Checksumsint gencompress(uchar **out, int *nout, int *szout, int *in,

int n, int len)compress n input integers in, using run length len, returning result as *nout bytes in *out.

int genuncompress(int **out, int *nout, int *size, uchar *in, int n)

uncompress the n bytes buffer in, returning result as *nout integers in *out.

int ccanada(int *uc, int nuc, char **cmp, int *ncmp, int *cmpsz)

compress nuc integers from uc to "Canadian Com-pression" format, result is *ncmp bytes in buffer *cmp of dynamic size *cmpsz.

16 libstock : General Utilities

Page 156: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int ucanada(char *cmp, int ncmp, int **uc, int *nuc, int *ucsz)

uncompress "Canadian Compression" buffer cmp of ncmp bytes, result is *nuc integers in buffer *uc of dynamic size *ucsz.

int cm6(int *uc, int nuc, char **cmp, long *ncmp, long *cmpsz)

compress nuc integers from uc to plain ascii "GSE AutoDRM CM6" format, result is *ncmp bytes in buffer *cmp of dynamic size *cmpsz.

long um6(char *cmp, long ncmp, int **uc, long *nuc, long *ucsz)

uncompress plain ascii "GSE AutoDRM CM6" for-mat buffer cmp of ncmp bytes, result is *nuc integers in buffer *uc of dynamic size *ucsz.

int gse_checksum(int *uc, int nuc)compute gse checksum over nuc integers in uc for AutoDRM

int cucsd(int *uc, int nuc, char **cmp, int *ncmp, int *cmpsz)

compress nuc integers from uc to UCSD RefTek data logger format, result is *ncmp bytes in buffer *cmp of dynamic size *cmpsz.

int uucsd(int *uc, char **cmp, int ncmp, int nuc)uncompress nuc integers from "UCSD RefTek data logger" format buffer cmp of ncmp bytes, advancing *cmp to the next location after uncompressed data

FILE *gz_cat(char *name)return FILE opened for reading on the output of "zcat name"

FILE *gz_open(char *name)return FILE opened for reading on the uncom-pressed version of name

Convenience Macrosallot(type*, name, n)

malloc space for n (type *) elements, putting the address in name

reallot(type*, name, n)realloc space for n (type *) elements, putting the address in name

allot and reallot both use ALLOTERROR, which may be defined as ALLOTDIE (default), ALLOTCOMPLAIN, ALLOTREGISTER_ERROR, or your own macro

libstock : General Utilities 17

Page 157: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

SIZE_BUFFER(type*, buffer, sizevar, needed)ensure that (type *) buffer (currently allocated with size in sizevar) has space for at least needed elements -- if not, free the old buffer, and malloc a new buffer

RESIZE_BUFFER(type*, buffer, sizevar, needed)ensure that (type *) buffer (currently allocated with size in sizevar) has space for at least needed elements -- if not, realloc the old buffer, copying the current contents

IEEE Arithmeticint is_infinity(double x)

return 1 if x is infinity

int is_denormalized(double x)return 1 if x is denormalized

int is_nan(double x)return 1 if x is nan

int is_negative_infinity(double x)return 1 if x is -infinity

double an_infinity(void)return an infinity

double a_nan(void)return a (quiet) nan

double a_quiet_nan(void)return a quiet nan

double a_signaling_nan(void)return a signaling nan

Local Machine/Architectureint my_hardware(char *hdw)

return processor name (sparc, i386, ..)

int my_hostname(char *name)return hostname

int my_ip(char *hostname, char *ipc, int *ip)return ip address, as integer and in dot notation

int my_os(char *name)return operating system (Solaris, Linux, ...)

int my_username(char *name)return the login id

int ip2name(int addr, char *name)return name corresponding to addr

int name2ip(char *name, struct in_addr *addr, char *ipstr)return ip address for name

18 libstock : General Utilities

Page 158: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int pid_exists(int pid)return 1 if process pid exists, 0 otherwise.

char *pidexecname(int pid)return path to executable for process pid

char *pidcmdline(int pid)return command line for process pid

char *pidpwd(int pid)return working directory for process pid

int pidinfo(int pid, Pidstat *process)return ppid, uid, memory size, resident set size, run state, start time, cpu time for process pid

void syscpu(int *ncpu, CpuUsage **cpu)return user, nice, system and idle time for each cpu

void sysloadavg(double *avg, int *nproc)return 1 minute, 5 minute and 15 minute load aver-ages

void sysmem(double *total, double *physical, double *used)

return size of virtual and actual physical memory, and size of memory in use.

int sysproc(Tbl **procsp)return list of system processes, with pid, uid, ppid, pcpu, state, and cpu time for each

int sysmounted(Tbl **sysmnt)return list of mounted filesystems, with mount point, filesystem type, and remote host and filesystem if mounted remotely.

Environmentint envfile(char *filename)

set environment using list in $ANTELOPE/data/env/filename

int fixup_env(char **list, int n, int force)set environment using list; if force==0, set only unset variables

char *expand_env(char *s)return new string substituting $env or ${env} in s with value from environment

Data File Referenceschar *datafile(char *env, char *file)

return path of filename file in $ANTELOPE/data, perhaps overridden by environment variable env

libstock : General Utilities 19

Page 159: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

char *datapath(char *env, char *dir, char *file, char *sfx)return path of filename file (with suffix sfx) in direc-tory dir under $ANTELOPE/data, perhaps overrid-den by environment variable env

int newdata(char *path, char *env, char *dir, char *file, char *sfx)

return complete path for file (with suffix sfx) in direc-tory dir under $ANTELOPE/data, allowing environ-ment variable env to override

Tbl *datasearch(char *search, char *dir, char *file, int flags)

return paths matching dir/file along the path search. If (flags & 1), expand $name in search; if (flags & 2), return non-existent paths too

State Filesint bury()

save state file, specified by exhume and resurrect calls

int exhume(char *nm, int *stop, int sec, void (*f)(Pf*))recover state file nm, and set up to save new copy. set up interrupt handlers to set flag stop and timer. If timer expires sec seconds later, calls bury and exits.

int resurrect(char *name, Relic value, Relic_type type)recover old value for name from state file, set up to save on later calls to bury. type is INT_RELIC, DOUBLE_RELIC or STRING_RELIC

Buffered Network Stream I/OBns *bnsnew(int fd, long sz)

create a new network stream I/O buffer

void bnsfree(Bns *bns)free space for bns

int bnsclose(Bns *bns)close file descriptor and free space for bns

void bnsuse_sockio(Bns *bns)setup bns to use socket routines rather than read and write

int bnsget(Bns *bns, void *data, int t, long n)get n elements of type t from bns, returning the result in data ; t may be BYTES, TWO_BYTES, INT_FOUR_BYTES, INT_EIGHT_BYTES, FLOAT_FOUR_BYTES, or FLOAT_EIGHT_BYTES

20 libstock : General Utilities

Page 160: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int bnsgetc(Bns *bns, void *data, long mx, int c)search for first char c in input, returning up to mx chars including c

long bnsin(Bns *bns)return count of chars gotten since previous bnsin call

long bnsout(Bns *bns)return count of chars written since previous bnsout call

char *bnsid(Bns *bns, char *id)return existing value, sets to new id if id != 0

int bnsput(Bns *bns, void *data, int t, long n)put n elements of type t from data, into buffer of bns

int bnsflush(Bns *bns)write all data currently in bns buffer

void bnsmark(Bns *bns)save the current read point in the input buffer; keep all data after this mark until bnsrelease

void bnsrelease(Bns *bns)reset mark on the input buffer

void bnsrestore(Bns *bns)back up bns pointer to previous mark

void bnsclr(Bns *bns)wipe clean the bns buffer

long bnscnt(Bns *bns)return count of bytes in bns buffer

int bnseof(Bns *bns)return non-zero when end of file occurs on input

int bnserr(Bns *bns)return non-zero after an error occurs on a bns

int bnserrno(Bns *bns)return any system errno recorded by bns after read or write

long bns2buf(Bns *bns, char *buf, long maxbuf)copy bns buffered data elsewhere

int buf2bns(Bns *bns, char *buf, long nbytes)put data directly into a bns buffer

int bnstimeout(Bns *bns, int milliseconds)set the bns timeout period

int bnswait(Bns *bns)wait until the bns timeout for data to appear

libstock : General Utilities 21

Page 161: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int gbnsSync(Bns *bns, char *sync, int nsync, int strict)read bns input until nsync chars matching sync are encountered

int pbnsSync(Bns *bns, char *sync, int nsync)write nsync chars of sync to bns output

Miscellaneousvoid cbanner(char *version, char *usage, char *author,

char *location, char *email)print header with program name, version, usage, and author contact information

void *usermethod(char *method)return pointer to routine method from libuser.so

int verbose_exists()return 1 if file "verbose" exists, 0 otherwise

Hook *new_hook(void (*hookfree)(void*))create a standard structure which contains a pointer to a free routine and a (void *) pointer

void free_hook(Hook **hook)free a hook structure, first calling the hookfree rou-tine to free the private pointer, and then freeing the structure

int runcmd(char **argv, char **result)execute a command, returning a result and the exit code

void xargs(char *cmd, Tbl *list, char *tail, int verbose)run cmd repeatedly on elements of list until list is exhausted. tail is appended to each command; ver-bose causes each to be printed.

double sz2dbl(char *size)takes input like 10k and return 10000 -- knows G, M, k, u and m

void *memdup(void *a, long n)return pointer to copy of n bytes of memory at address a

int xlatname(char *name, Xlat *xlat, int nxlat)return number corresponding to name in translation table xlat

char *xlatnum(int num, Xlat *xlat, int nxlat)return name corresponding to number in translation table xlat

void fill_random(char *buffer, int nbytes, int *position)fill a buffer with random values

22 libstock : General Utilities

Page 162: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int check_random(char *buffer, int nbytes)compare a buffer previously filled with fill_random with the values expected.

int set_random(int nbytes)set the size of the check_random internal buffer

double disordered()uniform [0,1] pseudo random number

int legit_ip(char *pfname, unsigned int ip, char **limit)

int legit_ip_pf(Pf *pf, unsigned int ip, char **limit)

int legit_fd(char *pfname, Pf **pf, int fd, char **limit)compare input ip address to list of valid_ip_addresses (and optional list of rejected_ip_addresses) in pf, returning 1 if valid, and remainder of matching line in limit

int units_convert(double x, char *x_units, char *want, double *y, char *y_units)

convert input value x x_units to units want, leaving result y y_units

Tbl *units_match(char *x_units)return a list of all units which match x_units (except x_units)

Signatures

int sgsign(char *signer, char *data, int nbytes, char *signa-ture)

computes a signature for nbytes of data using method dictated by signer

int sgverify(char *signer, char *data, int nbytes, char *sig-nature)

verifies the signature for nbytes of data using method dictated by signer

Reading Files with mmapint gxopen(char *filename)

return fd for filename using mmap

int gxclose(int fd)closes fd (unmaps file)

int gxline(int fd, char *aline, int maxchars)return line from file

int gxseek(int fd, int p)seeks to position p in file

int gxtell(int fd)return current position in file

libstock : General Utilities 23

Page 163: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int gxpipe(char *cmd, char **env, int *cmdin)execute cmd with environment env, cmdin is fd for stdin of cmd

24 libstock : General Utilities

Page 164: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libcoords : Time and Space 2-d and 3-d coordinate transformations, and seismic region routines

include "coords.h"ldlibs=$(STOCKLIBS)

Earth Units conversiondouble deg2km(double degrees)

convert from degrees at equator to kilometers

double km2deg(double km)convert from kilometers to degrees at equator

Flinn-Engdahl Regionsint grnumber(double lat, double lon)

return Flinn-Engdahl geographic region number which contains lat, lon

int grname(int grn, char *name)return Flinn-Engdahl geographic region name for geographic region grn

int srnumber(int grn)return Flinn-Engdahl seismic region number for geographic region grn

int srname(int srn, char *name)return Flinn-Engdahl seismic region name for seis-mic region number srn

Spherical Geometrydouble deg(double r)

convert input radians r to degrees

double rad(double d)convert input degrees d to radians

void dist(double lat1, double lon1, double lat2, double lon2, double *delta, double *azimuth)

return angular distance delta and direction azimuth between two points (lat1,lon1) and (lat2,lon2) (angles in radians)

void latlon(double lat1, double lon1, double delta, double azimuth, double *lat2, double *lon2)

return new position (lat2,lon2) after moving delta radians in direction azimuth from (lat1,lon1) (angles in radians)

void dcarsph(double u[3], double *ra, double *dec)convert a unit 3-vector u to ra and dec (radians)

libcoords : Time and Space 25

Page 165: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

void dsphcar(double ra, double dec, double u[3])convert ra and dec (in radians) to cartesian coords u

void deatom(double a, double b, double c, double m[9])convert Euler angles a, b, c to rotation matrix m

void dmtoea(double m[9], double *a, double *b, double *c)convert rotation matrix m to Euler angles a, b, c

void rotmat(double u[3], double A[9], double theta)create matrix A which rotates by angle theta about axis u

void xrotate(double u[3], v[3], w[3], theta)rotate v by angle theta about axis u, returned in w

void dr3add(double u[3], double v[3], double w[3])add two 3-vectors u and v

void dr3cros(double u[3], double v[3], double w[3])return cross product w of two 3-vectors u and v

double dr3dot(double u[3], double v[3])return dot product of two 3-vectors u and v

double dr3mag(double u[3])return length of a 3-vector

void dr3mov(double u[3], double v[3])move a vector u to a vector v

void dr3mxm(double A[9], double B[9], double C[9])multiply two 3x3 matrices A and B, returning result C

void dr3mxv(double A[9], double u[3], double v[3])multiply 3x3 matrix A by 3-vector u, returning vec-tor v

void dr3norm(double u[3])make u a unit vector

void dr3ortho(double u[3], double v[3])makes u and v orthonormal vectors

void dr3sub(double u[3], double v[3], double w[3])subtracts v from u, returning result w

void dr3sxv(double c, double v[3], double w[3])multiply 3-vector v by scalar c, returning result w

26 libcoords : Time and Space

Page 166: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libds : Database Operations implements the Datascope relational database system

include "db.h"ldlibs=$(DBLIBS)

typedef struct Dbptr {long database ;

long table ;

long field ;

long record ;

} Dbptr ;

Opening/Closing a Database

int dbopen(char *path, char *p, Dbptr *db)open database path with permission p ("r" or "r+"), return database pointer db

long dbopen_database(char *path, char *p, Dbptr *db)open database or table path, return database pointer db

long dbopen_table(char *path, char *p, Dbptr *db)open table path, return database pointer db

Dbptr dblookup(Dbptr db, char *d, char *t, char *f, char *r)

return database pointer for database d, table t, field f, and first row where field f==r

int dbcreate(char *path, char *schema, char *dbpath, char *description, char *detail)

create new database descriptor file path

Dbptr dbtmp(char *schema)create temporary database using schema

int dbclose(Dbptr db)close database db

Adding and Retrieving Valueslong dbadd(Dbptr db, char *r)

add row r to table db, return new record number

long dbadd_remark(Dbptr db, char *r)add comment r to CSS table db

long dbaddnull(Dbptr db)add null row to table db

libds : Database Operations 27

Page 167: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

long dbaddv(Dbptr db, char *t, char *f1, v1, ... NULL)add new row to table db/t, with values v1,... for cor-responding fields f1, ... ; terminate list with zero. return record number of new row (or existing matching row), or negative result if no row can be added

int dbget(Dbptr db, char *s)get row (or field or whole table) from database into s

int dbgetv(Dbptr db, char *t, char *f1, &v1, ... NULL)read values from row db/t for fields f1, ..., return cor-responding values in v1, ...; terminate list with NULL. return -1 if problem occurs.

int dbget_remark(Dbptr db, char **remark)get comment from row db of CSS tables, into new string remark

int dbput(Dbptr db, char *s)put row (or field or whole table) from s into data-base/table/field/row db

int dbputv(Dbptr db, char *t, char *f1, v1, ... NULL)write values v1, ... to corresponding fields f1, ... in database row db. terminate list with zero.

int dbselect(Dbptr db, Tbl *l, FILE *f)for each row in view db or range (db.record to db.field), print value of expressions in list l to file f.

Removing and Deleting Rowsint dbdelete(Dbptr db)

delete row db from view

int dbmark(Dbptr db)mark row db by setting all fields to NULL value

int dbcrunch(Dbptr db)remove marked (all null) rows from table db

int dbtruncate(Dbptr db, long n)truncate table db to first n rows

int dbdestroy(Dbptr db)remove descriptor file and each table in database db.

Manipulating and Saving ViewsDbptr dbsubset(Dbptr db, char *s, char *name)

create new view with rows from db which satisfy expression s

28 libds : Database Operations

Page 168: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Dbptr dbjoin(Dbptr db1, Dbptr db2, Tbl **keys1, Tbl **keys2, int outer, Tbl **nojoin, char *name)

return new joined view from two input views db1 and db2. Uses keys keys1 and keys2, or inferred join keys. Return join keys used and list nojoin of db1 rows which did not join. Setting outer causes every row in db1 to appear in output view, joined to null record for db2 if necessary.

Dbptr dbnojoin(Dbptr db1, Dbptr db2, Tbl **keys1, Tbl **keys2, char *view_name)

return view of rows from view db1 which do not match row in view db2.

long dbmatches(Dbptr db1, Dbptr db2, Tbl **keys1, Tbl **keys2, Hook **hook, Tbl **t)

return in t list of row from db2 matching row db1. hook is used by dbmatches for specific join; it must =zero at first call, is freed with free_hook when done.

Dbptr dbtheta(Dbptr db1, Dbptr db2, char *s, int outer, char *name)

return joined view of rows from db1 and db2 where expression s, evaluated against trial join of two rows, is non-zero.

Dbptr dbseparate(Dbptr db, char *tablename)creates new subset of base table tablename, contain-ing only rows which participate in input view db

Dbptr dbsever(Dbptr db, char *t, char *name)remove table t from joined view db, return new view

Dbptr dbsort(Dbptr db, Tbl *t, int f, char *name)sort input view db according to list t of fields or expressions; sort uniquely if f & dbSORT_UNIQUE is true; reverse sort order if f & dbSORT_REVERSE is true.

Dbptr dbgroup(Dbptr db, Tbl *fields, char *name, long type)

return view in which each row references groups of 1 or more adjacent rows of input view db, where all fields in list for each group are identical.

Dbptr dbungroup(Dbptr db, char *name)return view containing all rows referenced in input grouped view db

Dbptr dbprocess(Dbptr db, Tbl *operations, Dbptr (*unknown)())

construct new view using list of operations, which may include: dbopen, dbjoin, dbgroup, dbleftjoin,

libds : Database Operations 29

Page 169: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbnojoin, dbselect, dbseparate, dbsever, dbsort, dbsubset, dbtheta, dbungroup

Dbptr dblist2subset(Dbptr db, Tbl *t)convert list t of rows for view db to subset view

int dbread_view(FILE *f, Dbptr *db, char *name)read database view from open file f, return new data-base pointer in db. Return dbINVALID if unsuc-cessful.

int dbwrite_view(Dbptr db, FILE *f)write database view db to open file f.

int dbsave_view(Dbptr db)save database view db to file named according to view and database name

int dbunjoin(Dbptr db, char *name, int rewrite)using base table rows referenced in view db, write new tables (files) to an output database name. fails if any output tables are already present, unless rewrite is non-zero, in which case old tables are replaced.

int dbuntangle(Dbptr db, Arr **a)return an array a indexed by table with lists of rows present in view db

void dbfree_untangle(Arr *a)free array a of lists of rows returned by dbuntangle

int dbfree(Dbptr db)free space taken by database view: specify db.table. base tables and views referenced by other views should not be freed.

Dbptr dbbase(Dbptr db, char *table)returns the base table dbptr for a record of a join/subset/sort view

void dbget_range(Dbptr db, long *s, long *e)get row number range from grouped view bundle pointer

int dbcopy(Dbptr dbin, Dbptr dbout, Arr *expressions)copy rows field by field from table dbin to table dbout, translating fields as indicated by array expres-sions.

Evaluating Database Expressionsint dbex_compile(Dbptr db, char *s, Expression **e, int

type)compile string s as database expression, return com-piled representation e. type may be dbBOOLEAN, dbINTEGER, dbREAL, dbTIME, dbYEARDAY, or

30 libds : Database Operations

Page 170: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

dbSTRING (forcing result type) or 0 letting result type be dictated by expression

int dbex_eval(Dbptr db, Expression *e, int f, void *v)evaluate expression e for database row db. If flag f is non-zero, allow expression to change field values in row.

int dbex_free(Expression *e)free database expression e

int dbex_evalstr(Dbptr db, char *s, int type, void *v)evaluate string s as an expression for database row db, convert result to type, return result v

long dbfind(Dbptr db, char *string, int flags, Hook **hook)search for row matching string in view db, where string is regular expression, Datascope expression, or plain string. if flags&1, search backward.

int dbstrtype(Dbptr db, char *s)return strREAL, strINTEGER, strNULL, str-STRING, strTIME, strEXPR, strFIELD, or strUN-KNOWN, indicating how s might be evaluated

External Filesint dbextfile(Dbptr db, char *table, char *p)

compose path p using dir and dfile from database row db; specify table when view db contains multiple tables with dfile.

int dbfilename(Dbptr db, char *filename)compose filename from dir/dfile in database row db, creating directories if needed

Managing Ancillary Informationint dbquery(Dbptr db, int code, void *value)

return variety of information for database pointer db (see Datascope Constants)

Tbl *dbtables(Dbptr db, char *f)return list of tables which use field f

int dbcompile(Dbptr db, char *s)compile some fragment of schema, to add new rela-tions and perhaps attributes to schema

Dbptr dbinvalid()return database pointer with all elements set to dbINVALID

long dbnextid(Dbptr db, char *name)generate unique id for field name of database db

libds : Database Operations 31

Page 171: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

libtr : Waveform Manipulation implements routines for reading and writing waveforms from a data-base, and performing some standard operations on them.

include "tr.h"ldlibs=$(TRLIBS)

Trace ObjectsDbptr trnew(char *tr_path, char *schema_name)

create a new trace database

int trcopy(Dbptr *trout, Dbptr trin)copy trace table from trin to trout, duplicating data and records

int trfree(Dbptr tr)free up memory and clear trace object tables

int trdestroy(Dbptr *trp)close a trace database and free its resources

int trtruncate(Dbptr tr, long n)truncate a tr database table after record n

Reading and Writing Waveformsint trgetwf(Dbptr db, Arr **maparr, float **data, long

*datasz, double reqt0, double reqt1, double *t0, double *t1, long *npts, int (*fill)(), void *pvt)

read waveform data for single record db between times reqt0 and reqt1 into buffer data, returning #points npts and actual time range t0 to t1. returns 0 for success

void trgetwf_error(Dbptr db, int code)add error message to log for trgetwf errors

int trload_css(Dbptr db, char *reqt0, char *reqt1, Dbptr *trp, char *table, Arr **map)

load waveform data between reqt0 and reqt1 from all records in database view db into trace table trp

int trload_cssgrp(Dbptr db, char *reqt0, char *reqt1, Dbptr *trp, char *table, Arr **map)

load waveform data between reqt0 and reqt1 from pre-sorted database view or bundle db into trace table trp

Dbptr trloadchan(Dbptr db, double t0, double t1, char *sta, char *chan)

read waveform data for specified sta and chan from db for time range t0 to t1

32 libtr : Waveform Manipulation

Page 172: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int trloadwf(Dbptr db, double t0, double t1, Dbptr tr)read waveform data for specified database record from t0 to t1 into tr

int trsave_wf(Dbptr tr, Dbptr db, char *dt, char *wf, int flags)

save waveform data from tr to database db creating waveforms of specified datatype dt in data files named by trwfname(3) using the pattern wf. trAP-PEND flag bit causes data to be appended to exist-ing files; trOVERWRITE flag bit causes data to overwrite existing files.

int trwfname(Dbptr db, char *wf, char **path)generate waveform file name for database row db using specified pattern wf and creating any non-exis-tent directories.

Network, Aux and Loc Code Remapping Autodrm and SEED introduce extra keys to uniquely identify station and channel. These extra keys must be mapped into sta and chan to work with the CSS3.0 schema. These routines implement that map-ping.

int finit_db(Dbptr db)set the database the routines below use to look up snetsta and schanloc

int refinit_db(Dbptr db)change the database the routines below use to look up snetsta and schanloc

int map_autodrm_netsta(char *anet, char *fsta, char *sta)

map an autodrm net anet and station code fsta to a CSS3.0 sta code

int autodrm_net(char *sta, char *anet, char *fsta)return autodrm network code anet and station code fsta corresponding to CSS3.0 sta code

int map_autodrm_chanaux(char *sta, char *fchan, char *aux, char *chan)

map an autodrm channel fchan and aux code into a CSS3.0 chan code for station sta

int autodrm_aux(char *sta, char *chan, char *fchan, char *aux)

return autodrm channel code fchan and aux code cor-responding to CSS3.0 sta/chan

int map_seed_netsta(char *snet, char *fsta, char *sta)map a SEED net and station code into a CSS3.0 sta code

libtr : Waveform Manipulation 33

Page 173: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int seed_net(char *sta, char *snet, char *fsta)return seed network code snet and station code fsta corresponding to CSS3.0 sta code

int map_seed_chanloc(char *sta, char *fchan, char *loc, char *chan)

map a SEED channel fchan and loc code into a CSS3.0 chan code for station sta

int seed_loc(char *sta, char *chan, char *fchan, char *loc)return seed channel code fchan and loc code corre-sponding to CSS3.0 sta/chan

Generating Test Data

int trsignal_argv(Dbptr tr, int argc, char **argv)generate test signal data in a trace table

int trsignal(Dbptr tr, char *params)generate test signal data in a trace table; params is split into an argc/argv list

void mksignal(char *type, Trsample *data, double time, long nsamp, double samprate, double t0, double freq, double slew, double amp)

generate a signal of a specified type: type may be sin, cos, sqr, tri, saw, dlt, ran, stp, pkt or dif. creates floating-point numbers.

void imksignal(char *type, int *data, double time, long nsamp, double samprate, double t0, double freq, double slew, double amp)

generate a signal of a specified type. creates integers.

Miniseed and Steim CompressionMsd *msdnew()

create new configuration block for miniseed genera-tion

void msdfree(Msd *msd)free miniseed configuration block

int msdclose(Msd *msd)close the file descriptor with msd

int msdget(Msd *msd, int code, void *val, ...)get a parameter from msd struct

int msdput(Msd *msd, int code, void val, ...)set a parameter in msd struct

The possible parameter names are:

34 libtr : Waveform Manipulation

Page 174: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

MSD_ACTIVITY_FLAGS MSD_CHAN MSD_CNT MSD_DATAFORMAT MSD_FD MSD_FILENAME MSD_FIRST_DATA_FRAME MSD_FRAMES_PER_RECORD MSD_HAS_B100 MSD_HAS_B1000 MSD_HAS_SEED_HEADER MSD_IO_FLAGS MSD_LEVEL MSD_LOC MSD_MSEED MSD_MSEED_NBYTES MSD_NET MSD_NSAMP MSD_OFFSET MSD_QUALITY_FLAGS MSD_RECORD_SIZE MSD_SAMPRATE MSD_SAMPRATE_FLAGS MSD_SEQUENCE MSD_SPARC_ORDER MSD_STA MSD_TIME MSD_TIME_CORRECTION

int msd2wf(Msd *msd, Dbptr db, int (*add_wfdisc)(Dbptr, char*, char*, Wfdisc*))

reads through a miniseed volume with msdnxt(3), calls add_wfdisc whenever a new data segment is found

int msdnxt(Msd *msd)read header of next input record

int msdrec(Msd *msd, long rec)read header of input record #rec

int dmsd(FILE *file, Msd *msd, int verbose)print headers for a miniseed data block (in detail if verbose=1)

void msdpackhdr(Msd *msd, unsigned char *record)create a miniseed header in record using info from msd

int umsd(Msd *msd, int **data, long *npts)unpack the msd data record, returning the samples

int cmsd(Msd *msd, int (*save_record)(Msd*, long, long), int *data, long npts)

compress integer data into miniseed

int ustc(Msd *msd, int **data, long *npts)uncompresses a single Steim level 1 or level 2 mini-seed record

int cstc(Msd *msd, int (*save_record)(Msd*, long, long), int *data, long npts)

compresses the npts input sample data into a mini-seed record that is accumulated inside the msd struct, and written by save_record when full. npts=0 flushes msd.

libtr : Waveform Manipulation 35

Page 175: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

int dstc(FILE *file, char *rcd, int nbytes)prints out a single Steim compressed miniseed record

Filtersint trfilter(Dbptr tr, char *f)

apply time-domain filters f to trace data tr

int trfilter_segs(int n, int *nsamp, double *dt, float **data, char *f)

apply time-domain filters f to n waveform segments

int trfilter_pkt(int nsamp, double dt, float *data, char *f, Hook **hook)

apply time-domain filters f to data, retaining state in hook

int trrotate(Dbptr tr, double phi, double theta, char **newchan)

rotate three component data

int rotate_to_standard(Dbptr tr, char **newchan)rotate three component data to standard orientation

int trapply(Dbptr tr, int (*filter)(), void *pvt)apply filter routine to each waveform segment

int trapply_calib(Dbptr tr)multiply waveform data in trace object by calib value

int trdemean(Dbptr tr)subtract mean (DC) value from trace

int trdemean_seg(Dbptr tr)subtract mean (DC) value from trace segment

int trderiv(Dbptr tr)compute derivative of trace data

int trintegral(Dbptr tr)integrate waveform segments

Utilitieslong trclip(double time, double samprate, long nsamp, dou-

ble from, double until, long *pt0, long *npts, double *t0, double *t1)

find sample range corresponding to time range

36 libtr : Waveform Manipulation

Page 176: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int trsplit(Dbptr tr, int (*fill)(Dbptr*, Trsample*, long*, long*, long*), int (*findbad)(Trsample*, long, char*, Tbl*))

break up waveform records, eliminating marked missing data

int trsplice1(Dbptr tr, int factor_calib, double tolerance, int (*fill)(Dbptr *dbp, Trsample *data, long *i0, long *i1, long *imaxp), int (*resample)(Dbptr*, Trsam-ple*, Trsample*, long, Dbptr*, Trsample*, long*, double*, double*))

splice together any data segments which fit together, eliminating overlapping portions. don't splice sec-tions with different calibs together if factor_calib is 0.

int trsplice(Dbptr tr, double tolerance, int (*fill)(Dbptr *dbp, Trsample *data, long *i0, long *i1, long *imaxp), int (*resample)(Dbptr*, Trsample*, Trsample*, long, Dbptr*, Trsample*, long*, dou-ble*, double*))

splice together any data segments which fit together, eliminating overlapping portions. splice sections with different calibs together, multiplying later val-ues by the ratio of calibs.

double traligned(double atime, double std_time, double std_samprate)

returns a time properly aligned with a specific time and sample rate

void trfill_gap(Trsample *data, long nsamp)fills a data segment with the 'standard' "t4" gap value

long wfchanid(Dbptr db)lookup chanid for a wfdisc record in the sensor or sitechan table

long arrchanid(Dbptr db)lookup chanid for an arrival record in the sensor or sitechan table

int trlookup_segtype(char *segtype, char **units, char **desc)

returns units and description for a segtype code

Wftype *trwflist(int i)return the i'th waveform type

Wftype *trwftype(char *datatype)get waveform type structure for specified type

libtr : Waveform Manipulation 37

Page 177: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Convenience Macrosdouble ENDTIME(t0, samprate, nsamp)

return endtime based on input parameters

int NSAMP(t0, samprate, endtime)return number of samples based on input param-eters

double SAMP2TIME(t0, samprate, n)return a sample time given a sample index

double SAMPRATE(t0, nsamp, endtime)return samprate based on input parameters

int TIME2SAMP(t0, samprate, t1)return a sample index given a time

int TRCONTIGUOUS(t0, t1, samprate, nsamp)test whether a segment of nsamp samples begin-ning at t0 with sample rate samprate abut to t1, within the tolerance specified in trdefaults.pf.

int TRSAMERATE(samprate0, samprate1)test whether certain values of sample rate are the same to within the tolerance specified in trde-faults.pf.

int TRSAMETICKS(t0, t1, samprate)test whether two values of time are on the same tick marks, within the tolerance specified in trde-faults.pf.

int TRSAMETIME(t0, t1, samprate)test whether two values of time are the same to within the tolerance specified in trdefaults.pf.

38 libtr : Waveform Manipulation

Page 178: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libtrvltm : Travel Times provides generic interface for various travel time calculators

include "tt.h"ldlibs=-ltrvltm $(STOCKLIBS)

int ttcalc(char *method, char *model, char *phase, int flags, TTGeometry *geom, Tbl **times, Hook **hook)

return travel times using specified method and model for phase given 3d source and receiver in geom

int ucalc(char *method, char *model, char *phase, int flags, TTGeometry *geom, Tbl **slows, Hook **hook)

return slowness values using specified method and model for phase given 3d source and receiver in geom

The following routines use the ttcalc and ucalc routines above and the ttmethod and ttmodel from trvltm.pf.

int arrtimes(double delta, double depth, char ***phases, double **times)

return all calculated phases and travel times for spec-ified delta (degrees) and depth (km)

int arr_slowness(double delta, double depth, char ***phases, double **slowness)

return all calculated phases and slowness values for specified delta (degrees) and depth (km)

double phasetime(char *phase, double delta, double depth)return the arrival time for the specified phase, delta (degrees) and depth (km)

double phase_slowness(char *phase, double delta, double depth)

return the slowness value for the specified phase, delta (degrees) and depth (km)

double pphasetime(double delta, double depth)return the first P arrival time for specified delta (degrees) and depth (km)

double pphase_slowness(double delta, double depth)return the slowness for the first P arrival for speci-fied delta (degrees) and depth (km)

double sphasetime(double delta, double depth)return the first S arrival time for specified delta (degrees) and depth (km)

double sphase_slowness(double delta, double depth)return the slowness for the first S arrival for speci-fied delta (degrees) and depth (km)

libtrvltm : Travel Times 39

Page 179: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libresponse : Instrument Response routines for reading, writing and evaluating CSS 3.0 response files

include "response.h"ldlibs=$(STOCKLIBS)

Response *new_response()initialize a new response object

int get_response(char *filename, Response **rsp)read response from file filename into rsp

int read_response(FILE *file, Response **rsp)read a response from open file into rsp

int save_response(char *filename, Response *rsp)write response rsp to file filename

int write_response(FILE *file, Response *rsp)write a response to a file

int free_response(Response *rsp)free memory for a response

void init_response_group(Response_group *gp)initialize a new Response_group object

int add_response_group(Response *rp, Response_group *gp)

add a new response stage gp to response rp

int compare_response(Response *r1, Response *r2)compare two responses r1 and r2, returning 0 if identical, 1 otherwise

int eval_response(double omega, Response *rsp, double *r, double *i)

evaluate a response rp at the frequency omega, returning real and imaginary components r and i.

libresponse : Instrument Response 40

Page 180: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

liborb : Orbserver Access routines which implement the orb protocol

include "orb.h"ldlibs=$(ORBLIBS)

int orbopen(char *name, char *p)open a connection to the orbserver name, with per-mission p = "r" or "w", with "&" appended to cause reconnections; returns orb or -1 for failure

int orbclose(int orb)close the orbserver connection orb

int orbselect(int orb, char *re)select packets from orb which match the regular expression re

int orbreject(int orb, char *re)reject packets from orb which match the regular expression re

int orbafter(int orb, double t)set the read position for connection orb after the specified time t

int orbposition(int orb, char *w)set the read position for connection orb according to string w, which may be an epoch time or "newest" or "oldest".

int orbseek(int orb, int which)set the read position for connection orb according to the which code: ORBPREV, ORBNEXT, ORBNEXT_WAIT, ORBOLDEST, ORBNEWEST.

int orbresurrect(int orb, int *last_pktid, double *last_t)sets up and uses a bury(3) state file to save and restore a packet position for the connection orb.

Readingint orbget(int orb, int which, int *pktid, char *srcname, dou-

ble *time, char **pkt, int *nbytes, int *bufsize)get packet which from orb, returning pktid, srcname, time, and nbytes of data pkt. size of buffer pkt is adjusted as needed; pktid may be explicit pktid or ORBPREV, ORBNEXT, ORBNEXT_WAIT, ORBOLDEST, ORBNEWEST.

liborb : Orbserver Access 41

Page 181: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int orbgetstash(int orb, char *srcname, double *time, char **packet, int *nbytes, int *bufsize)

get stash packet for srcname

int orbreap(int orb, int *id, char *nm, double *t, char **p, int *n, int *sz)

read next packet from orb, returning standard packet information

int orbreap_nd(int orb, int *id, char *nm, double *t, char **p, int *n, int *sz)

read next packet from orb, returning standard packet information, or ORB_INCOMPLETE if no packet is available

int orbreap_timeout(int orb, int sec, int *id, char *nm, double *t, char **p, int *n, int *sz)

read next packet from orb, returning standard packet information, or ORB_INCOMPLETE if no packet is available after sec seconds

Writingint orbput(int orb, char *srcname, double time, char

*packet, int nbytes)write the nbytes of packet data onto orb with specified srcname and time

int orbputx(int orb, char *srcname, double pkttime, char *pkt, int nbytes)

write the nbytes of packet data onto orb with speci-fied srcname and time, waiting for acknowledgement

int orbput_nolag(int orb, char *srcname, double t, char *packet, int nbytes, LagParams *params)

write to output orb ensuring that certain readers have read previous packets first, using lag parameter

Status Informationint orbtell(int orb)

return current pktid position for orb

int orbping(int orb, int *version)verify active connection to orb, returning an orb ver-sion number

int orbclients(int orb, double *when, Orbclient **client, int *nclient)

get list of orb clients

int orbsources(int orb, double *when, Orbsrc **source, int *nsource)

get list of srcnames available from orb

int orbstat(int orb, Orbstat **orbstat)get some status information from orb

liborb : Orbserver Access 42

Page 182: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

double orblag(int orb, char *match, char *reject, Laggards **laggards)

return stats showing how far behind clients are

void freeLaggards(Laggards *laggards)free Laggards structure returned by orblag

liborb : Orbserver Access 43

Page 183: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libPkt : Orb Packets Orb packet contain some data and associated srcname and time. The srcname indicates at least the source and packet structure.

include "Pkt.h"ldlibs=$(ORBLIBS)

int unstuffPkt(char *srcname, double time, char *packet, int nbytes, Packet **pkt)

unpack binary packet wth size nbytes and specified srcname and time into c struct Packet pkt.

void showPkt(int pktid, char *srcname, double time, char *packet, int nbytes, FILE *file, int mode)

display the input orb packet on output file; mode may be PKT_TERSE, PKT_PEEK, PKT_NOSAMPLES, PKT_UNSTUFF or PKT_DUMP.

void showPktMatch(int pktid, char *srcname, double time, char *packet, int nbytes, FILE *file, char *match, int mode)

display matching input orb packets on output file; mode may be PKT_TERSE, PKT_PEEK, PKT_NOSAMPLES, PKT_UNSTUFF or PKT_DUMP.

int stuffPkt(Packet *pkt, char *srcname, double *time, char **buffer, int *n, int *size)

from c structure pkt, create binary representation of packet in buffer. returns srcname, time, length of packet n, and size of buffer (size >= n).

int stuffStashPkt(char *stash, int nstash, char **packet, int *nbytes, int *packetsz)

stuff input stash into output packet, allocating space in packet as necessary and returning size nbytes

Packet *newPkt(void)create a new, empty, initialized Packet structure

void freePkt(Packet *pkt)free memory associated with a Packet structure

void clrPkt(Packet *pkt)reset all parameters in a Packet structure

PktChannel *newPktChannel(void)create a new, empty, initialized PktChannel structure

void freePktChannel(PktChannel *achan)free memory associated with a PktChannel structure

libPkt : Orb Packets 44

Page 184: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

void clrPktChannel(PktChannel *achan)reset all parameters in a PktChannel structure

void join_srcname(Srcname *parts, char *srcname)create orb srcname

void split_srcname(char *srcname, Srcname *parts)tear apart orb srcname

PacketType *suffix2pkttype(char *suffix)return PacketType corresponding to srcname suffix

PacketType *header2pkttype(short hdrcode, short body-code)

return PacketType corresponding to hdrcode and bodycode (when no suffix is available).

libPkt : Orb Packets 45

Page 185: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libpforbstat : Orb Status Parameter Files routines to return parameter-files with orb status

include "pforbstat.h"ldlibs=$(ORBLIBS)

Pf *pforbstat(int orb, int flags)return orb-status as a parameter-file

Pf *orbstat2pf(Orbstat *orbstat, int orbversion)Translate an orbstat structure into a parameter file

Pf *orbsources2pf(double atime, Orbsrc *sources, int nsources)

Translate an orbsources structure into a parameter file

Pf *orbclients2pf(double atime, Orbclient *clients, int nclients)

Translate an orbclients structure into a parameter file

libpforbstat : Orb Status Parameter Files 46

Page 186: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libxtra : Miscellaneous contains assorted routines which use multiple libraries, and are gath-ered in one library to avoid complex interdependencies between other libraries

include "xtra.h"ldlibs=$(ORBLIBS)

int dbget_calib(char *sta, char *chan, double time, char *database, double *calib, double *calper, char *segtype)

lookup calib, calper, and segtype from a dynamic database

int netstachanloc(int orb, Arr **netstachan, Arr **src-names)

return net/sta/chan/loc combinations and srcnames for an orb

int trdisp(Dbptr tr, char *title)display a trace object in a dbpick-like window

libxtra : Miscellaneous 47

Page 187: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libbrttpkt : Packet Processing utilities for processing ORB waveform packets

include "brttpkt.h"ldlibs=-lbrttpkt -lgrx -lol $(THREAD) -ltkrtd -lbrttfilter -lbrt-

tutil -ltkbrttplot $(ORBLIBS) $(TKLIBS)

Channel Trace BuffersChantracebuf *chantracebuf_new(double tstart, double

tend, double latency, int apply_calib)create a new channel trace buffer object

int chantracebuf_add(Chantracebuf *cp, PktChannel *pktchan)

add new data packets to trace-buffer object

int chantracebuf_free(Chantracebuf *cp)free a channel trace buffer object

Chantraceproc chantraceproc_new(double latency)create a new channel trace process object

int chantraceproc_addchan(Chantraceproc *cp, char *netstachan, int (*callback)(), void *pvt, double tstart, double tend, double latency, int apply_calib)

specify a channel to be processed by a process object

int chantraceproc_free(Chantraceproc *cp)free a channel trace process object

int chantraceproc_process(Chantraceproc *cp, int orb)process data with a channel trace process object

int chantracebuf_filter(void **fil, int *type, Chantracebuf *icp, Chantracebuf **ocp, char *filspec, int filinit)

apply a filter to a trace-buffer object

Orb Reap/Put ThreadsOrbreapThr *orbreapthr_new(int orb, double timeout, int

queuesize)create a new ORB reap thread that will read from orb with a read timeout and queuesize slots in the FIFO

OrbreapThr *orbreapthr_new2(char *orbname, char *select, char *reject, double tafter, double timeout, int queuesize)

create a new ORB reap thread that will read from orb with a read timeout and queuesize slots in the FIFO

libbrttpkt : Packet Processing 48

Page 188: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int orbreapthr_select(OrbreapThr *orbth, char *select)cause a new orbselect to be processed on a running ORB reap thread

int orbreapthr_reject(OrbreapThr *orbth, char *reject)cause a new orbreject to be processed on a running ORB reap thread

int orbreapthr_after(OrbreapThr *orbth, double after)cause a new orbafter to be processed on a running ORB reap thread

int orbreapthr_set_to_stop(OrbreapThr *orbth)instruct the orbth ORB reap thread to stop from reading new packets and return immediately

int orbreapthr_is_stopped(OrbreapThr *orbth)has the orbth ORB reap thread stopped?

int orbreapthr_stop_and_wait(OrbreapThr *orbth)stop the orbth ORB reap thread from reading new packets and wait for it to stop

int orbreapthr_destroy(OrbreapThr *orbth)destroy the orbth ORB reap thread and free all resources

int orbreapthr_data_available(OrbreapThr *orbth)check for data availability on the orbth ORB reap thread

int orbreapthr_set_timeout(OrbreapThr *orbth, double timeout)

(re)set the read timeout on the orbth ORB reap thread

int orbreapthr_get(OrbreapThr *orbth, int *pktid, char *srcname, double *time, char **packet, int *nbytes, int *bufsize)

get the next packet from the orbth ORB reap thread

OrbputThr *orbputthr_new(int orb, int queuesize)create a new ORB put thread that will write to orb with queuesize slots in the FIFO

int orbputthr_stop(OrbputThr *orbth)stop the orbth ORB put thread from writing new packets

int orbputthr_destroy(OrbputThr *orbth)destroy the orbth ORB write thread and free all resources

int orbputthr_put(OrbputThr *orbth, char *srcname, dou-ble time, char *packet, int nbytes)

put a packet into the orbth ORB reap thread FIFO for eventual writing to the ORB

libbrttpkt : Packet Processing 49

Page 189: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Packet-Channel Calib CachingPktChannelCalib *pktchannelcalib_new(char *dbname,

int need_calib, int need_response, int need_site)create a new packet-channel calib object from dbname database with need_calib, need_response, need_site metadata needs

int pktchannelcalib_free(PktChannelCalib *ch)destroy the ch packet-channel calib object and free all resources

int pktchannelcalib_get(PktChannelCalib *ch, char *snet, char *ssta, char *schan, char *sloc, double time, int check, char *sta, char *chan, double *lat, double *lon, double *elev, double *calib, double *calper, char *segtype, Response **response)

get metadata from the ch packet-channel calib object for snet, ssta, schan, sloc SEED codes at this time and check the database table access times to see if it is necessary to reread the database

Packet-Channel Pipe ProcessingPktChannelPipe *pktchannelpipe_new(Tbl

*channels_select, Tbl *channels_reject, int maxp-kts, int (*callback)(void *private, PktChannel **pktchan, int queue_code, double gaptime), void *private)

create a new packet-channel pipe object using channels_select expressions for selecting channels, channels_reject expressions for rejecting channels, maxpkts packets in the time-ordered queue, and using the user supplied callback function when packet-channels are ready for processing

int pktchannelpipe_free(PktChannelPipe *pcp)destroy the pcp packet-channel pipe object and free all resources

int pktchannelpipe_push(PktChannelPipe *pcp, char *srcname, double pkttime, char *pkt, int nbytes)

push a new ORB packet onto the pcp packet-channel pipe object

int pktchannelpipe_flush(PktChannelPipe *pcp)flush all packet-channels from the pcp packet-chan-nel pipe object

Packet-Channel To Trace Accumulation

libbrttpkt : Packet Processing 50

Page 190: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

PktChannel2Trace *pktchannel2trace_new(Dbptr dbmaster, Dbptr dbtrace, Dbptr dbwf, int need_calib, int need_response, int need_site)

create a new pktchannel2trace object

int pktchannel2trace_free(PktChannel2Trace *pt)free a pktchannel2trace object

int pktchannel2trace_put_from_db(PktChannel2Trace *pt, char *sta, char *chan_expr, int calibfrommas-ter, double tstart, double tend)

fill a pktchannel2trace object from an archive data-base

int pktchannel2trace_put(PktChannel2Trace *pt, PktChannel *pchan, int calibfrommaster, double tstart, double tend)

fill a pktchannel2trace object from an ORB Packet-Channel

int pktchannel2trace_get_stats(PktChannel2Trace *pt, char *sta, char *chan, int *ngood, int *nbad)

determine the numbers of good and gap sample val-ues in a pktchannel2trace object

libbrttpkt : Packet Processing 51

Page 191: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libbrttutil : BRTT Utilities other miscellaneous utilities

include "brttutil.h"ldlibs=-lbrttutil $(STOCKLIBS)

Pf Parameter Processingint parse_param(Pf *pf, char *name, int type, int need,

void *val)parse name parameter from pf parameter file object of a certain type into val and return an error if need is set and name with type does not exist; type may be P_SINT, P_LINT, P_FLT, P_DBL, P_STR, P_BOOL, P_TBL, P_TBLPF, P_ARR, P_ARRPF

MT-Safe FIFOPmtfifo *pmtfifo_create(int maxqueue, int block, int

check)create a POSIX MT-safe FIFO queue of maximum size maxqueue, block when the queue is full and check all subsequent calls to see if the queue still exists

int pmtfifo_set_timeout(Pmtfifo *mtf, double timeout)(re)set a read timeout on the mtf POSIX MT-safe FIFO queue

int pmtfifo_destroy(Pmtfifo *mtf, void (*free_value)(void *ptr))

destroy the mtf POSIX MT-safe FIFO queue and free all resources

int pmtfifo_push(Pmtfifo *mtf, void *ptr)push pointer ptr onto the mtf POSIX MT-safe FIFO queue

int pmtfifo_pop(Pmtfifo *mtf, void **ptr)pop pointer *ptr from the mtf POSIX MT-safe FIFO queue

int pmtfifo_unpop(Pmtfifo *mtf, void *ptr)unpop pointer ptr back onto the mtf POSIX MT-safe FIFO queue

int pmtfifo_data_available(Pmtfifo *mtf)check for data availability on the mtf POSIX MT-safe FIFO queue

int pmtfifo_release_block(Pmtfifo *mtf)release an existing blocking condition on the mtf POSIX MT-safe FIFO queue

libbrttutil : BRTT Utilities 52

Page 192: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int pmtfifo_release_blocks(Pmtfifo *mtf)release any existing and all future blocking condi-tions (i.e. make the FIFO non-blocking) on the mtf POSIX MT-safe FIFO queue

Time History UtilityBUHistory *buhistory_create(int maxnp, char *tag, char

*filename, char *handle)create a time history object with maxnp maximum number of points

int buhistory_free(char *handle)free a time history object referenced by handle

int buhistory_free_tag(char *tag)free a time history object referenced by tag

void buhistory_free_history(BUHistory *history)free a time history object with pointer history

BUHistory *buhistory_get_history(char *handle)get the time history object pointer corresponding to handle

int buhistory_add(char *handle, double time, double value)

add a time-value point to a time history

int buhistory_get_points(char *handle, int *npts, double **tpts, double **ypts)

get all of the time-value points from a time history

int buhistory_eval(char *handle, double time, double *value)

evaluate a time history at time

int buhistory_maxmin(char *handle, double *tmin, dou-ble *tmax, double *vmin, double *vmax)

get the minimum and maximum time and data ranges for a time history

Vector UtilityBUVector *buvector_create(int nx, int ny, char *tag, char

*handle)create a vector object with nx X-values and ny Y-val-ues

int buvector_free(char *handle)free a vector object referenced by handle

int buvector_free_tag(char *tag)free a vector object referenced by tag

void buvector_free_vector(BUVector *vector)free a time history object with pointer vector

libbrttutil : BRTT Utilities 53

Page 193: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

BUVector *buvector_get_vector(char *handle)get the vector object pointer corresponding to handle

BUVector *buvector_read(char *fname, char *tag, int line_off, int xpos, int ny, int *ypos, int lpos, char *handle)

create a vector object and fill it by reading an ASCII file

BUVector *buvector_create_tsamp(int nsamp, double time, double samprate, double *data, char *tag, char *handle)

create a vector object and fill it from a time series waveform

BUVector *buvector_create_response_fap(char *file-name, char *tag, char *handle, int *err)

create a vector object and fill it from a instrument response file

int buvector_resize(char *handle)resize a vector object

BUVector *buvector_copy(char *in_handle, char *tag, char *handle)

copy a vector object

int buvector_append(char *handle, int index, double x, double *y, char *label)

append to a vector object

int buvector_puty(char *handle, int index, double *y, char *label)

replace a point in a vector object

int buvector_get_point(char *handle, int index, double *x, double *y, char *label)

get all of the data for a single point in a vector object

int buvector_get_points(char *handle, int *npts, int *ny, double **xpts, void *vypts, char ***labels)

get all of the data for a all of the points in a vector object

int buvector_eval(char *handle, double x, double *y)evaluate a vector object at X-value x

int buvector_maxmin(char *handle, int iy, double *xmin, double *xmax, double *ymin, double *ymax)

get the minimum and maximum ranges for a vector object

int buvector_transform_edp(char *handle, double lonr, double latr)

transform a vector object into equal distance map projection coordinates

libbrttutil : BRTT Utilities 54

Page 194: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libmappts : Map Data Utilities routines to read various map data formats

include "netcdf.h"include "gmtmap.h"include "gshhsmap.h"ldlibs=-lmappts

NetCDF Format Processingint netcdf_unstuff_header(unsigned char **stream,

NETCDFHdr **hdr)Unstuff the file header from a NetCDF file

int netcdf_print_header(NETCDFHdr *hdr, FILE *file)Print the file header from a NetCDF file

GMT/NetCDF Format Processingint gmtmap_open(void **handle)

create a GMT map object

int gmtmap_select(void *handle, char *types, char *reso-lution, double bb_lonwest, double bb_loneast, dou-ble bb_latsouth, double bb_latnorth)

select GMT map coordinates of certain types, resolu-tions and contained witin a lat-lon bounding box

int gmtmap_nextseg(void *handle, int *npts, int *bufsize, float **lon, float **lat, char *type, int *level)

get the next segment of GMT map coordinates in *lon and *lat with *npts number of coordinates

GSHHS Format Processingint gshhs_unstuff_hdr(GSHHSHdr **gshhs, char

**stream)Unstuff a data block header from a GSHHS file

int gshhs_skip_pts(GSHHSHdr *gshhs, char **stream)skip over a GSHHS file data block

int gshhsmap_open(void **handle)create a GSHHS map object

int gshhsmap_select(void *handle, char *types, char *res-olution, double bb_lonwest, double bb_loneast, double bb_latsouth, double bb_latnorth, double bb_lonref, double bb_latref)

select GSHHS map coordinates of certain types, res-olutions and contained witin a lat-lon bounding box

libmappts : Map Data Utilities 55

Page 195: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

int gshhsmap_nextseg(void *handle, int *npts, int *buf-size, float **lon, float **lat, char *type, int *level, int *antipode)

get the next segment of GSHHS map coordinates in *lon and *lat with *npts number of coordinates

libmappts : Map Data Utilities 56

Page 196: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libproj : Map Projections Various map projections

include "proj.h"ldlibs=$(STOCKLIBS)

PJ *pj_init(int argc, char **argv)select and initialize a cartographic projection

UV pj_fwd(UV val, PJ *proj)perform a forward cartographic projection

UV pj_inv(UV val, PJ *proj)perform an inverse cartographic projection

void pj_free(PJ *proj)free a cartographic projection

libproj : Map Projections 57

Page 197: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Map Projectionsaea Albers Equal Areaaeqd Azimuthal equidistantalsk Alaska Mod.-Stereographicsapian Apian Globularbipc Bipolar Conicbonne Bonnecass Cassinicc Central Cylindricalcea Cylindrical Equal Areacollg Collignoneck1 Eckert Ieck2 Eckert IIeck3 Eckert IIIeck4 Eckert IVeck5 Eckert Veck6 Eckert VIeqc Equidistant Cylindricaleqdc Equidistant Conicgall Gall (Stereographic)gnom Gnomonicgs50 50 State U.S. Mod.-Stereographicgs48 48 State U.S. Mod.-Stereographichataea Hatano Asymmetrical Equal Arealabrd Labordelaea Lambert Azimuthal Equal Arealeac Lambert Equal Area Coniclee os Lee Oblate Stereographics Pacificlcc Lambert Conformal Conicloxim Loximuthallsat LANDSAT Space Oblique Mercatormbtfpp McBryde-Thomas Flat-Polar Parabolicmbtfps McBryde-Thomas Flat-Polar Sinusoidalmbtfpq McBryde-Thomas Flat-Polar Quarticmerc Mercatormill Millermil os Miller Oblate Stereographics Eur-Africamoll Mollweidesmtm Mercator Transverse Modifiee (Quebec)nsper General Vertical Persepectivenzmg New Zealand Map Gridocea Oblique Cylindrical Equal Areaomerc Oblique Mercatorortho Orthographicparab Caster Parabolic poly Polyconic (American) putp2 PutninsP2putp5 PutninsP5 quau QuarticAuthalicrobin Robinsonsinu Sinusoidalstere Stereographictcc Transverse Central Cylindricaltcea Transverse Cylindrical Equal Area

libproj : Map Projections 58

Page 198: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

tmerc Transverse Mercatortpers Tilted Perspectiveups Universal Polar Stereographicutm Universal Transverse Mercatorvandg Van der Grintenwink1 Winkel 1

libproj : Map Projections 59

Page 199: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libtks : Tk Send IPC provides a c interface to the tcl/tk send IPC mechanism

include "tks.h"ldlibs=-ltks $(X11LIBS) -lposix4

TkSend *Tks_Create(Display *display, Window window, int version)

optionally connect to X-server and create communi-cation window

int Tks_Send(TkSend **tksptr, char *name, char *msg, char **response, int async)

send a message via the tksend IPC mechanism

int Tks_Reply(TkSend *tks, char *reply)return a reply to an application that has just sent a message

int Tks_GetmsgEventProc(TkSend *tks, XEvent *event, char **msg_ptr, int *replyrequest)

process an X-event that may contain a message

int Tks_ValidateName(TkSend *tks, char *name, char *disposition, int *version)

validate an application name

char *Tks_SetAppName(TkSend *tks, char *name)set an application name in the X registry

int Tks_ClearAppName(TkSend *tks, char *name)clear an application name from the X registry

void Tks_SetVerbose()turn on tksend verbose mode

libtks : Tk Send IPC 60

Page 200: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libwffil : Filter Waveforms provides a c interface to general purpose time-domina waveform fil-tering with user-written dynamic link libraries to implement the filters

include "wffil.h"ldlibs=$(STOCKLIBS)

int wffil_define_filters(char *pfname, void *user_data)define new filter methods

int wffil_parse_filter(void *user_data, char *filter_string)parse a filter specification

int wffil(void *user_data, char *filter_string, double gap_tolerance, int *nsamps, double *tstart, double *dt, float **data, int *data_size, char *input_units, char *output_units, Hook **state)

filter data in place

libwffil : Filter Waveforms 61

Page 201: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libwffilave : Averaging Filters example of extension filters for libwffil

ldlibs=$(STOCKLIBS)

int wffilave_filter(void *user_data, char *filter_string, double gap_tolerance, int *nsamps, double *tstart, double *dt, float **data, int *data_size, char *input_units, char *output_units, Hook **state)

filter data in place

libwffilave : Averaging Filters 62

Page 202: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

libwffilbrtt : BRTT Filters provides a c interface to BRTT time-domain waveform filtering using digital recursion filters

ldlibs=$(STOCKLIBS)

int wffilbrtt_filter(void *user_data, char *filter_string, double gap_tolerance, int *nsamps, double *tstart, double *dt, float **data, int *data_size, char *input_units, char *output_units, Hook **state)

filter data in place

libwffilbrtt : BRTT Filters 63

Page 203: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Fortran Interfaces

Database Operationsdeclarations for variables used below:

include "db.i"integer db(4)char record(*)character table_name, field_namecharacter sinteger expression # expression is pointer to compiled expres-

sioninteger typeinteger pattern1, pattern2, nojoin # pattern1 and pattern2 are

pointers to Tbl listsinteger outercharacter name(*)

integer dbadd(db, record)add a record to a table

integer dbadd_remark(db, remark)add a remark to CSS database tables

integer dbaddv(db, table_name, field_name, value1, ...)write values to fields in a new database row

integer dbcrunch(db)crunch out null rows in database

integer dbdelete(db)delete rows from database tables

integer dbdestroy(db)remove all base tables for a database

integer dbex_compile(db, s, expression, type)compile a database expression

integer dbex_eval(db, expression, setflag, result)evaluate a database expression for a record

integer dbex_free(expression)free memory for a database expression

integer dbextfile(db, tablename, filename)compose filename from database record

integer dbget(db, s)get ascii tables, records, or fields from a database

integer dbget_remark(db, remark)get a remark from CSS database tables

integer dbgetv(db, table_name, field_name, value1, ...)read values from fields in a database

Fortran Interfaces 64

Page 204: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

subroutine dbjoin(dbresult, db1, db2, pattern1, pattern2, outer, nojoin, name)

join two database tables

subroutine dblookup(dbr, db, database, table, field, record)lookup database pointer indexes from ascii names

integer dbmark(db)mark rows for deletion

integer dbnextid(db, name)generate unique id from the lastid table

integer dbopen(name, opentype, db)open a database

integer dbopen_database(name, opentype, db)open a database or table pathname

integer dbopen_table(name, opentype, db)open a database or table

integer dbput(db, s)put ascii tables, records, or fields into a database

integer dbputv(db, table_name, field_name, value1, ...)write values to fields in a database

subroutine dbquery(db, code, value)get ancillary information about a database

subroutine dbsort(result, db, tbl, flag, name)create a sorted view

subroutine dbsubset(result, db, s, name)create a subset view

integer dbtruncate(db, nrows)truncate a database table to specified length

integer dbunjoin(db, database_name, rewrite)create new tables from a joined table

subroutine trgetwf(db, 0, data, NMAX, t0_req, t1_req, t0, t1, npts, fill, fill_value)

read trace data from file into memory

Spatial Transformationssubroutine dist(lat1, long1, lat2, long2, delta, azimuth)

compute angular distance and azimuth between two points (all in radians)

subroutine latlon(lat1, long1, del, azimuth, lat2, long2)compute lat and long given starting point and dis-tance (all radians)

Fortran Interfaces 65

Page 205: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

Time Transformationssubroutine doy2mday(doy, year, month, day)

convert day of year to month and day

subroutine e2h(epoch, iyear, iday, ihour, imin, sec)split epoch time into output components

real *8 epoch(yearday)convert yearday to epoch time

subroutine epoch2str(s, e, f)convert epoch time to formatted string

real*8 h2e(year, day, hour, min, sec)convert input parameters to epoch time

integer mday2doy(year, month, day)convert month and day to day of year

double now()return current epoch time

real *8 str2epoch(s)convert string to epoch time

subroutine strdate(s, e)convert epoch time to string date

subroutine strtime(s, e)convert epoch time to string time

integer yearday(e)convert epoch time to yearday

Error Handlingsubroutine clear_register(printflag)

clear the error register

subroutine complain(sysflag, msg)log an error message and print

subroutine die(sysflag, msg)log an error message and die

subroutine register_error(sysflag, msg)register an error message

General Programming Utilitiessubroutine datafile(path, envname, filename)

return path corresponding to either environment variable envname or file relative to $ANTELOPE/data

Fortran Interfaces 66

Page 206: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

subroutine datapath(path, envname, dirname, filename, suffix)

return path corresponding to either environment variable envname or dir/file.suffix relative to $ANTELOPE/data

subroutine isort(a, n, size, compare, pvt)insertion sort routine

integer newdata(pathname, envname, dirname, filename, suffix)

construct pathname for a new datafile

subroutine shellsort(a, n, size, compare, pvt)shell sort implementation

integer ssearch(key, keysize, a, n, unique, compare, pvt, ns, ne)

binary search of index

Niceplotsubroutine axis(xdim, ydim, xmarg, ymarg, xlow, ylow,

xmax, xmin, ymax, ymin, dxsmal, dxnumb, dysmal, dynumb, fmtx, fmty, labelx, labely, title, iclear)

draw a box with tic marks and labels

subroutine box(xleft, xright, ybot, ytop, thick, ithick, iclip)draw a box

subroutine cfont(integer jfont)change font

subroutine chrdir(real angle)change text labelling direction

subroutine chrsiz(height, ratio, slant)change size and slant of text labelling

subroutine circle(xc, yc, r, narc, iclose, iclip, thick, ithick)draw a circle

subroutine clear()clear the window

subroutine clrrgn(xmn, xmx, ymn, ymx)clear a region in the window

subroutine cpyrgn(xmn, xmx, ymn, ymx)copy a region from the pixmap to the window

subroutine cursor(x, y, chr)reads in the cursor position upon keypress

subroutine finitt()finish plotting

subroutine fplot(n, x, y)fast plotting routine

Fortran Interfaces 67

Page 207: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

subroutine getchr(c, nstrks, npoint, ioff, ix, iy)compute the outline of a character

subroutine getsiz(c, ihite, iwidth)compute the size of a character

subroutine initt(itran, plotfile, display, program, ssize, xwin, ywin)

initialize window

subroutine laxis(xdim, ydim, xmarg, ymarg, xlow, ylow, xmax, xmin, ymax, ymin, dysmal, dynumb, fmty, labelx, labely, title, iclear)

draw log-linear axes

subroutine line(x1, y1, x2, y2, thick, ithick, iclip)draw a line

subroutine llaxis(xdim, ydim, xmarg, ymarg, xlow, ylow, xmax, xmin, ymax, ymin, labelx, labely, title, iclear)

draw log-log axes

subroutine ltype(integer n)set line type0 - solid1 - dotted-dashed -dashed -dashed

subroutine ncontour(nx, nxmax, ny, x, y, z, ctype, zmin, zmax, dz)

render a contour map

subroutine nplot(n, x, y, igraf, iclip, thick, ithick, asymb)plot a set of points

subroutine ntype(xtype, ytype)define plot scales

subroutine plot1(n, x, y, roff, iclip)plot a curve

subroutine sclsiz(real*4 scale)scale character sizes

subroutine setbac(hue, light, sat)set background color

subroutine setbg(character *(*) color)set background color

subroutine setcursor(type, param1, param2)set the appearance of the graphics cursor

subroutine setdim(xdim, ydim, xlow, ylow)set plotting area dimensions

Fortran Interfaces 68

Page 208: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

subroutine setfg(character *(*) color)set foreground color

subroutine setfor(hue, light, sat)set foreground color

subroutine setscl(xmin, xmax, ymin, ymax)set plotting area scaling

subroutine text(x, y, angle, iref, string, iclip)plot a text string

subroutine tics(x1, y1, x2, y2, stic, ntic, dtic, tlen, thick, idir)plot tic marks

subroutine trackcursor(external track(x, y))calls routine track with coordinates x, y as cursor moves

subroutine trackcursoroff()disables cursor tracking callback routine

subroutine xmap(real x)convert from plotting to raster units

subroutine ymap(real y)convert from plotting to raster units

Listsinteger maxtbl(itbl)

return the number of elements in a list

subroutine strfreetbl(itbl)free memory associated with a list

subroutine strgettbl(itbl, i, s)copy the i'th string from a list to a FORTRAN string

subroutine strputtbl(itbl, i, s)copy a string to the i'th element of a list

subroutine strtbl(itbl, s, ...)create a new list from a list of strings

Parameter Filessubroutine pfcompile(string, pf, retcode)

read a parameter file from a string

subroutine pffree(pf)free resources for a parameter space

subroutine pfget(pf, name, result, retcode)get a value from a parameter file

subroutine pfget_arr(pf, name, iresult)get an associative array from a parameter file

subroutine pfget_boolean(pf, name, iresult)get a boolean value from a parameter file

Fortran Interfaces 69

Page 209: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

subroutine pfget_double(pf, name, fresult)get a double precision value from a parameter file

subroutine pfget_int(pf, name, iresult)get an integer value from a parameter file

subroutine pfget_string(pf, name, svalue)get a string value from a parameter file

subroutine pfget_tbl(pf, name, iresult)get an ordered list from a parameter file

subroutine pfnew(type, result)start a new parameter space

subroutine pfput(pf, name, value, type)put a value into a parameter space

subroutine pfput_arr(pf, name, value)put an associative array into a parameter space

subroutine pfput_boolean(pf, name, value)put a boolean value into a parameter space

subroutine pfput_double(pf, name, fvalue)put a double precision value into a parameter space

subroutine pfput_int(pf, name, value)put an integer value into a parameter space

subroutine pfput_string(pf, name, svalue)put a string value into a parameter space

subroutine pfput_tbl(pf, name, value)put an ordered list into a parameter space

subroutine pfread(name, pf, retcode)read a parameter file

subroutine pfwrite(pf, filename, retcode)write a parameter file object to the specified file

Seismic Informationinteger arrtimes(delta, depth, phases, times)

returns all the calculated phases

integer grname(grn)return the name of a Flinn-Engdahl geographic region

integer grnumber(lat, lon)return the Flinn-Engdahl geographic region number

real*8 phasetime(phase, delta, depth)returns the time for a specified phase

real*8 ptime(delta, depth)returns the first P arrival

Fortran Interfaces 70

Page 210: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Programmer Reference

integer srname(srn)return the name of a Flinn-Engdahl seismic region

integer srnumber(grn)return the Flinn-Engdahl seismic region number

real*8 stime(delta, depth)returns the first S arrival

Fortran Interfaces 71

Page 211: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Appendices

Page 212: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Contents

ANTELOPEMAKE ........................................... 1

Schemas.......................................................... 3

Datascope Constants ...................................... 5

Expression Calculator...................................... 9

Environment variables ................................... 14

Tcl/Tk Extensions .......................................... 17

Waveform Filtering......................................... 18

Parameter Files ............................................. 19

Epoch Format Codes..................................... 20

Acceptable Time Formats.............................. 21

Directory Structure ........................................ 22

Page 213: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

ANTELOPEMAKE

Targetsall create everything in current directoryInclude install include files onlyinstall install everythinguninstall uninstall everythingclean remove all intermediate filespurge remove .make.state, other filesBIN install executables DLIB install dynamic librariesSLIB install static librariesPF install parameter files DATA install data filesINCLUDE install include filesMAN install man pages

User MacrosBIN executables to install into $(DEST)/bin LIB static libraries to install into $(DEST)/static DLIB dynamic libraries to install into $(DEST)/lib INCLUDE include files to install into $(DEST)/include PF parameter files to install into $(DEST)/data/pf DATA data files to install into $(DEST)/data/$(DATADIR)DEMO demos to install into $(DEST)/data/$(DEMODIR)DOC documents to install into $(DEST)/data/$(DOCDIR)MAN1 program man pages for $(DEST)/man/man1MAN3 c interface man pages for $(DEST)/man/man3MAN3F fortran man pages for $(DEST)/man/man3fMAN3H files to install into $(DEST)/man/man3hMAN3P perl man pages for $(DEST)/man/man3pMAN3T tcl man pages for $(DEST)/man/man3tMAN5 format man pages for $(DEST)/man/man5

cflags special c compilation flagsfflags special fortran compilation flags ldflags special linker flags ldlibs libraries to be linked with the executable

DIRS sub directories (in order) into which make descendsDEST installation directory: $(ANTELOPE)$(SUBDIR)SUBDIR alternate destination hierarchy below $ANTELOPE, often local

ANTELOPEMAKE 1

Page 214: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Predefined Link Library MacrosSTOCKLIBS -lcoords -lstock + required librariesDBLIBS -lds + required librariesTRLIBS -ltr + required librariesORBLIBS -lPkt -lorb -lforb + required librariesTHREAD multi-threading librariesX11LIBS X librariesF77LIBS fortran libraries

2 ANTELOPEMAKE

Page 215: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

SchemasThe following schemas are included with the Antelope distribution.

autodrm1.0 logs of messages sent and received by autodrm

certify2.0 database of regression tests and results

contacts1.0 phone-numbers and contact names for investigation of felt reports from earthquakes

css2.8 predecessor to css3.0. See css3.0.

css3.0 Center for Seismic Studies schema version 3.0; seismic information including waveforms, paramet-ric data, and station details.

css_vel supports the dblocgrad program

cvs1.0 alternative representation for CVS (Concurrent Ver-sion System) log information

Db2sd1.0 additions to css3.0 for generating SEED volumes

dbrecenteqs1.1 expansion of css3.0 and rt1.0 to support web-based mapping of hypocenters and related information

genloc1.0 extensions of css3.0 to support the genloc program

gmt1.0 schema to track GMT grid files

iceworm1.3 extensions to css3.0 schema for use with the Ice-worm system

Id1.0 used by the database id server program dbids

Logs1.0 defines a table to hold log files

models0.4 prototype css3.0 expansion schema to store travel-time models

MWavelet1.1 extension of css3.0 for multiwavelet array-process-ing

Schemas 3

Page 216: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

notify1.2 holds contact information used in earthquake response procedures

pde Datascope schema representation of the Preliminary Determination of Epicenters reports from the National Earthquake Information Center

places1.2 Describes places on the earth: cities, populated places, summits etc. Includes support for specifying polygonal regions.

rt1.0 Depricated: use css3.0 instead

rtexec1.0 supports Antelope real-time executive program rtexec

statrans1.1 Supports translation of station-names from station-name-only (used by some networks in the past) to css3.0-compatible station and channel names.

Status1.0 monitoring and maintenance of one or more Ante-lope real-time systems

strawman1.0 strawman proposal for a schema which fixes some of the problems with css3.0

takeoff extensions to css3.0 used for focal mechanisms and theoretical travel-times

tcpmonitor1.0 keep TCP link statistics

Trace4.0 trace manipulation and processing database; pro-vides the parameter information needed during stan-dard processing of seismic waveform data, and their representation in memory.

USGS_pde1.0 USGS 1995 format for Preliminary Determination of Epicenters

wfrecords1.0 schema for cataloging non-digital records, e.g. heli-corder paper

4 Schemas

Page 217: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

Datascope Constants

Dbptr ValuesA database pointer has four elements: database, table, field and record. Each of these elements takes on a nonnegative integer value to refer to a specific database, table, field or record, but may also take one of the following special values:

dbINVALID error indication

dbALL all tables, all fields, or all records

dbSCRATCH scratch record for a table or view

dbNULL null record for a table or view

Routine FlagsdbOUTER_JOIN

set to force join of every record in first table

dbSORT_UNIQUE set to cause the result to contain only one record for each unique set of sort key values

dbSORT_REVERSE reverse the sense of the sort

Dbquery CodesdbSCHEMA_NAME

schema name

dbSCHEMA_DESCRIPTION short description for schema

dbSCHEMA_DETAIL long description for schema

dbSCHEMA_DEFAULT return the schema used for databases lacking a descriptor file.

dbSCHEMA_TABLES return a Tbl list of all the relations in the schema

dbSCHEMA_FIELDS return a Tbl list of all the attributes in the schema

dbLINK_FIELDS return a Tbl list of all id attributes in the schema

dbTIMEDATE_NAME name of attribute automatically filled with current time when record is changed

Datascope Constants 5

Page 218: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbLASTIDS returns Arr array of lastid by table name, for tables with added records

dbDATABASE_DESCRIPTION short description for database

dbDATABASE_DETAIL short description for database

dbDATABASE_NAME database name

dbDATABASE_FILENAME return the name of database descriptor file

dbDATABASE_IS_WRITABLE return non-zero if database was opened with permis-sion "r+"

dbIDSERVER return the name of the idserver, or 0 if not used

dbLOCKS returns value of DBLOCKS

dbDATABASE_COUNT count of databases open

dbDBPATH return the path along which database tables may be found

dbTABLE_COUNT count of relations in database

dbTABLE_NAME relation name

dbTABLE_DESCRIPTION short description for relation

dbTABLE_DETAIL short description for relation

dbTABLE_FILENAME return complete path for file holding table

dbTABLE_DIRNAME return the directory path for the table

dbTABLE_PRESENT return non-zero if table has at least one record

dbTABLE_SIZE return total size in bytes of a table

dbRECORD_COUNT count of records in table

6 Datascope Constants

Page 219: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

dbRECORD_SIZE return size in bytes of a record in the table

dbTABLE_FIELDS return a Tbl list of the fields in the table

dbFIELD_COUNT count of attributes in relation

dbTABLE_IS_WRITABLE return non-zero if table is writeable

dbTABLE_IS_ADDABLE return non-zero if locks and permissions allow add-ing records

dbTABLE_IS_TRANSIENT return non-zero if table has no actual file

dbPRIMARY_KEY return the primary key for a table

dbALTERNATE_KEY return the alternate key for a table

dbFOREIGN_KEYS return any foreign keys in the table

dbUNIQUE_ID_NAME return name of id defined by the table, if any

dbTABLE_IS_VIEW returns non-zero if table is a view

dbVIEW_TABLE_COUNT return the number of relations participating in the view

dbVIEW_TABLES return a Tbl list of tables which are present in the view

dbFIELD_BASE_TABLE return the base table for the field

dbFIELD_NAME attribute name

dbFIELD_DESCRIPTION short description for attribute

dbFIELD_DETAIL short description for attribute

dbFIELD_RANGE return the expression which defines the valid range of values for a field

Datascope Constants 7

Page 220: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

dbFIELD_FORMAT return printf format string used to save attibute value into database

dbFIELD_SIZE return size in bytes of an attribute

dbFIELD_TYPE return type of an attribute:

dbBOOLEANdbDBPTRdbINTEGERdbREALdbTIMEdbYEARDAYdbSTRING

dbFIELD_UNITS return units for an attribute (not used by Datascope)

dbFIELD_INDEX return the offset in bytes of a field into a record

dbFIELD_TABLES return a Tbl list of tables which contain the field

8 Datascope Constants

Page 221: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

Expression Calculator

Aggregate Functionscount()

count records in a group or table

count_table()count records in a table

max(expr)find the maximum of the expression in a group or a table

max_table(expr)find the maximum of the expression in a table

min(expr)find the minimum of the expression in a group or a table

min_table(expr)find the minimum of the expression in a table

sum(expr)add an expression across a group or a table

sum_table(expr)add an expression across a table

record()return the Datascope record number

Arithmetic Functionsabs(x)

absolute value

atan(x,y)arctangent of angle from x-axis to point (x,y)

ceil(x)next integer >= x

cos(x)cosine of x in degrees

exp(x)e^x

floor(x)next integer <= x

int(x)floor(abs(x))*sign(x)

log(x)natural logarithm

Expression Calculator 9

Page 222: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

log10(x)base 10 logarithm

max(x,y)maximum of x,y

min(x,y)minimum of x,y

sign(x)1 if x>0, -1 if x<0, 0 otherwise

sin(x)sine of x in degrees

sqrt(x)square root

tan(x)tan of x in degrees

Time Conversiondate2e(year, month, day, seconds)

convert to epoch time

epoch(jdate)convert from jdate to time

now()the current epoch time

strdate(epoch)convert time to date string

strtdelta(epoch)convert time difference to string

strtime(epoch)convert time to string

strydtime(epoch)convert time to string with yearday

epoch2str(epoch,format[,timezone])convert time to string using format, optionally for a timezone

yearday(epoch)convert from epoch time to yearday (jdate)

Flinn-Engdahl Regionsgrname(lat,lon)

geographic region name

grn(lat,lon)geographic region number

srname(lat,lon)seismic region name

10 Expression Calculator

Page 223: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

srn(lat,lon)seismic region number

Seismic Travel Timespphasetime(delta,depth)

ptime(delta,depth)elapsed time for first p-arrival from event at delta, depth

sphasetime(delta,depth)

stime(delta,depth)elapsed time for first s-arrival from event at delta, depth

phasetime(phase, delta, depth)elapsed time for specified phase for event at delta, depth

parrival()time of first p-arrival

sarrival()time of first s-arrival

arrival(phase)arrival of specified phase

phase_arrival(velocity)time of phase arrival, given velocity in degrees/sec-ond

pphase_slowness(delta,depth)slowness of first p-arrival from event at delta, depth

sphase_slowness(delta,depth)slowness of first s-arrival from event at delta, depth

phase_slowness(phase, delta, depth)slowness for specified phase for event at delta, depth

Spherical Geometryazimuth(lat1, lon1, lat2, lon2)

azimuth from point 1 to point 2

distance(lat1, lon1, lat2, lon2)distance in degrees between two points

latitude(lat, lon, distance, azimuth)latitude of the point a distance away from (lat,lon) in the direction azimuth

longitude(lat, lon, distance, azimuth)longitude of the point a distance away from (lat,lon) in the direction azimuth

Expression Calculator 11

Page 224: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

km2deg(km)convert kilometers to (nominal) degrees

deg2km(deg)convert degrees to (nominal) kilometers

Stringssubstr(str,x0,n)

null("fieldname")

strlen(sta)

External Files and Commandsconcatpaths(dir,dfile)

dirname(path)

basename(path)

["wc" extfile()]execute a unix command, as in this example

extfile([ table ])generate the complete path for an external file

Operators+ arithmetic addition- arithmetic subtraction

* arithmetic multiplication^ exponentiation

/ arithmetic division% arithmetic modulus

>> bit shift right<< bit shift left

. string concatenation

:= assignment

" surrounds a string expression' surrounds a string expression_ surrounds a time expression (suitable for str2epoch)

expr ? a : bconditional expression: evaluates to a when expr is true, b when expr is false.

Pattern MatchingA =~ /regular-expression/

regular expression match

12 Expression Calculator

Page 225: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

A !~ /regular-expression/regular expression does not match

patsub(old, pattern, replacement)replaces the first pattern matched in old with replacement

Relational Operators== equals!= not equal to

a == NULL true if field a has the null value for that fielda != NULL true if field a does not have the null value for that field

< less than<= less than or equal to

> greater than>= greater than or equal to

|| logical or&& logical and

| bitwise or& bitwise and

Expression Calculator 13

Page 226: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Environment variablesThe following environment variables may be used to change the default Antelope behavior. See antelopeenv(5) for more information.

ANTELOPE identifies the Antelope base directory, eg, "/opt/antelope/4.10"

ANTELOPEMAKE specifies file with standard make(1) rules for Ante-lope

BNS_RESEND # of packets to resend when orbput fails and recon-nects; default 1

BNS_TIMEOUT overrides the default timeout used by Antelope rou-tines on orb socket connections (and other sockets handled by bns(3) routines).

DATAPATH overrides the default directory $ANTELOPE/data where Antelope programs find a variety of data files.

EDITOR

XEDITOR specify an editor to use when editing pf files from rtm

ELOG_DELIVER list of error message destinations: filenames, "stderr" or "stdout", or "orb:hostname:port".

ELOG_DEBUG when set, a debugger is started for program faults

ELOG_SIGNALS signals for which handlers are set up; default is "ILL:TRAP:FPE:BUS:SEGV:SYS". if null, don't install any handlers.

ELOG_MAXMSG maximum number of messages allowed on the error log. If zero, no limit.

14 Environment variables

Page 227: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

ELOG_TAG tag prepended to each message; see elog.pf for default.%a argument list%h host name%p pid%P program name%r complete path to program%t local time tag, eg "Thu May 29 15:27:59 1997"%T thread id

-149 21:27:59"

EUROPEAN_DATE when set, interpret dates like xx/xx/xx as day/month/year. various output formats are also changed equivalently; see time_formats.pf for alternative.

FORBRECVTIME when set, record time packet is received in forb(5) files

GRX_PSCOLOR affects niceplot hardcopy output, eg from dbpick: full full color PostScript fore color PostScript for contour images, but background is white color color PostScript only for color contour images unset grayscale or black&white output

GRX_FONTPATH overrides the default location $ANTELOPE/data/fonts.bin for the binary font file used by niceplot

ORB_IP_ADDRESS cause orb client connections to bind to the specified ip address

PFPATH overrides the default path to parameter files: "$(ANTELOPE)/data/pf:."

SCHEMA_DEFAULT overrides the default schema (css3.0) to use when no descriptor file is present.

SCHEMA_DIR overrides the default location ($(ANTELOPE)/data/schemas) for Datascope schema files

TTMETHOD override default travel time method (tttaup)

TTMODEL override default travel time model (iasp91)

Environment variables 15

Page 228: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

TAUP_PATH

TAUP_TABLE override the default directory $(ANTELOPE)/data/tables/taup_ttimes for the tau-p travel time tables and the default tau-p model iasp91

16 Environment variables

Page 229: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

Tcl/Tk Extensions% man tcl_packages

atcl Tcl shell

awish Tk shell

package require XXX

Tclx

Tkx extended tcl/tk -- variety of extensions to unix func-tions

BLT primarily 2d graphics

Itcl object oriented extensions

Itk object oriented widget extensions

Iwidgets extended widgets

Brttplot extensions for drawing graphs on a tk canvas.

Datascope Datascope database extensions

Dbe extensions for implementing dbe

Orb extensions for reading and writing to an orbserver

Pixmap extension for pixmaps (used in dbevents)

Rtd extension for real time trace display

Rtm extensions for implementing rtm

Ttgrid extensions for the time travel grid file used by orbas-soc and dbgrassoc

Vogle 3-d graphics extension for "Very Ordinary Graphics Library"

Tcl/Tk Extensions 17

Page 230: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Waveform FilteringA variety of time domain waveform filter routines are available across Antelope programs and routines. A filter spec is made by combining the filter names (and associated parameters) defined below.

Standard FiltersBW lowfreq loworder highfreq highorder General bandpass Butterworth minimum phase filter.BWZ lowfreq loworder highfreq highorder General bandpass Butterworth zero phase filter.WAA [nominal] Wood-Anderson instrument filter for acceleration sensorWAV [nominal] Wood-Anderson instrument filter for velocity sensorWAD [nominal] Wood-Anderson instrument filter for displacement sensorINT [n|sfreq] IntegrationINT2 [sfreq] Double integrationDIF [n] DifferentiationDIF2 Double differentiationDEMEAN Demean waveformG fac1 [fac2 [...]] [segtype] Apply gain factor

Simple Averaging FiltersAVE twin[toffset] Boxcar average waveformABS Compute waveform absolute valueSQ Compute waveform square valueSQRT Compute waveform square root value

18 Waveform Filtering

Page 231: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

Parameter FilesPFPATH combine all parameter files found along PFPATH or

$ANTELOPE/data/pf:.

&Tbl{ ordered list of values&Arr{ key/value pairs&ask(prompt) ask for the value using prompt&Literal{ everything until matching closing bracket: {[(<`'>)]}&Undef{} eliminate previous value&exec(cmd) result from executing cmd &file(path) contents of path&filename(path) path filename&datafile(path) contents of data file $ANTELOPE/data/path&datafilename(path) $ANTELOPE/data/path&env(name) value of environment variable name&ref(pf, key) look up key in parameter file pf&glob(glob) list of paths matching glob&reference use another value from this parameter file&{reference} use another value from this parameter file&user-function(args) write your own function

__DATA__ end of the parameter file__END__ end of the parameter file__EOF__ end of the parameter file

ExampleTry with "pfecho -i"

# comment"key with spaces" value # commentlist &Tbl{ 1 2}array &Arr{three 3one 1}literal &Literal{ proc a {b} { # example

puts hi }}sta AAKdate &exec(date +%Y-%j)pfnames &glob(*.pf)name &{sta}.&dateantelope &env(ANTELOPE)

Parameter Files 19

Page 232: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Epoch Format CodesThe two character combinations on the left in the list below are replaced by the value indicated on the right by the epoch(1) command and the epoch2str(3) function.%% %%B month%b abbreviated month%D date as %m/%d/%y%d day of month (01-31)%a abbreviated day of week%A day of week%E epoch time to milliseconds (xxxxxxxxxxx.xxx)%e day of month (1-31)%H hour (00-23)%I hour (01-12)%j day number of year (001-366)%k hour ( 0-23)%l hour ( 1-12)%L month number ( 1-12)%M minute (00-59)%m month number (01-12)%n (linefeed)%o ordinal day of month ("1st", "2nd", "23rd")%O ordinal day of year ("1st", "2nd", "365th")%p AM or PM, whichever is appropriate%S seconds (00-59)%s milliseconds (000-999)%t (tab)%u tens of microseconds (00000-99999)%Y year including century (eg, 1988)%y year within century (00-99)%Z timezone code%z timezone code

Example:% epoch +"%a %b %d %H:%M" nowThu Nov 30 23:09% epoch +"wf/%Y-%j" nowwf/2000-335

20 Epoch Format Codes

Page 233: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Tables Reference

Acceptable Time Formats

All the following representations for

August 9 1993 1:34

are acceptable. The order of the fields doesn't matter.

9 Aug 1993 1:34:56.789 am8/9/93 1:34:56.7898/9/1993 1:34:56.7891:34:56.789 8/9/1993Aug 09 93 1:34:56.789AUG 9 93 1:34:56.7899 August 1993 1:34:56.7891993221 1:34:56.7891993 (221) 1:34:56.789744860096.7897448600961993 (221) 1:349 August 1993 1:34:56.7891993221 1:34:56.7891993221:1:34:56.7891993221:1:34:56.7891993:221:1:34:56.7891993:221:1:34:56:7891993 (221) 1:34:56.7891993:aug:9:1:34:56.7891993-221 1:34:56.7891993-08-09 1:34:56.789

The string "now" indicates the current time.A leading + (plus) or - (minus) sign indicatesa time relative to now:

now -1:00 -0:00:10 +0:15

To specify a previous day, use -Ndays:2:00 -1day-10days 13:35

Acceptable Time Formats 21

Page 234: Antelope 4.10 Reference Guide - OOICI Confluence Site · 2008-10-29 · Antelope 4.10 2 Antelope Real Time System truncate_log [options] log [log..] eliminate old lines in log files-c

Antelope 4.10

Directory Structure

/opt/antelope/perl* perl releasetcltk* Tcl/Tk releasedata /rtdemo demo realtime data /db demo databases

/opt/antelope/4.10antelope.html master guide to documentationChanges list of changes for current releasebin executable programsdata program data /doc files related to documentation /instruments data files for dbbuild /maps map databases and images /pf parameter files /perl perl extensions /pkt packet library source code /responses datalogger and sensor responses /schemas schema descriptions /system restart on boot scripts /tables travel time tables /tcl tcl extensions /www web related data filesdemo real time demosdoc miscellaneous Antelope documentionexample Antelope source examplesinclude include files for program development /antelopemake Antelope make ruleslib librariesman man pages /html html version of man pagespatches patches in tar formatpatched descriptions of applied patchesREADME introductory information about AntelopeRelease compilation information about releasesetup.csh sets up csh shell environment variablessetup.sh sets up bourne shell environment variables

Real Time Directorybin special executablesdb dynamic database tables and waveform datadbmaster "static" database tables like sitelogs program log filesorb ring buffer filespf parameter filesrtexec.pf real time system configuration file rtsys process database used by rtexecstate files preserving state between program executions

22 Directory Structure