#!/bin/sh
#
# Scans HARVARD formatted output and converts it to PDPC input.
# ftp://saf.harvard.edu/CMT/allorder.dek
# Usage: "create_catalog_harvard.sh < input > output"

awk '
BEGIN{ count = 0; }
{
   if (count % 4 == 0)
   {
      month = substr($0,10,2) * 1.0
      day   = substr($0,13,2) * 1.0
      year  = substr($0,16,2) + 1900

      lat   = substr($0,31,6) * 1.0
      lon   = substr($0,38,6) * 1.0

      mag = substr($0,50,3) * 1.0

      if ((lat!=0)&&(lon!=0)&&(mag>3.0)) {print year,month,day,lon,lat,mag}
   }

   count++;
}
'

