Getting a response file to use with the CSS3.0 format

Hello dear friends! I started using obspy and I need to receive data from Iris and process it. Processing is performed using the Antelope package in css3.0 format. I receive the data normally and convert it to css3.0 format. But to measure amplitude, I need to have response files in any format that is supported by css3.0.
I receive responses using the inventory class, but I don’t understand how to convert them to the required formats. I didn’t find any documentation or description of the format.
Thanks for any help…

You can use the .write() method of Inventory to output in various file formats, listed in the docs:

https://docs.obspy.org/master/packages/autogen/obspy.core.inventory.inventory.Inventory.write.html#obspy.core.inventory.inventory.Inventory.write

Thank you Megies!
Yes, I have seen this method. Maybe I don’t understand something, but if I use inventory.write(“dbname”, format=“CSS”) then I just get a few files with metadata, but I don’t get the response file I need. This is written in the documentation for obspy.io.css.station._write_css - Any Response objects are not saved.
If I select the SACPZ format, it is not readable by dbpick.
Previously, we received response files from a dataless file (seed format) like this:

Source: Seed file
Instrument: Titan S/N 2492

1 unknown paz unknown
1.0077649893e+18 4.0000000000e-01
6
-9.7700000000e+02 3.2800000000e+02 0.0000000000e+00 0.0000000000e+00
-9.7700000000e+02 -3.2800000000e+02 0.0000000000e+00 0.0000000000e+00
-1.4860000000e+03 2.5120000000e+03 0.0000000000e+00 0.0000000000e+00
-1.4860000000e+03 -2.5120000000e+03 0.0000000000e+00 0.0000000000e+00
-5.7360000000e+03 4.9460000000e+03 0.0000000000e+00 0.0000000000e+00
-5.7360000000e+03 -4.9460000000e+03 0.0000000000e+00 0.0000000000e+00
1
-5.1500000000e+02 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
2 unknown paz unknown
1.0000000000e+00 4.0000000000e-01
0
0
3 unknown paz unknown
1.0000000000e+00 4.0000000000e-01
0
0
4 unknown fir unknown
3.0000000000e+04 1
1
1.0000000000e+00 0.0000000000e+00
0
5 unknown fir unknown
3.0000000000e+04 20
203
-5.1485571485e-10 0.0000000000e+00
-5.5038276418e-10 0.0000000000e+00
-6.4914790131e-10 0.0000000000e+00
-8.8653023091e-10 0.0000000000e+00
-1.3992219428e-09 0.0000000000e+00

In addition, I saw response files in fap (frequency-amplitude-period) format:

displacement frequency for seismic array short-period
vertical channels
Freq(Hz) Amp(norm) Phase(deg) Error(amp) Error(phase)
theoretical 0 complete fap
111
0.10000 0.0062559 -103.97 0.0 0.0
0.20000 0.050193 -109.54 0.0 0.0
0.30000 0.16895 -117.29 0.0 0.0
0.40000 0.39709 -125.91 0.0 0.0
0.50000 0.76195 -135.10 0.0 0.0
0.60000 1.2769 -144.70 0.0 0.0
0.70000 1.9351 -154.47 0.0 0.0
0.80000 2.7092 -164.10 0.0 0.0
0.90000 3.5588 -173.31 0.0 0.0
1.0000 4.4426 178.13 0.0 0.0
1.2000 6.1941 163.43 0.0 0.0
1.4000 7.8394 151.90 0.0 0.0
1.6000 9.3709 142.98 0.0 0.0
1.8000 10.815 136.00 0.0 0.0
2.0000 12.198 130.43 0.0 0.0
2.2000 13.540 125.90 0.0 0.0
2.4000 14.857 122.13 0.0 0.0
2.6000 16.158 118.96 0.0 0.0
2.8000 17.450 116.23 0.0 0.0
3.0000 18.739 113.85 0.0 0.0
3.2000 20.022 111.76 0.0 0.0
3.4000 21.299 109.90 0.0 0.0
3.6000 22.567 108.23 0.0 0.0
3.8000 23.829 106.71 0.0 0.0
4.0000 25.086 105.33 0.0 0.0

Fap tables are obtained from responses in poles and zeros, but I don’t know how to do this.

I don’t know formats used by CSS. The first example seems to be a textual representation of all filter stages, but not sure about the conventions. In principle you could work with the Response objects and write out such information yourself, but that might be quite some work.

Getting a F-A-P list is straight forward. It’s probably not the most ideal approach but it’s easy to do, so maybe you can have a try with that.

e.g.

from obspy import read_inventory
import numpy as np

inv = read_inventory()
response = inv[0][0][0].response
freqs = np.logspace(-3, 3, 100)
resp_cpx = response.get_evalresp_response_for_frequencies(freqs)
resp_amp = np.abs(resp_cpx)
resp_phase = np.angle(resp_cpx)
resp_phase = np.degrees(resp_phase)

These values you could write out to files for all your stations looping over your inventory…

for net in inv:
    for sta in net:
        for cha in sta:
            resp = cha.response
            ...

Again, thank you!
Yes, exactly, my goal is to create a response file for each station and channel, as you wrote. I have already created metadata tables in this way (site/sitechan/instrument/sensor).
I’ll try to do it as you suggested and try to understand the format. Unfortunately there is very little information!
If anyone has experience solving this problem, I would be very glad to communicate!