Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for response function #1829

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

s-schneider
Copy link
Member

@s-schneider s-schneider commented Jun 28, 2017

What does this PR do?

Adds write support for AH (Ad Hoc) format to stream.write(), It is an addition to PR #1757

Why was it initiated? Any relevant Issues?

related to issue #1754

PR Checklist

  • This PR is not directly related to an existing issue (which has no PR yet).
  • All tests still pass.
  • Any new features or fixed regressions are be covered via new tests.
  • Any new or changed features have are fully documented.
  • Significant changes have been added to CHANGELOG.txt .
  • First time contributors have added your name to CONTRIBUTORS.txt .

packer.pack_float(0)
packer.pack_float(0)
if hasattr(tr.stats, 'response'):
poles, zeros = tr.stats.response.get_paz()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we nowadays don't encourage "magic uses" of additional items in Trace.stats anymore.. but if it's important for you we might still accept this change I guess..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be a better way to check if there is a response attached?

@krischer
Copy link
Member

I'd personally either like to see this as tr.stats.ah.response or Stream.write(..., format="AH", response=response). Adding important things to tr.stats is a hack in any case and we should not keep doing this - there are already enough places in our code base that do that.

@s-schneider
Copy link
Member Author

s-schneider commented Jun 28, 2017

I use the information provided for instance by the get_waveforms(attach_response=True) of obspy.clients.fdsn. I didn't add that information manually.

@krischer
Copy link
Member

Yea- this is one of the instances in our code base where it does already happen. I'd be fine with a construct like this which offers a cleaner interface but also falls back to using the existing tr.stats.response:

def _write_ah(..., response=None, ...):
    ...
    # First use passed response, otherwise look in trace.stats.
    if response is None and "response" in tr.stats:
        response = tr.stats.response

    if response:
        ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants