{"action":"created","comment":{"url":"https://api.github.com/repos/obspy/obspy/pulls/comments/34403732","id":34403732,"diff_hunk":"@@ -0,0 +1,637 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"\n+Low-level array interface to the SAC file format.\n+\n+Functions in this module work directly with numpy arrays that mirror the SAC\n+format.  The 'primitives' in this module are the float, int, and string header\n+arrays, the float data array, and a header dictionary. Convenience functions\n+are provided to convert between header arrays and more user-friendly\n+dictionaries.\n+\n+These read/write routines are very literal; there is almost no value or type\n+checking, except for byteorder and header/data array length.  File- and array-\n+based checking routines are provided for additional checks where desired.\n+\n+\"\"\"\n+from __future__ import (absolute_import, division, print_function,\n+                        unicode_literals)\n+from future.utils import native_str\n+from future.builtins import *\n+\n+import sys\n+import warnings\n+\n+import numpy as np\n+\n+from obspy.core.compatibility import from_buffer\n+\n+from ..sac import header as HD\n+from .util import SacIOError, SacInvalidContentError\n+from .util import is_valid_enum_int, is_same_byteorder, byteswap\n+\n+\n+def init_header_arrays(*args):\n+    \"\"\"\n+    Initialize arbitrary header arrays.\n+\n+    Parameters\n+    ----------\n+    which : str, {'float', 'int', 'str'}\n+        Specify which arrays to initialize, and desired order.\n+        If omitted, returned arrays are ('float', 'int', 'str').\n+\n+    Returns\n+    -------\n+    arrays : list of numpy.ndarrays\n+        The desired SAC header arrays.\n+\n+    \"\"\"\n+    if len(args) == 0:\n+        args = ('float', 'int', 'str')\n+    #http://stackoverflow.com/a/13052254/745557","path":"obspy/io/sac/arrayio.py","position":51,"original_position":51,"commit_id":"3943b96a2d729cc8cfc41bbd1ad28125b3b7c1f8","original_commit_id":"3943b96a2d729cc8cfc41bbd1ad28125b3b7c1f8","user":{"login":"QuLogic","id":302469,"avatar_url":"https://avatars.githubusercontent.com/u/302469?v=3","gravatar_id":"","url":"https://api.github.com/users/QuLogic","html_url":"https://github.com/QuLogic","followers_url":"https://api.github.com/users/QuLogic/followers","following_url":"https://api.github.com/users/QuLogic/following{/other_user}","gists_url":"https://api.github.com/users/QuLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/QuLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuLogic/subscriptions","organizations_url":"https://api.github.com/users/QuLogic/orgs","repos_url":"https://api.github.com/users/QuLogic/repos","events_url":"https://api.github.com/users/QuLogic/events{/privacy}","received_events_url":"https://api.github.com/users/QuLogic/received_events","type":"User","site_admin":false},"body":"Sure, but see @krischer's other comment.","created_at":"2015-07-10T23:06:45Z","updated_at":"2015-07-10T23:06:45Z","html_url":"https://github.com/obspy/obspy/pull/1092#discussion_r34403732","pull_request_url":"https://api.github.com/repos/obspy/obspy/pulls/1092","_links":{"self":{"href":"https://api.github.com/repos/obspy/obspy/pulls/comments/34403732"},"html":{"href":"https://github.com/obspy/obspy/pull/1092#discussion_r34403732"},"pull_request":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1092"}}},"pull_request":{"url":"https://api.github.com/repos/obspy/obspy/pulls/1092","id":39603746,"html_url":"https://github.com/obspy/obspy/pull/1092","diff_url":"https://github.com/obspy/obspy/pull/1092.diff","patch_url":"https://github.com/obspy/obspy/pull/1092.patch","issue_url":"https://api.github.com/repos/obspy/obspy/issues/1092","number":1092,"state":"open","locked":false,"title":"Sac rewrite","user":{"login":"jkmacc-LANL","id":6475152,"avatar_url":"https://avatars.githubusercontent.com/u/6475152?v=3","gravatar_id":"","url":"https://api.github.com/users/jkmacc-LANL","html_url":"https://github.com/jkmacc-LANL","followers_url":"https://api.github.com/users/jkmacc-LANL/followers","following_url":"https://api.github.com/users/jkmacc-LANL/following{/other_user}","gists_url":"https://api.github.com/users/jkmacc-LANL/gists{/gist_id}","starred_url":"https://api.github.com/users/jkmacc-LANL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkmacc-LANL/subscriptions","organizations_url":"https://api.github.com/users/jkmacc-LANL/orgs","repos_url":"https://api.github.com/users/jkmacc-LANL/repos","events_url":"https://api.github.com/users/jkmacc-LANL/events{/privacy}","received_events_url":"https://api.github.com/users/jkmacc-LANL/received_events","type":"User","site_admin":false},"body":"## Why a re-write?\r\nThe `sacio` module underlying ObsPy's SAC handling was a bit hard to follow, as it has a long inheritance, which made it hard to track down issues or make fixes.  This re-write attempts to make the SAC plugin easier to understand and maintain, as well as offer some potential improvements.\r\n\r\n### Improve maintainability.\r\nI've split out the header specification (`header.py`), the low-level array-based SAC file I/O (`arrayio.py`), and the object-oriented interface (`sactrace.py`), whereas it was previously all within one `sacio.py` module.  I hope that the flow of how each plugs into the other is clear, so that bug tracking is straight-forward, and that hacking on one aspect of SAC handling is not cluttered/distracted by another.\r\n\r\n### Expand support for round-trip SAC file processing\r\nThis PR attempts to improve support for a common work flow: read one or more SAC files into ObsPy, do some processing, then (over)write them back as SAC files that look mostly like the originals.  Previously, ObsPy Traces written to SAC files wrote only files based on the first sample time (iztype 9/'ib').  In [`util.py:obspy_to_sac_header`](https://github.com/jkmacc-LANL/obspy/blob/sac-rewrite/obspy/io/sac/util.py#L237)  of this PR, if an old `tr.stats.sac` SAC header is found, the *iztype and reference \"nz\" times are used and kept*, and the \"b\" and \"e\" times of the Trace being written are adjusted according to this reference time.  This preserves the absolute reference of any relative time headers, like t0-t9, carried from the old SAC header into the new file.  This can only be done if SAC to Trace conversion preserves these \"nz\" time headers, which is possible with the current `debug_headers=True` flag.\r\n\r\n## To Do:\r\n1. Testing integration.\r\n2. setup.py integration.\r\n3. Docs.\r\n\r\n## Feedback\r\nComments and suggestions about the following would be greatly appreciated:\r\n\r\n1. The design decisions and round-trip processing support mentioned above\r\n2. License language and attribution  \r\n    As much of the hard work of basic I/O came from the old `sacio`, I only wish to tack my name onto the author list for this module.  Please offer any suggestions to make that clear.\r\n3. My git-fu.  \r\n    This is the first time I've done anything that might be merged into a larger project, so any comments or suggestions on how to improving my use of git would be welcomed.\r\n\r\nEDIT: shoutouts\r\n@yannikbehr , @mbyt , @cja12, @claudiodsf \r\n    ","created_at":"2015-07-09T16:42:48Z","updated_at":"2015-07-10T23:06:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79119fd42a5b582337d582d9108af9129806fbaa","assignee":null,"milestone":{"url":"https://api.github.com/repos/obspy/obspy/milestones/8","html_url":"https://github.com/obspy/obspy/milestones/0.11.0","labels_url":"https://api.github.com/repos/obspy/obspy/milestones/8/labels","id":725009,"number":8,"title":"0.11.0","description":"","creator":{"login":"barsch","id":602450,"avatar_url":"https://avatars.githubusercontent.com/u/602450?v=3","gravatar_id":"","url":"https://api.github.com/users/barsch","html_url":"https://github.com/barsch","followers_url":"https://api.github.com/users/barsch/followers","following_url":"https://api.github.com/users/barsch/following{/other_user}","gists_url":"https://api.github.com/users/barsch/gists{/gist_id}","starred_url":"https://api.github.com/users/barsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barsch/subscriptions","organizations_url":"https://api.github.com/users/barsch/orgs","repos_url":"https://api.github.com/users/barsch/repos","events_url":"https://api.github.com/users/barsch/events{/privacy}","received_events_url":"https://api.github.com/users/barsch/received_events","type":"User","site_admin":false},"open_issues":44,"closed_issues":19,"state":"open","created_at":"2014-07-18T08:42:03Z","updated_at":"2015-07-10T09:00:54Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/obspy/obspy/pulls/1092/commits","review_comments_url":"https://api.github.com/repos/obspy/obspy/pulls/1092/comments","review_comment_url":"https://api.github.com/repos/obspy/obspy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/obspy/obspy/issues/1092/comments","statuses_url":"https://api.github.com/repos/obspy/obspy/statuses/3943b96a2d729cc8cfc41bbd1ad28125b3b7c1f8","head":{"label":"jkmacc-LANL:sac-rewrite","ref":"sac-rewrite","sha":"3943b96a2d729cc8cfc41bbd1ad28125b3b7c1f8","user":{"login":"jkmacc-LANL","id":6475152,"avatar_url":"https://avatars.githubusercontent.com/u/6475152?v=3","gravatar_id":"","url":"https://api.github.com/users/jkmacc-LANL","html_url":"https://github.com/jkmacc-LANL","followers_url":"https://api.github.com/users/jkmacc-LANL/followers","following_url":"https://api.github.com/users/jkmacc-LANL/following{/other_user}","gists_url":"https://api.github.com/users/jkmacc-LANL/gists{/gist_id}","starred_url":"https://api.github.com/users/jkmacc-LANL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkmacc-LANL/subscriptions","organizations_url":"https://api.github.com/users/jkmacc-LANL/orgs","repos_url":"https://api.github.com/users/jkmacc-LANL/repos","events_url":"https://api.github.com/users/jkmacc-LANL/events{/privacy}","received_events_url":"https://api.github.com/users/jkmacc-LANL/received_events","type":"User","site_admin":false},"repo":{"id":38391209,"name":"obspy","full_name":"jkmacc-LANL/obspy","owner":{"login":"jkmacc-LANL","id":6475152,"avatar_url":"https://avatars.githubusercontent.com/u/6475152?v=3","gravatar_id":"","url":"https://api.github.com/users/jkmacc-LANL","html_url":"https://github.com/jkmacc-LANL","followers_url":"https://api.github.com/users/jkmacc-LANL/followers","following_url":"https://api.github.com/users/jkmacc-LANL/following{/other_user}","gists_url":"https://api.github.com/users/jkmacc-LANL/gists{/gist_id}","starred_url":"https://api.github.com/users/jkmacc-LANL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkmacc-LANL/subscriptions","organizations_url":"https://api.github.com/users/jkmacc-LANL/orgs","repos_url":"https://api.github.com/users/jkmacc-LANL/repos","events_url":"https://api.github.com/users/jkmacc-LANL/events{/privacy}","received_events_url":"https://api.github.com/users/jkmacc-LANL/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jkmacc-LANL/obspy","description":"ObsPy: A Python Toolbox for seismology/seismological observatories.","fork":true,"url":"https://api.github.com/repos/jkmacc-LANL/obspy","forks_url":"https://api.github.com/repos/jkmacc-LANL/obspy/forks","keys_url":"https://api.github.com/repos/jkmacc-LANL/obspy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jkmacc-LANL/obspy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jkmacc-LANL/obspy/teams","hooks_url":"https://api.github.com/repos/jkmacc-LANL/obspy/hooks","issue_events_url":"https://api.github.com/repos/jkmacc-LANL/obspy/issues/events{/number}","events_url":"https://api.github.com/repos/jkmacc-LANL/obspy/events","assignees_url":"https://api.github.com/repos/jkmacc-LANL/obspy/assignees{/user}","branches_url":"https://api.github.com/repos/jkmacc-LANL/obspy/branches{/branch}","tags_url":"https://api.github.com/repos/jkmacc-LANL/obspy/tags","blobs_url":"https://api.github.com/repos/jkmacc-LANL/obspy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jkmacc-LANL/obspy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jkmacc-LANL/obspy/git/refs{/sha}","trees_url":"https://api.github.com/repos/jkmacc-LANL/obspy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jkmacc-LANL/obspy/statuses/{sha}","languages_url":"https://api.github.com/repos/jkmacc-LANL/obspy/languages","stargazers_url":"https://api.github.com/repos/jkmacc-LANL/obspy/stargazers","contributors_url":"https://api.github.com/repos/jkmacc-LANL/obspy/contributors","subscribers_url":"https://api.github.com/repos/jkmacc-LANL/obspy/subscribers","subscription_url":"https://api.github.com/repos/jkmacc-LANL/obspy/subscription","commits_url":"https://api.github.com/repos/jkmacc-LANL/obspy/commits{/sha}","git_commits_url":"https://api.github.com/repos/jkmacc-LANL/obspy/git/commits{/sha}","comments_url":"https://api.github.com/repos/jkmacc-LANL/obspy/comments{/number}","issue_comment_url":"https://api.github.com/repos/jkmacc-LANL/obspy/issues/comments{/number}","contents_url":"https://api.github.com/repos/jkmacc-LANL/obspy/contents/{+path}","compare_url":"https://api.github.com/repos/jkmacc-LANL/obspy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jkmacc-LANL/obspy/merges","archive_url":"https://api.github.com/repos/jkmacc-LANL/obspy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jkmacc-LANL/obspy/downloads","issues_url":"https://api.github.com/repos/jkmacc-LANL/obspy/issues{/number}","pulls_url":"https://api.github.com/repos/jkmacc-LANL/obspy/pulls{/number}","milestones_url":"https://api.github.com/repos/jkmacc-LANL/obspy/milestones{/number}","notifications_url":"https://api.github.com/repos/jkmacc-LANL/obspy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jkmacc-LANL/obspy/labels{/name}","releases_url":"https://api.github.com/repos/jkmacc-LANL/obspy/releases{/id}","created_at":"2015-07-01T19:41:24Z","updated_at":"2015-07-01T19:41:30Z","pushed_at":"2015-07-09T14:02:45Z","git_url":"git://github.com/jkmacc-LANL/obspy.git","ssh_url":"git@github.com:jkmacc-LANL/obspy.git","clone_url":"https://github.com/jkmacc-LANL/obspy.git","svn_url":"https://github.com/jkmacc-LANL/obspy","homepage":"http://www.obspy.org","size":64490,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"obspy:master","ref":"master","sha":"1c600fb662aea19b991e2db64a95acb1ee056416","user":{"login":"obspy","id":1701221,"avatar_url":"https://avatars.githubusercontent.com/u/1701221?v=3","gravatar_id":"","url":"https://api.github.com/users/obspy","html_url":"https://github.com/obspy","followers_url":"https://api.github.com/users/obspy/followers","following_url":"https://api.github.com/users/obspy/following{/other_user}","gists_url":"https://api.github.com/users/obspy/gists{/gist_id}","starred_url":"https://api.github.com/users/obspy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obspy/subscriptions","organizations_url":"https://api.github.com/users/obspy/orgs","repos_url":"https://api.github.com/users/obspy/repos","events_url":"https://api.github.com/users/obspy/events{/privacy}","received_events_url":"https://api.github.com/users/obspy/received_events","type":"Organization","site_admin":false},"repo":{"id":5731348,"name":"obspy","full_name":"obspy/obspy","owner":{"login":"obspy","id":1701221,"avatar_url":"https://avatars.githubusercontent.com/u/1701221?v=3","gravatar_id":"","url":"https://api.github.com/users/obspy","html_url":"https://github.com/obspy","followers_url":"https://api.github.com/users/obspy/followers","following_url":"https://api.github.com/users/obspy/following{/other_user}","gists_url":"https://api.github.com/users/obspy/gists{/gist_id}","starred_url":"https://api.github.com/users/obspy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obspy/subscriptions","organizations_url":"https://api.github.com/users/obspy/orgs","repos_url":"https://api.github.com/users/obspy/repos","events_url":"https://api.github.com/users/obspy/events{/privacy}","received_events_url":"https://api.github.com/users/obspy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/obspy/obspy","description":"ObsPy: A Python Toolbox for seismology/seismological observatories.","fork":false,"url":"https://api.github.com/repos/obspy/obspy","forks_url":"https://api.github.com/repos/obspy/obspy/forks","keys_url":"https://api.github.com/repos/obspy/obspy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obspy/obspy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obspy/obspy/teams","hooks_url":"https://api.github.com/repos/obspy/obspy/hooks","issue_events_url":"https://api.github.com/repos/obspy/obspy/issues/events{/number}","events_url":"https://api.github.com/repos/obspy/obspy/events","assignees_url":"https://api.github.com/repos/obspy/obspy/assignees{/user}","branches_url":"https://api.github.com/repos/obspy/obspy/branches{/branch}","tags_url":"https://api.github.com/repos/obspy/obspy/tags","blobs_url":"https://api.github.com/repos/obspy/obspy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obspy/obspy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obspy/obspy/git/refs{/sha}","trees_url":"https://api.github.com/repos/obspy/obspy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obspy/obspy/statuses/{sha}","languages_url":"https://api.github.com/repos/obspy/obspy/languages","stargazers_url":"https://api.github.com/repos/obspy/obspy/stargazers","contributors_url":"https://api.github.com/repos/obspy/obspy/contributors","subscribers_url":"https://api.github.com/repos/obspy/obspy/subscribers","subscription_url":"https://api.github.com/repos/obspy/obspy/subscription","commits_url":"https://api.github.com/repos/obspy/obspy/commits{/sha}","git_commits_url":"https://api.github.com/repos/obspy/obspy/git/commits{/sha}","comments_url":"https://api.github.com/repos/obspy/obspy/comments{/number}","issue_comment_url":"https://api.github.com/repos/obspy/obspy/issues/comments{/number}","contents_url":"https://api.github.com/repos/obspy/obspy/contents/{+path}","compare_url":"https://api.github.com/repos/obspy/obspy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obspy/obspy/merges","archive_url":"https://api.github.com/repos/obspy/obspy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obspy/obspy/downloads","issues_url":"https://api.github.com/repos/obspy/obspy/issues{/number}","pulls_url":"https://api.github.com/repos/obspy/obspy/pulls{/number}","milestones_url":"https://api.github.com/repos/obspy/obspy/milestones{/number}","notifications_url":"https://api.github.com/repos/obspy/obspy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obspy/obspy/labels{/name}","releases_url":"https://api.github.com/repos/obspy/obspy/releases{/id}","created_at":"2012-09-08T19:17:46Z","updated_at":"2015-07-07T22:58:32Z","pushed_at":"2015-07-10T17:35:40Z","git_url":"git://github.com/obspy/obspy.git","ssh_url":"git@github.com:obspy/obspy.git","clone_url":"https://github.com/obspy/obspy.git","svn_url":"https://github.com/obspy/obspy","homepage":"http://www.obspy.org","size":83608,"stargazers_count":143,"watchers_count":143,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":90,"forks":103,"open_issues":90,"watchers":143,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1092"},"html":{"href":"https://github.com/obspy/obspy/pull/1092"},"issue":{"href":"https://api.github.com/repos/obspy/obspy/issues/1092"},"comments":{"href":"https://api.github.com/repos/obspy/obspy/issues/1092/comments"},"review_comments":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1092/comments"},"review_comment":{"href":"https://api.github.com/repos/obspy/obspy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1092/commits"},"statuses":{"href":"https://api.github.com/repos/obspy/obspy/statuses/3943b96a2d729cc8cfc41bbd1ad28125b3b7c1f8"}}}}