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

Add warning for metadata truncation when writing to mseed #2972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jawooll
Copy link

@jawooll jawooll commented Jan 27, 2022

What does this PR do?

Changes default behaviour when writing to mseed files to now print a warning if the provided metadata would be truncated during writing.

Why was it initiated? Any relevant Issues?

See issues/questions (fixes #2971, #2588).

PR Checklist

  • Correct base branch selected? master for new features, maintenance_... for bug fixes
  • This PR is not directly related to an existing issue (which has no PR yet).
  • If the PR is making changes to documentation, docs pages can be built automatically.
    Just add the "build_docs" tag to this PR.
  • If all tests including network modules (e.g. clients.fdsn) should be tested for the PR,
    just add the "test_network" tag to this PR.
  • All tests still pass.
  • Any new features or fixed regressions are covered via new tests.
  • Any new or changed features are fully documented.
  • Significant changes have been added to CHANGELOG.txt .
  • First time contributors have added your name to CONTRIBUTORS.txt .
  • If the changes affect any plotting functions you have checked that the plots
    from all the CI builds look correct. Add the "upload_plots" tag so that plotting
    outputs are attached as artifacts.
  • Add the "ready for review" tag when you are ready for the PR to be reviewed.

@yetinam
Copy link
Contributor

yetinam commented Jan 27, 2022

Hey Jack! If I remember correctly, this truncation issue affects a few formats that you listed here seisbench/seisbench#54 . Even though mseed will be the most prominent one, I was wondering whether it would be reasonable to add warnings for all formats in one go.

@jawooll
Copy link
Author

jawooll commented Jan 28, 2022

Hey Jannes, Good point! This requires a more involved PR though. Let's first see if the obspy team are open to the idea of logging such warnings when writing streams, and I could then look into extending this if required.

@d-chambers
Copy link
Member

Let's first see if the obspy team are open to the idea of logging such warnings

Totally open to it, please run with it.

@jawooll
Copy link
Author

jawooll commented Jan 28, 2022

Ok great thanks, I'll extend the PR to log warning on all appropriate formats.

@megies
Copy link
Member

megies commented Mar 9, 2022

This looks pretty good to me, just a few things/thoughts..

  • please add a changelog one-liner
  • please actually test that the appropriate warning is shown, currently it only checks if any warning appears which could be anything (we have a helper context manager making this easy)
  • currently this is in a really low-level spot, which is OK, I guess, but if you plan on extending it to other file formats, I'd just move the check to inside Stream.write(). That is the recommended high-level routine and I'd argue people going the discouraged low-level way are kind of on their own with detail issues like this. Having it in a high level place like that would make it easier to extend for more formats in the future, by just adding to some dictionary storing limitations per format code

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

Successfully merging this pull request may close these issues.

Add warning when writing non-compatible stream metadata to MSEED
4 participants