Stuff to Work with CSS Data
Programs and Scripts
GETFEMTO10 - Extract multiple station/channel pairs from the NFS-mounted /femto/archive database and create a new CSS volume at the user-supplied location containing only these data
Correct whitespace issues in a wfdisc (this realigns all columns so the wfdisc format is recovered)
Convert a wfdisc that contains multiple stations into station wfdiscs
Correct whitespace issues in a wfdisc (this realigns all columns so the wfdisc format is recovered)
Scripting Tips
Scripts are extremely powerful when managing or manipulating ascii data. Perl is very popular with the programming community, but I find it non-intuitive. I like C-Shell (csh) scripts because they are user-friendly and very intuitive. Below are some advanced tips to get the most out of your csh scripts.
Remove last 2 characters of each element of an array of strings. In the
example below, wffile is a wfdisc containing station names like: I04H3 I04H4 TX32 TXI01. That line pulls out just the unique identifiers that range in size betwween two and three characters (e.g. I04 and TX).
set stations=`awk '{print $1}' $wffile | sort -u | sed 's/..$//g' | sort -u`
Accepting arguments at the command line. All arguments supplied to the script at the command line can be accessed inside the script like so: $1, $2, etc. This makes passing information from a parent script to a child script trivial.
Calling a system command from within awk. This can be very useful. For example, if you want to output epoch time for a date string that is input to awk using an external program called "epoch", then try this. The substr command just takes the target fields and subselects a chunk from them. In this case, you end up feeding a date string like this into epoch "2009/03/10 23:22:19". Then you cut the output of epoch so only the seconds string is left to write to /tmp/infile. Then suck /tmp/infile back up with the "getline" awk command and put it in variable "et". Then print "et" out in standard C 17.5f format. For more info on getline, see here.
awk '{system("/opt/antelope/4.10/bin/epoch "substr($20,1,4)"/"substr($20,5,2)"/"substr($20,7,2)" "$21" | /usr/bin/cut -c1-15 > /tmp/infile")}{getline et < "/tmp/infile"}{printf "%17.5f\n",et}' $wfdisc
Trexcerpt Examples
Create a new CSS volume from an existing one.
Only extract all BHZ channels for the time period 2006-112 17:03:34 to 2006-118 00:00:00 and make the binary data in i4 format (intel 4-byte float):
trexcerpt -o i4 -s 'chan=="BHZ"' in newdir/out "2006-112 17:03:34" "2006-118 00:00:00"
Now take all BH[ENZ] channels:
trexcerpt -o i4 -s 'chan=="BHE"' -s 'chan=="BHN"' -s 'chan=="BHZ"' in newdir/out "2006-112 17:03:34" "2006-118 00:00:00"
Extract several station/channel pairs simultaneously.
trexcerpt -o f4 -c "(sta=~/CELLO1/ && chan=~/p1f32/) || (sta=~/CELLO1/
&& chan=~/p2f32/) || (sta=~/CELLO1/ && chan=~/p3f32/ )" all newdir/
here "2009-252 00:00:00" "2009-252 00:01:00"
A more concise way is:
trexcerpt -o f4 -c "sta=~/CELLO1/ && chan=~/p[123]f32/)" all newdir/
here "2009-252 00:00:00" "2009-252 00:01:00"