obspy.io.sac.util.obspy_to_sac_header
- obspy_to_sac_header(stats, keep_sac_header=True)[source]
Merge a primary with a secondary header, reconciling some differences.
- Parameters:
stats (dict or
Stats
) – Filled ObsPy Stats headerkeep_sac_header (bool) –
If keep_sac_header is True, old stats.sac header values are kept, and a minimal set of values are updated from the stats dictionary according to these guidelines:
npts, delta always come from stats
If a valid old reftime is found, the new b and e will be made and properly referenced to it. All other old SAC headers are simply carried along.
If the old SAC reftime is invalid and relative time headers are set, a SacHeaderError exception will be raised.
If the old SAC reftime is invalid, no relative time headers are set, and “b” is set, “e” is updated from stats and other old SAC headers are carried along.
If the old SAC reftime is invalid, no relative time headers are set, and “b” is not set, the reftime will be set from stats.starttime (with micro/milliseconds precision adjustments) and “b” and “e” are set accordingly.
If ‘kstnm’, ‘knetwk’, ‘kcmpnm’, or ‘khole’ are not set or differ from Stats values ‘station’, ‘network’, ‘channel’, or ‘location’, they are taken from the Stats values.
If keep_sac_header is False, a new SAC header is constructed from only information found in the Stats dictionary, with some other default values introduced. It will be an iztype 9 (“ib”) file, with small reference time adjustments for micro/milliseconds precision issues. SAC headers nvhdr, level, lovrok, and iftype are always produced.
- Rtype merged:
dict
- Returns:
SAC header