-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_mapOBShdr.pl
More file actions
executable file
·46 lines (36 loc) · 1.04 KB
/
db_mapOBShdr.pl
File metadata and controls
executable file
·46 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env perl
#
# db_mapOBShdr.pl -by Mark
# Usage:
#
# Maps headers to proper sta/chan names using
# a template file
use lib "$ENV{ANTELOPE}/data/perl/";
use Datascope;
$template = $ARGV[1];
$site_db = $ARGV[0];
$table_count = 0;
@db = dbopen("$site_db", "r+");
@db = dblookup(@db, "" , "wfdisc" , "", "" );
#-- Make hashes from the template file --#
open(TEMP, "<$template");
TEMPLINE: while (<TEMP>) { next TEMPLINE if m/\#|\{|\}/;
# Read in values
chomp;
($head1,$head2) = split();
($sta1,$chan1,$loc1,$net1,$sps1) = split(":",$head1);
($sta2,$chan2,$loc2,$net2) = split(":",$head2);
$chid = sprintf("${chan1}_%3.1f",$sps1);
# Build hashes
$sta{$sta1} = $sta2;
$chan{$chid} = $chan2;
}
#-- Get old sta/chan, replace with new values from hash --#
$nrecs = dbquery(@db, "dbRECORD_COUNT");
for ( $db[3]=0; $db[3]<$nrecs; $db[3]++ ) {
($dbsta,$dbchan,$dbfs) = dbgetv(@db,"sta","chan","samprate");
$dbchid = sprintf("${dbchan}_%3.1f",$dbfs);
dbputv(@db,"sta",$sta{$dbsta},"chan",$chan{"$dbchid"});
}
close(TEMP);
dbclose(@db);