-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhypodd2gmt.pl
More file actions
executable file
·56 lines (46 loc) · 1.43 KB
/
hypodd2gmt.pl
File metadata and controls
executable file
·56 lines (46 loc) · 1.43 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
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/env perl
#
# hypodd2gmt.pl locfile outfile
# -by Mark 2009-274
# takes line catalog info from hypoDD reloc file
# and writes to standard out for use with GMT
#
# See hypoDD Open File Report by Waldhauser for specs
# NOTES:
# Magnitudes of 0.0 are change to 1.5 so they will show up on a map
#
# This is set up to make a "lon lat magscale" file
# for a topographic style map with relative sizes for magnitude
# could be changed for a depth style map or to include the error bars
use Getopt::Std;
$help = <<"EOF";
Usage: hypodd2gmt [locfile] [>> outfile]
locfile - hypoDD file './hypoDD.reloc' is default
EOF
getopts('h');
$flag = print "$help" if $opt_h;
MAIN: { last MAIN if $flag;
# if no input file, specify hypoDD.reloc
if (@ARGV < 1) {
$infile = "hypoDD.reloc";
}
elsif (-d $ARGV[0]) {
$infile = "$ARGV[0]/hypoDD.reloc";
}
else {
$infile = $ARGV[0];
}
open(FILEIN, "<$infile") or die "Can't open $infile: $!";
# this doesn't work, flags not available in MacOSX?? check man open(2)
#sysopen(FILEOUT, $outfile, O_EXCL | O_CREAT | O_WRONLY) or die "Can't open $outfile: $!";
while (<FILEIN>) {
chomp;
($hid,$lat,$lon,$dep,$x,$y,$z,$dx,$dy,$dz,$yr,$mth,$day,$hr,$mn,$snd,$mag,$nccp,$nccs,$nctp,$ncts,$rcc,$rct,$cid) = split(" ",$_);
#$lat = sprintf('%2.4f',$lat);
#$lon = sprintf('%3.4f',$lon);
$mag = 1.5 if ($mag == 0.0);
$magscale = $mag/10;
print "$lon $lat $magscale\n";
}
close(FILEIN);
} # MAIN