Building StationXML using NRl v2

Hello.

Up to now I build station-inventories using PDCC, but as it works not for the NRL v2, I am looking for a alternative to build station-inventories.

I tried to build a stationXML with Obspy using NRL v2, but somehow it does not work well:
I include the NRL v2 responses with
nrl=(NRLv2 file)
I also get the senor and datalogger keys (after changing the filenames “datalogger” and “sensor” to “dataloggers” and “sensors” in the unzipped NRLv2-filestructure)
But when I am trying to build the stationXML I get the following:

/usr/lib64/python3.6/site-packages/obspy/clients/nrl/client.py:224: UserWarning: Failed to recalculate overall sensitivity.
warnings.warn(msg)

also, when I just apply nrl.get_response I got the same result.
Is there any change to build a stationXML with NRL v2 with obspy.

If someone could help me with this problem, this would be really great,

Andrea

I build StationXML from NRLv2 all the time. I think I’d need to see your full code example that fails to say anything here.

Hello Tobias,

here is the code:

import obspy
from obspy.core.inventory import Inventory, Network, Station, Channel, Site
from obspy.clients.nrl import NRL

We’ll first create all the various objects. These strongly follow the

hierarchy of StationXML files.

inv = Inventory(
# We’ll add networks later.
networks=,
# The source should be the id whoever create the file.
source=“ObsPy-Tutorial”)

net = Network(
# This is the network code according to the SEED standard.
code=“LE”,
# A list of stations. We’ll add one later.
stations=,
description=“A test stations.”,
# Start-and end dates are optional.
start_date=obspy.UTCDateTime(1970, 1, 1))

sta = Station(
# This is the station code according to the SEED standard.
code=“XXX”,
latitude=0.0,
longitude=0.0,
elevation=0.0,
creation_date=obspy.UTCDateTime(2025, 1, 1),
site=Site(name=“First station”))

cha = Channel(
# This is the channel code according to the SEED standard.
code=“HHZ”,
# This is the location code according to the SEED standard.
location_code=“”,
# Note that these coordinates can differ from the station coordinates.
latitude=0.0,
longitude=0.0,
elevation=0.0,
depth=205.0,
azimuth=0.0,
dip=-90.0,
sample_rate=100)

By default this accesses the NRL online. Offline copies of the NRL can

also be used instead

nrl = NRL(‘NRL2resp’)
#nrl=NRL()

The contents of the NRL can be explored interactively in a Python prompt,

see API documentation of NRL submodule:

obspy.clients.nrl - Nominal Response Library client for ObsPy — ObsPy 1.4.1 documentation

Here we assume that the end point of data logger and sensor are already

known:

response = nrl.get_response( # doctest: +SKIP
sensor_keys=[‘Nanometrics’, ‘TrilliumSlimPosthole120’, ‘1203’],
datalogger_keys=[‘Nanometrics’, ‘Centaur’, ‘40Vpp’, ‘100 Hz’,‘0.001’,‘Linear’])

Now tie it all together.

cha.response = response
sta.channels.append(cha)
net.stations.append(sta)
inv.networks.append(net)

And finally write it to a StationXML file. We also force a validation against

the StationXML schema to ensure it produces a valid StationXML file.

Note that it is also possible to serialize to any of the other inventory

output formats ObsPy supports.

inv.write(“XX.test.xml”, format=“stationxml”, validate=True)

Please have a look at our “Read this first” pinned post