How to get a inventory file for the raw data (mseed format)?

I am trying to deconvelve the raw data from the geophone (Datalogger = Datacube3, sample rate=200hz, gain=16; Sensors = sensor_SensorNederland PE-6B) by using the Obspy package.

i download the station XML file from NRL website, i found that i can download two file, one is from the sensor, another is from the datacube. However, both of which give me the same error in pycharm: ValueError:No matching response information found.

Is there any suggestions for the “how to download the suitable XML file”?

Here is my code

import numpy as np
import matplotlib.pyplot as plt
import obspy
from obspy.core import UTCDateTime
from obspy import read, read_inventory

st = read(‘/Users/lu/LU_User/PythonProjects/gipptools-2022.171/bin/mseed-out/c0bln210620085250.pri2’)
tr = st[0]
t = np.arange(0, tr.stats.npts / tr.stats.sampling_rate, tr.stats.delta)

inv = read_inventory(‘/Users/lu/LU_User/PythonProjects/gipptools-2022.171/bin/datacube.xml’)
print(inv)
st.attach_response(inv)
tr = st[0]
print(tr.stats.response)

tr_filt_deconvelve = tr.remove_response(inventory=inv, output=‘VEL’, plot=True)

Let us know if it’s still not clear after looking at the respective parts of the docs:

https://docs.obspy.org/master/packages/obspy.clients.nrl.html

https://docs.obspy.org/master/tutorial/code_snippets/stationxml_file_from_scratch.html

This is assuming you performed the experiment yourself and therefore have to build the metadata from scratch. If it is somebody else’s data, you’d want to ask them to give you the metadata as well.

Hi, megies

Thanks for your attention again. I performed the experiments by myself, the only thing i know is the name of sensor and data logger. Thus, i tried to build the metadata station xml file from the scratch by using the code below:

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

inv = Inventory(
networks=[],
source=“ObsPy-Tutorial_LU”)

net = Network(
code=“XX”,
stations=[],
description=“DDFORS”,
start_date=obspy.UTCDateTime(2018, 1, 1))

sta = Station(
code=“YY”,
latitude=1.0,
longitude=2.0,
elevation=345.0,
creation_date=obspy.UTCDateTime(2016, 1, 2),
site=Site(name=“DDFORS”))

cha = Channel(
code=“ZZZ”,
location_code=“00”,
latitude=1.0,
longitude=2.0,
elevation=345.0,
depth=10.0,
azimuth=0.0,
dip=-90.0,
sample_rate=200)

nrl = NRL()
response = nrl.get_response(
sensor_keys=[‘SensorNederland’, ‘PE-6’, ‘375’, ‘None’],
datalogger_keys=[‘DiGOS/Omnirecs’, ‘DATACUBE’, ‘16’, ‘200’])

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

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

from which i can got the station xml file and i use the following code to deconvolve the raw data, however, i got the “ValueError: No response information found. Use inventory parameter to specify an inventory with response information.” I dont know why there is no response information found because I can print the response correctly by using the “nrl.get_response” code above.

import numpy as np
import matplotlib.pyplot as plt
import obspy
from obspy.core import UTCDateTime
from obspy import read, read_inventory
from obspy.clients.nrl import NRL

st = read()
inv = read_inventory(‘/Users/station.xml’)
t = np.arange(0, tr.stats.npts / tr.stats.sampling_rate, tr.stats.delta)
tr = st[0]
tr_deconvelve = tr.remove_response(inventor=inv, output=‘VEL’)
tr_deconvelve.plot()

here is the output of my trace, should i keep the inventory network/station/channel same with this? why do my sensor and data logger has network/station/channel = XX / YY/ ZZZ?

network:
station: c0BLN
location:
channel: p2
starttime: 2021-06-20T08:52:50.600000Z
endtime: 2021-06-20T09:00:10.595000Z
sampling_rate: 200.0
delta: 0.005
npts: 88000
calib: 1.0
_format: MSEED
mseed: AttribDict({‘dataquality’: ‘D’, ‘number_of_records’: 65, ‘encoding’: ‘STEIM1’, ‘byteorder’: ‘<’, ‘record_length’: 4096, ‘filesize’: 266240})

network, station, location, channel code that you put in your metadata has to match what your actual data has. You have to set up metadata for each individual channel. Also, please take the time to format your postings properly. :wink:

Thanks a lot in my heart. It works now.

Hi,
There is another small problem coming. i cant print the inventory information when my name of network is empty. i got the error “IndexError: list index out of range”. How can i deal with this if i need to print(inv)?

Impossible to tell what that problem is without more info. I recommend debugging to find out what is causing the execption, see e.g.