How to modify an Obspy Response object

Hello Obspy users,

I am trying to modify a response object retrieved using obspy NRL client. This is a snippet of code used to retrieve the response:

from obspy.clients.nrl import NRL

nrl = NRL()

response = nrl.get_response(sensor_keys= [‘Nanometrics’, ‘Trillium Compact’, ‘120 s’], datalogger_keys=[‘Earth Data’,‘EDR-210’,‘Low (default)’,‘100’] )

and the retrieved response:

Channel Response

From M/S (Velocity in Meters per Second) to COUNTS (Digital Counts)

Overall Sensitivity: 7.50725e+08 defined at 1.000 Hz

7 stages:

Stage 1: PolesZerosResponseStage from M/S to V, gain: 754.3

Stage 2: ResponseStage from V to V, gain: 2.5

Stage 3: CoefficientsTypeResponseStage from V to COUNTS, gain: 400000

Stage 4: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1

Stage 5: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1

Stage 6: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1

Stage 7: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1

I need to add an additional Stage with gain of 256 (due to 32-bit digitizing rather than 24-bit default in the NRL database). How can I do this?

Thank you.

Silvio De Angelis

School of Environmental Sciences

University of Liverpool

4 Brownlow Street, L69 3GP

Liverpool, UK

Hi Silvio

The returned object of nrl.get_response() has and attribute response_stages which is a list of objects of class obspy.core.inventory.response.ResponseStage, thus simply create such an object and append it to the list, e.g.

from obspy.core.inventory.response import ResponseStage
new_response_stage = ResponseStage(stage_sequence_number, stage_gain, stage_gain_frequency, input_units, output_units)
response.insert(position, new_response_stage)

For some more info on the attributes of the ResponseStage class see


Hi Silvio,

I wrote a small function, based on the obspy docs, that clones an inventory using a user specified network and station name. It’s below.

I had to do this because I found I wasn’t able to change the station or network names of an existing inventory object- necessary in case the RESP file used by read_inventory has a different station name associated with it. I solved the problem by creating a new inventory and then copying the existing response from original inventory to the new one.

Maybe this would be useful to you in case you have trouble modifying the response itself.

I hope you’re doing well.
Tim Bartholomaus

I think you'll have to also recalculate the overall sensitivty, see