# Commonly used and basic commands in SAC :::warning Learning resources https://web.mst.edu/~sgao/manuals/sac_manual.pdf http://geophysics.eas.gatech.edu/people/zpeng/Teaching/Sac_Tutorial_2006/ https://moodle.glg.miamioh.edu/brudzimr/tutorials/SAC/ https://seisman.github.io/SAC_Docs_zh/ https://ds.iris.edu/files/sac-manual/manual/tutorial.html ::: ## Installation Please refer to [installation tutorial](https://hackmd.io/@kmo/notes_sac_install) ## Read, sort, and plot SAC files **Read files** `r *.SAC` read all file end with .SAC `r more` read more **Rearrange** `sort x` sort by x (attributes in sac file) `sort distance` sort by distance `sort a` sort by "a" marker **Parser** `rtr` remove trend `rmean` remove mean `int` intergrate onece (積分) acc.-> vel.->disp. `dif` differentiate (微分) disp.-> vel-> acc. `cut 10 50` `cut o+10 o+50` cut the data from 10 to 50 (values in x axis) `r *.sac` read the files that need to be cut after cut command **Display** `qdp off` turn off quick dirty plot, for finer resolution `xlim t1 -5 t3 +50` show range of x axis from t1-5 to t3+50 (command before ppk or p) `xlim o -10 +20` show range from o-10 to o+20 **Plot** `p` plot by default (one file on one page) `p1` plot all files, which has been read, in 1 page ## Filter waveforms `bp` band pass `lp`,`hp` low pass and high pass `bp n 4 p 2 c 0.02 0.08` n 4 : channel p 2 : pole c 0.02 0.08: frequecny range (Hz) ## Mark time on waveforms `ppk p 3 m on` ppk -> picking mode; p 3 -> one page 3 files; m on -> makeall on (mark all file at the same time) `ppk p 4` picking mode, show 4 files, mark one by one `a`,`t1`...`t5` markers `n` next page `b` back to the last one page Use mouse to pick two time points for zooming in `x` zoom out `k` temporally quit :::danger `wh` write all the change during this round; save the header `q or quit` exit (no change will be made and exit) ::: ## Write files `w over` overwrite the file that is in read now with the same file name `w newname.SAC` write/save as a newfile.SAC `w append .bp` write as a new file, using original name append with ".bp" ## List SAC headers `lh` list all headers after read files `saclst kztime kzdate stlo stla stel delta a t1 o f *` list noted headers from file(f) * `saclst evlo evla gcarc kzname f *| sort -nk2` combined with sorting command in linux, sort the second column (i.e., evlo here) `-r` list reversely >For SAC header variables, please check: https://ds.iris.edu/files/sac-manual/manual/file_format.html ## Write header in SAC files `chhdr` --- # Advanced commands * Convert data between SAC binary and ASCII files * Write macro file for batch processing: macro *.m * generate function `fungen` or `fg` generate function `FG IMPULSE NPTS 100 DELTA 0.1` `fft` `plotsp` or `psp` plot spectrum `psp am` plot amplitude `convolve` do convolution with the first file `correlate` do cross correlation wtih the first file --- # Plot SAC with GMT ## map view plotting ## seismogram and profiles --- TauP: travel time calculation >http://geophysics.eas.gatech.edu/people/zpeng/Teaching/EAS8803_S08/ttime/ > ```taup_time -mod prem -h 200 -ph S,P -deg 57.4``` --- SAC> syn SAC> ppk p 5 m on SAC> sss Signal Stacking Subprocess. SAC/SSS> prs SAC/SSS> hp cor 1