-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_mkHypoDDnoERR.pl
executable file
·68 lines (55 loc) · 2.05 KB
/
db_mkHypoDDnoERR.pl
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/env perl
#-----------------------
# db_mkHypoDD.pl -MCW
# Antelope database perl script
#
# Produces a "phase.dat"-style pickfile for hypoDD
# from an Antelope CSS 3.0 database
#
# you must have perl package "Datascope.pm"
# the "use lib" line points to where antelope keeps it
#
# USAGE: db_mkHypoDD.pl my_database
# Database must contain 'origin', 'assoc', and 'arrival' tables
# OUTPUT: file "hdd_picks.dat"
use lib "$ENV{ANTELOPE}/data/perl/";
use Datascope;
$dbname = $ARGV[0];
$outfile = "hdd_picks.dat";
open(FILEOUT, ">" , $outfile) or die "Can't open $outfile: $!";
print "Reading database: $dbname\n";
@db = dbopen("$dbname", "r");
@dbo = dblookup(@db, "" , "origin" , "", "" );
@dbe = @dbo;
$nrecords = dbquery(@dbo, "dbRECORD_COUNT");
$err = 0.000;
$rms = 0.00;
for ( $dbe[3] = 0; $dbe[3] < $nrecords; $dbe[3]++ ) {
($olat,$olon,$otime,$odepth,$omag,$orid) = dbgetv(@dbe,qw(lat lon time depth mb orid));
$odatetime = epoch2str($otime,'%Y %m %d %H %M %S.%s');
$ostrtime = strtime($otime);
print FILEOUT "# $odatetime $olat $olon $odepth $omag $err $err $rms $orid\n";
@db = dbsubset(@dbo,"orid==$orid");
@db = dbjoin(@db, dblookup(@db, "", "assoc", "" ,""));
@db = dbjoin(@db, dblookup(@db, "", "arrival", "", ""));
$nassoc = dbquery(@db, "dbRECORD_COUNT");
for ( $db[3] = 0; $db[3] < $nassoc; $db[3]++ ) {
($sta, $arrtime, $deltim, $iphase) = dbgetv(@db, qw(sta arrival.time deltim iphase));
if ($sta =~ /TAKO/ || $sta =~ /MEGW/) {
print "Removed sta $sta from event $orid.\n";}
else {
$travtim = $arrtime-$otime;
$phase = substr($iphase,0,1);
$weight = $deltim;
SWITCH: {
if ($weight <= 0.05) { $weight = 1.00; last SWITCH;}
if ($weight <= 0.1) { $weight = 0.50; last SWITCH;}
if ($weight <= 0.2) { $weight = 0.25; last SWITCH;}
if ($weight <= 0.4) { $weight = 0.12; last SWITCH;}
else { $weight = 0.00; last SWITCH;}
} #switch
printf FILEOUT "$sta %2.3f $weight $phase\n" ,$travtim;
} #else
}#for
}#for
print "Wrote hypoDD pickfile: $outfile\n"