[SAC-HELP] How to concatenate several sac files

Mei Xue meixue.geo at gmail.com
Tue Jan 13 06:35:37 PST 2009


I use merge commands. The following is the shell script I use:

## merge the data segmental files from the same station to one file
## and remove the extra segmental files for that station
## merge before simplify file name, as which can cause some files overwritten
foreach wave (BHZ BHE BHN HHZ HHE HHN BH1 BH2 BH3 HH1 HH2 HH3 EHZ EHE
EHN EH1 EH2 EH3)
  ls -1 *.$wave.*SAC | gawk -F. '(NR>=1){if($1==station){printf("merge
%s\n w over\n",$0)} else{station=$1;printf("r %s\n",$0)}}' >! m
erge.tmp
  echo q >> merge.tmp
  sac2000 merge.tmp
  ls -1 *.$wave.*SAC | gawk -F. '(NR>=1){if($1==station){printf("rm -f
%s\n",$0)} else{station=$1}}' >! rmsegments.tmp
  chmod 777 rmsegments.tmp
  rmsegments.tmp
end

Note: here I rename all the files in a certain sequence, and the
following is the shell script I used to process the raw sac files
extracted using rdseed:
## reorder file names to make station name 1st, channel name 2nd, for
the convenience of
## merging files for the same station; and keep all other information
to make sure
## no files is overwritten
ls -1 *.?HE.*SAC | awk -F. '{ printf "mv %s
%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s\n",$0,$8,$10,$1,$2,$3,$4,$5,$6,$7,$9,$11,$12}'
>! rena
me.tmp
ls -1 *.?HN.*SAC | awk -F. '{ printf "mv %s
%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s\n",$0,$8,$10,$1,$2,$3,$4,$5,$6,$7,$9,$11,$12}'
>> rena
me.tmp
ls -1 *.?HZ.*SAC | awk -F. '{ printf "mv %s
%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s\n",$0,$8,$10,$1,$2,$3,$4,$5,$6,$7,$9,$11,$12}'
>> rena
me.tmp
ls -1 *.?H[123].*SAC | awk -F. '{ printf "mv %s
%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s.%s\n",$0,$8,$10,$1,$2,$3,$4,$5,$6,$7,$9,$11,$12}'
>>
rename.tmp
chmod 777 rename.tmp
rename.tmp

Hope it helps,

Mei Xue

2009/1/13, Graça Silveira <mdsilveira at fc.ul.pt>:
> Dear All
>
>  Does someone know a sac command (or several in a script) to concatenate
>  several sac files?
>
>  Thanks
>
>  Graça Silveira
>
>
>  --
>  Graça Silveira
>  Professora Adjunta
>
>  Área Científica de Física
>  Instituto Superior de Engenharia de Lisboa
>  Rua Conselheiro Emídio Navarro
>  1959-007 Lisboa
>  tel: 218317135
>
>  Centro de Geofísica da Universidade de Lisboa
>  Edifício C8
>  Campo Grande
>  1749-016 LISBOA
>  email: mdsilveira at fc.ul.pt
>  tel: 217500812
>
>  _______________________________________________
>  sac-help mailing list
>  sac-help at iris.washington.edu
>  http://www.iris.washington.edu/mailman/listinfo/sac-help
>




More information about the sac-help mailing list