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

seedlink client: add option to fetch available stations #2405

Merged
merged 11 commits into from Oct 9, 2019

Conversation

megies
Copy link
Member

@megies megies commented May 24, 2019

What does this PR do?

Adds a method to seedlink client to be able to fetch a list of network/stations for which waveform streams are provided.

Why was it initiated? Any relevant Issues?

This can help in applications to resolve wildcards in stations/networks, e.g. when using seedlink-plotter with "GR_*:HHZ" as seedlink string because the realtime version of the seedlink client can not handle wildcards in network/station.

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 remove the space in the following string after the + sign: "+ DOCS"
  • If any network modules should be tested for the PR, add them as a comma separated list
    (e.g. clients.fdsn,clients.arclink) after the colon in the following magic string: "+TESTS:clients.seedlink"
    (you can also add "ALL" to just simply run all tests across all modules)
  • 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 .

@megies megies added this to the 1.2.0 milestone May 24, 2019
@megies megies self-assigned this May 24, 2019
@megies megies force-pushed the seedlink_get_stations branch 2 times, most recently from 7ec4328 to 8cd49e6 Compare May 24, 2019 14:28
@megies
Copy link
Member Author

megies commented May 24, 2019

Maybe should rename the method, because other get_stations() methods usually return Inventory objects..

@d-chambers
Copy link
Member

Maybe should rename the method, because other get_stations() methods usually return Inventory objects

Yes, I think this is important for maintaining a consistent API.

I am not very familiar with the seedlink client but would it make sense to also return channel level info? or maybe have a level keyword argument?

Also, is the cache really merited? I don't imagine users calling this method more than a small number of times (probably once) in the same python process, but maybe there is a use case I am overlooking.

@megies
Copy link
Member Author

megies commented May 28, 2019

Yes, I think this is important for maintaining a consistent API.

Yeah, I totally agree and I only thought about it when I was sending the PR. How about renaming it to get_contents() or get_station_information?

But actually, I checked again and we can also query down to full SEED ID level, so maybe I change it to return an Inventory object and have the level keyword.

Also, is the cache really merited? I don't imagine users calling this method more than a small number of times (probably once) in the same python process, but maybe there is a use case I am overlooking.

I agree that most use cases will only do a single or some few request and that users could do the same caching easily in their programs. But it's a low hanging fruit, not very complex implementation, users tend to be lazy and just call the method again and the station request actually takes pretty long (several seconds), so I think it should stay in for use cases we might not have on the radar.

@Jollyfant
Copy link
Contributor

How does this work? Does it use the CAT command on seedlink?

@megies
Copy link
Member Author

megies commented May 28, 2019

@megies
Copy link
Member Author

megies commented May 28, 2019

INFO level
    requests an INFO packet containing XML data embedded in a Mini-SEED log record. level should be one of the following: ID, CAPABILITIES, STATIONS, STREAMS, GAPS, CONNECTIONS, ALL. The XML document conforms to the Document Type Definition (DTD) shown in section ???. The amount of info available depends on the configuration of the SeedLink server. 

https://www.seiscomp3.org/doc/applications/seedlink.html

@megies
Copy link
Member Author

megies commented Oct 9, 2019

Tests passing should be good to go.

@megies megies merged commit b8f77ce into master Oct 9, 2019
@megies megies deleted the seedlink_get_stations branch October 9, 2019 15:45
@megies megies moved this from In Progress to Done in Release 1.2.0 Oct 9, 2019
megies added a commit that referenced this pull request Feb 14, 2020
lxml won't parse xml from a unicode string if it includes a textual
declaration of the xml encoding. seems an easy solution is to encode to
bytes, utf-8 should work for all normal cases

see #2405

https://stackoverflow.com/a/38244227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants