Skip to content

Commit fdd9e8b

Browse files
committed
perl script to extract hypocenter (only) data from JMA deck files
1 parent 43e9c34 commit fdd9e8b

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

bin/deck2csv.pl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/perl
2+
3+
# JMA REDC.DECK fomat ¤«¤é ¿Ì¸»¾ðÊó¤ò¼è¤ê½Ð¤¹¥¹¥¯¥ê¥×¥È
4+
# 98.10.22 tsuru
5+
6+
# printf("year;month;day;hour;minute;second;longitude;latitude;depth;magnitude\n");
7+
8+
# running like this:
9+
# time for file in $(ls ../../deckfiles/??????*.deck.Z | sort); do uncompress -c $file; done | time ./deck2csv.pl > ../../JMA-hypocenter-timestamp.csv
10+
11+
12+
printf("timestamp;longitude;latitude;depth;magnitude\n");
13+
14+
while(<>){
15+
chop;
16+
if ( /^J/ ) {
17+
$cmag = substr($_, 52, 2);
18+
s/ /0/g;
19+
$yr = substr($_, 1, 4);
20+
$mo = substr($_, 5, 2);
21+
$dy = substr($_, 7, 2);
22+
$hr = substr($_, 9, 2);
23+
$mi = substr($_, 11, 2);
24+
25+
# $sc = substr($_, 13, 4); $sc = $sc/100.0;
26+
$sc = substr($_, 13, 2);
27+
$sf = substr($_, 15, 2); $sf = $sf * 10000;
28+
29+
# $dt = substr($_, 17, 4); $dt = $dt/100.0;
30+
$latd = substr($_, 21, 3);
31+
$latm = substr($_, 24, 4);
32+
$lat = $latd + $latm/(100.0*60.0);
33+
$elat = substr($_, 28, 4); $elat = $elat/(100.0*60.0);
34+
$lond = substr($_, 32, 4);
35+
$lonm = substr($_, 36, 4);
36+
$lon = $lond + $lonm/(100.0*60.0);
37+
$elon = substr($_, 40, 4); $elon = $elon/(100.0*60.0);
38+
$dep = substr($_, 44, 5); $dep = $dep/100.0;
39+
$edep = substr($_, 49, 3);
40+
if ( $edep eq '000' ) {
41+
$edep = 1.0;
42+
} else {
43+
$edep = $edep/100.0;
44+
}
45+
# $cmag = substr($_, 52, 2);
46+
$mflag = substr($_, 52, 1);
47+
$m = substr($_, 53, 1);
48+
if ( $mflag eq 'A') { $cmag = '-1' . $m; }
49+
if ( $mflag eq 'B') { $cmag = '-2' . $m; }
50+
if ( $mflag eq 'C') { $cmag = '-3' . $m; }
51+
$mag = $cmag; $mag = $mag/10.0;
52+
if ( $cmag ne ' ' ) {
53+
printf("%04d-%02d-%02dT%02d:%02d:%02d.%06d+0900;", $yr, $mo, $dy, $hr, $mi, $sc, $sf);
54+
printf("%.4f;%.4f;%.2f;%.3f\n", $lon, $lat, $dep, $mag);
55+
# printf("%04d;%02d;%02d;%02d;%02d;%.2f;", $yr, $mo, $dy, $hr, $mi, $sc);
56+
# printf("%.4f;%.4f;%.2f;%.3f\n", $lon, $lat, $dep, $mag);
57+
}
58+
}
59+
}
60+
61+
62+
# J2013010100033169 015 372521 029 1412406 076 279510616V 511 2 69E OFF FUKUSHIMA PREF 30K

0 commit comments

Comments
 (0)