kasra-hosseini / obspyDMT

A Python toolbox for the query, retrieval, processing and management of seismological data sets, including very large, heterogeneous and/or dynamically growing ones.
http://kasra-hosseini.github.io/obspyDMT/
Other
89 stars 58 forks source link

Calculate azimuth, SAC format #61

Closed kasra-hosseini closed 3 years ago

kasra-hosseini commented 3 years ago

I received an email asking

there is no Azimuth info on the SAC header, and reading your ObspyDMT's paper I notice that there is no mention about this particular information being saved in any file.

Azimuth can be computed using SAC headers (or similarly, by using station_event files stored in info directories), e.g.:

  1. Download waveforms (note: --waveform_format sac, it is possible to compute azimuth using station_event files even if the waveform format is not set to SAC)
obspyDMT --datapath event_based_dir --min_date 2014-01-01 --max_date 2015-01-01 --min_mag 7.8 --event_catalog NEIC_USGS --data_source IRIS --net "II" --loc "00" --cha "BHZ" --preset 100 --offset 1800 --waveform_format sac --instrument_correction --req_parallel --req_np 4 --parallel_process --process_np 4 --test 10 
  1. Compute azimuth
from obspy import read
from obspy.geodetics import gps2dist_azimuth
st_test = read("./event_based_dir/20140401_234647.a/processed/II.AAK.00.BHZ")
tr_test = st_test[0]
dist, azi, bazi = gps2dist_azimuth(tr_test.stats.sac["evla"], tr_test.stats.sac["evlo"], tr_test.stats.sac["stla"], tr_test.stats.sac["stlo"])
  1. Results
print(dist, azi, bazi)
15884171.735157024 43.83614331946817 297.6450250332194