Tuesday, December 8, 2015

Converting JWeed event files to julian days (new for 2015)

JWeed event files identify earthquakes in month-day format, but seismic data filenames follow Julian-day format. Unless you have a magic patch of brain cells that converts the calendar to julian days, this is a big hassle when matching files with events. I adapted a little fortran code to convert, and some awk lines that convert a JWeed event file into a format that is used by other codes to pre-process body wave data. Here are the awk lines:

sed 's/,/ /g' events*.events | sed 's[-[ [g' >! blob.dat
awk '{print "echo " $3 " " $4 " " $2 " >! blobb; echo " $0 " >>blobb ; Julian1 < blobb >> ev_julian " }' blob.dat >! c_events

IF THE EVENT INFO IS IN A JWEED SUMMARY FILE, start with extracting the EVENT lines, then remove the dashes, but only the first two (NOT the minus signs on latitude and longitude!), then sort the events from earliest to latest, then generate a command file to invoke the Julian1 utility.  Remember to change the first line of command file c_events (from >> to >!) to create the file ev_julian.

grep EVENT RAR_events.summary >! RAR.events
sed 's/,/ /g' RAR.events | sed 's[-[ [' | sed 's[-[ [' >! blobb.dat
sort blobb.dat >! blob.dat
awk '{print "echo " $3 " " $4 " " $2 " >! blobb; echo " $0 " >>blobb ; Julian1 < blobb >> ev_julian " }' blob.dat >! c_events

optional to remove extra "words" from blob.dat:
sed 's/xxxx yyyyy//g' c_events >! c_ev

cd RAR (from the Teleseismic directory)
ls *.SAC >! infiles_raw
cp ../ev_julian events_rawlist
cp infiles_raw infiles1
te events &
te infiles1 &

the JWeed event filenaming convention (for me) is events_YYYY.events, with variants. The first step strips the syntax separating numbers in the events file, so that awk can parse the numbers. The second line creates a command file c_events that uses Julian1 to read the output of the awk step. You must change the ">> ev_julian" in the first line to ">! ev_julian" so that the event file ev_julian is created to write into when you "source c_events"    The optional step takes out some superfluous matter from c_events, then you "source c_ev" to make ev_julian. I rename this file events.julian as a template for the file "events" that each station needs in preprocessing (see previous post).

Oh yes, there is a Fortran code

c program Julian1
c f77 -o /Users/jjpark/bin/Julian1 Julian1.f
character string*80
dimension mmonth(12)
data mmonth/0,31,59,90,120,151,181,212,243,273,304,334/
c print *,'enter month, day, year'
read(5,*) jmo,jd,jy
if(jmo.gt.2) jd_julian=jd_julian+leap
c print *,'julian day = ',jd_julian
read(5,101) string
print 102,jy,jd_julian,string
101 format(a)
102 format(2i5,4x,a)