pysep.utils.cap_sac
#
Utils to honor file formats from SAC and CAP
- For SAC header names and descriptions, see:
http://www.adc1.iris.edu/files/sac-manual/manual/file_format.html
Module Contents#
Functions#
|
Write CAP (Cut-and-Paste) moment tensor inversion code weight files, |
|
Wrapper for trace header appending to get a loop and some logic in |
|
Append SAC headers to ObsPy streams given event and station metadata. |
|
Add TauP travel times to the SAC headers using information in the SAC header |
SAC headers do not update when rotating so we need to apply manual |
|
|
Build a UTCDateTime origin time from values in the SAC header appended to |
Attributes#
- pysep.utils.cap_sac.write_cap_weights_files(st, path_out='./', order_by='dist')[source]#
Write CAP (Cut-and-Paste) moment tensor inversion code weight files, assuming that SAC headers are already present.
TODO re-add Ptime setting with event.picks
Replaces write_cap_weights
The weight file has columns corresponding to the following:
0: EVENT_STATION_ID 1: DIST_KM 2: BODY_Z 3: BODY_R 4: SURF_Z 5: SURF_R 6: SURF_T 7: P_ARRIVAL 8: LEGACY (unused) 9: S_ARRIVAL 10: LEGACY (unused) 11: STATIC CORRECTION RAYLEIGH
- Parameters:
st (obspy.core.stream.Stream) – input stream to use to write CAP weight files, expected to have SAC header
path_out (str) – path to write the weight file, filenames are set by default inside the function
order_by (str) – how to order the list of stations that gets written out available options are: * dist: order by smallest to largest source-receiver distance (default) * az: order by smallest to largest azimuth (deg) * code: order alphabetically by station name
- pysep.utils.cap_sac.append_sac_headers(st, event, inv)[source]#
Wrapper for trace header appending to get a loop and some logic in
- Parameters:
st (obspy.core.stream.Stream) – Stream to append SAC header to
event (obspy.core.event.Event) – Event with metadata for SAC header
event – StationXML with metadata for SAC header
- Return type:
obspy.core.stream.Stream
- Returns:
Stream with SAC headers, those that could not be appended to have been removed from the stream
- pysep.utils.cap_sac._append_sac_headers_trace(tr, event, inv)[source]#
Append SAC headers to ObsPy streams given event and station metadata. Also add ‘back_azimuth’ to Stream stats which can be used for rotation.
Rewritten from: util_write_cap.add_sac_metadata()
- TODO Add back in information removed from original function
Add sensor type somewhere, previously stored in KT? (used for picks)
Note
We explicitely set ‘iztype, ‘b’ and ‘e’ in the SAC header to tell ObsPy that the trace start is NOT the origin time. Otherwise all the relative timing (e.g., picks) will be wrong.
- Parameters:
tr (obspy.core.trace.Trace) – Trace to append SAC header to
event (obspy.core.event.Event) – Event with metadata for SAC header
event – StationXML with metadata for SAC header
- Return type:
obspy.core.trace.Trace
- Returns:
Trace with appended SAC header
- pysep.utils.cap_sac.format_sac_header_w_taup_traveltimes(st, model='ak135', phase_list=('ttall',))[source]#
Add TauP travel times to the SAC headers using information in the SAC header Also get some information from TauP regarding incident angle, takeoff angle Hardcoded to only look at P and S arrivals (both upgoing and downgoing)
TODO Probably find better ways to store arrival time and incident angles
Note
This function expects that the Stream has been formatted with SAC header
Note
SAC header writing could probably be in a loop, but I think it’s more readable to see P and S values getting written separately.
- Parameters:
st (obspy.core.stream.Stream) – Stream object with SAC headers which will be written to with new SAC header attributser
model (str) – name of the TauP model to use for arrival times etc. defaults to ‘ak135’
phase_list (list of str) – phase names to get ray information from TauP with. Defaults to ‘ttall’, which is ObsPy’s default for getting all phase arrivals. Must match Phases expected by TauP (see ObsPy TauP documentation for acceptable phases).
- pysep.utils.cap_sac.format_sac_headers_post_rotation(st)[source]#
SAC headers do not update when rotating so we need to apply manual changes to the azimuth, inclination and naming values
- TODO is this necessary? Who is using the SAC headers and what info
do they need? Or can we just re-run SAC header appending?
- Parameters:
st (obspy.core.stream.Stream) – Stream to append SAC headers for
- pysep.utils.cap_sac.origin_time_from_sac_header(sac_header)[source]#
Build a UTCDateTime origin time from values in the SAC header appended to an ObsPy trace.
- Parameters:
sac_header (obspy.core.util.attribdict.AttribDict) – SAC header built by append_sac_header()
- Return type:
UTCDateTime
- Returns:
event origin time built from SAC header