Skip to content

Commit

Permalink
Merge pull request #1507 from obspy/sac_default_booleans
Browse files Browse the repository at this point in the history
Default SAC boolean headers when writing ObsPy trace?
  • Loading branch information
krischer committed Aug 22, 2016
2 parents e807228 + f74e0f5 commit 23e0208
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
@@ -1,6 +1,10 @@
1.0.3:
- obspy.io.mseed:
* ObsPy can now also read (Mini)SEED files with noise records. (see #1495)
- obspy.io.sac:
* `SACTrace.lpspol` and `lcalda` are `True` and `False` by default, when
created via `SACTrace.from_obspy_trace` with a `Trace` that has no SAC
inheritance. (see #1507)

1.0.2: (doi: 10.5281/zenodo.49636)
- obspy.core:
Expand Down
4 changes: 2 additions & 2 deletions obspy/io/sac/sactrace.py
Expand Up @@ -298,10 +298,10 @@
kcmpnm = EHZ
knetwk = BW
kstnm = RJOB
lcalda = True
lcalda = False
leven = True
lovrok = True
lpspol = False
lpspol = True
npts = 3000
nvhdr = 6
nzhour = 0
Expand Down
10 changes: 10 additions & 0 deletions obspy/io/sac/tests/test_core.py
Expand Up @@ -874,6 +874,16 @@ def test_not_ascii(self):
self.assertEqual(tr.stats.channel, 'HHE')
self.assertEqual(tr.stats.network, '')

def test_sac_booleans_from_trace(self):
"""
SAC booleans "lcalda" and "lpspol" should be "False" and "True",
respectively, by default when converting from a "Trace".
"""
tr = Trace()
sac = SACTrace.from_obspy_trace(tr)
self.assertFalse(sac.lcalda)
self.assertTrue(sac.lpspol)


def suite():
return unittest.makeSuite(CoreTestCase, 'test')
Expand Down
3 changes: 3 additions & 0 deletions obspy/io/sac/util.py
Expand Up @@ -406,6 +406,9 @@ def obspy_to_sac_header(stats, keep_sac_header=True):
header['knetwk'] = stats['network'] if stats['network'] else HD.SNULL
header['khole'] = stats['location'] if stats['location'] else HD.SNULL

header['lpspol'] = True
header['lcalda'] = False

# ObsPy issue 1204
header['nvhdr'] = 6
header['leven'] = 1
Expand Down

0 comments on commit 23e0208

Please sign in to comment.