Dear all, I am using sac since about 2 months and need help in writing events parameters into sac headers as the following details:
I have more than 400 events as sac files, and a text file containing events parameters" evla, evlo, evdp, mag" . I am trying to find a macro or shell script in any language to read these parameters from file and insert them in sac file's header.
I prepare all sac files with names like " 1.sac, 2.sac, ..." and the same in text file data "line1: contains event number 1 parameters and so on".
thats mean : read from line 1 and write in 1.sac for all. it is very hard to do individually and I don't know programming, Anyone help me please by this code.
Thanks All
wadah
I have more than 400 events as sac files, and a text file containing events parameters" evla, evlo, evdp, mag" . I am trying to find a macro or shell script in any language to read these parameters from file and insert them in sac file's header.
I prepare all sac files with names like " 1.sac, 2.sac, ..." and the same in text file data "line1: contains event number 1 parameters and so on".
thats mean : read from line 1 and write in 1.sac for all. it is very hard to do individually and I don't know programming, Anyone help me please by this code.
Thanks All
wadah
-
Dear Dr. Waddah,
Assuming you have you have a punch of SAC files (like 2009.*.SAC`) and you have a text file (for instance, called headinfo.txt ), containing the events information such as the following format, (where the columns written as EVLA EVLO EVDP MAG FILENAME):
-----------
25.0 37.0. 1.0 3.0 2009.139.17.30.58.0000.SG.HAQS..BHZ.D.SAC
25.1 37.1 1.5 3.1 2009.139.17.30.58.0000.SG.HQLS..BHZ.D.SAC
25.2 37.2 2.0 3.2 2009.139.17.30.58.0000.SG.MDRS..BHZ.D.SAC
25.3 37.3 2.5 3.3 2009.139.17.30.58.0000.SG.UMJS..BHZ.D.SAC
................etc
----------------
Then, one of the option is to use the following script which go through all sac files as in the list above and change any header info you would like to change.....
#####------------------Script starts here ----
#!/bin/bash
# rm ./prep_sacfile
files=`ls 2009*SAC`
for file in $files; do
olat=`cat headinfo.txt | grep "$file" | awk '{print $1}'`
olon=`cat headinfo.txt | grep "$file" | awk '{print $2}'`
dep=`cat headinfo.txt | grep "$file" | awk '{print $3}'`
mag=`cat headinfo.txt | grep "$file" | awk '{print $4}'`
ahlan=`echo $olat $olon $dep $mag | awk '{print $1,$2,$3,$4}'`
echo $ahlan
cat >> ./prep_sacfile << ENDSAC
r $file
ch evla $olat
ch evlo $olon
ch evdp $dep
ch mag $mag
wh
w over
ENDSAC
done
sac prep_sacfile
#####------------------Script ends here and you quit sac----
I hope this helps
Cheers, Mohammad Youssof
-
Dear Dr. Waddah,
Answering your question you sent about adding the origin time, yes, we can add the origin time as well as any other header information.
The origin offset is already given by the OMARKER field.
Let's assume an OMARKER = 1800 seconds and you have KZTIME = 09:00:09.18 .
,where the OMARKER is the difference between the exact origin time and the reference time (KZTIME).
Therefore, KZTIME + OMARKER = 09:00:09.18 + 1800 seconds = 09:30:09.18 is the origin time.
Let me know if you have further questions with this regards.
Cheers, Mohammad Youssof
-
Many thanks Dr. Mohammed for help.
Cheers
Wadah
-
-