# Efficient access to Station in Inventory given network code and station code

**URL:** https://discourse.obspy.org/t/efficient-access-to-station-in-inventory-given-network-code-and-station-code/357
**Category:** Users Mailing List Archive
**Tags:** archive
**Created:** [October 10, 2014, 6:40pm UTC](https://discourse.obspy.org/t/efficient-access-to-station-in-inventory-given-network-code-and-station-code/357 "2014-10-10T18:40:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Brad\_Aagaard](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@Brad\_Aagaard](https://discourse.obspy.org/u/Brad_Aagaard)
#### Post date: [October 10, 2014, 6:40pm UTC](https://discourse.obspy.org/t/efficient-access-to-station-in-inventory-given-network-code-and-station-code/357/1 "2014-10-10T18:40:03Z")

</div>

I am trying to use information in the Station objects retrieved via fdsn.get\_stations() (longitude, latitude, azimuth, dip) to add the distance and back azimuth information to a stream and rotate to ENZ components (some components are 123 or 12Z and rotated relative to ENZ).

Given a station's network and station codes from a trace in a Stream object, what is the recommended (efficient) way to access the corresponding station in an Inventory object? Is there an equivalent method/function to Stream.select? For example, is there something equivalent to:

station = inventory.select(network='BK', station='BRIB')  
or  
station = inventory['BK']['BRIB']

Thanks,  
Brad

---

<div class="post-metadata">

### Author: ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)
#### Post date: [October 10, 2014, 7:09pm UTC](https://discourse.obspy.org/t/efficient-access-to-station-in-inventory-given-network-code-and-station-code/357/2 "2014-10-10T19:09:15Z")

</div>

Hi Brad,

your first example

> station = inventory.select(network='BK', station='BRIB’)

is by coincidence exactly what we implemented in the current master 😉 You will either have to update to the latest dev version or wait for the next release. Alternatively you can add it to your code in some fashion as its only a couple of lines.

[https://github.com/obspy/obspy/blob/0e9965dae0b90ff4af2e4347723d066bfc985f08/obspy/station/inventory.py#L282-367](https://github.com/obspy/obspy/blob/0e9965dae0b90ff4af2e4347723d066bfc985f08/obspy/station/inventory.py#L282-367)

Cheers!

Lion

---

<div class="post-metadata">

### Author: ![Brad\_Aagaard](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@Brad\_Aagaard](https://discourse.obspy.org/u/Brad_Aagaard)
#### Post date: [October 10, 2014, 7:34pm UTC](https://discourse.obspy.org/t/efficient-access-to-station-in-inventory-given-network-code-and-station-code/357/3 "2014-10-10T19:34:50Z")

</div>

Thanks for the info. This functionality is very useful, so I'll switch from 0.9.2 to master.

Cheers,  
Brad
