colab logo

In this article we simulate ground motion (displacement, velocity and acceleration) using the functions and the Inventory object in obspy.

1 Reading seismic data¶

obspy can read many data and metadata formats. To read data, we use the read function:

In [ ]:
from obspy import read

st=read('/content/drive/MyDrive/BMKG_Akselerometer/event-sundastrait-20210321/ASJR_Z.mseed')
st+=read('/content/drive/MyDrive/BMKG_Akselerometer/event-sundastrait-20210321/ASJR_N.mseed')
st+=read('/content/drive/MyDrive/BMKG_Akselerometer/event-sundastrait-20210321/ASJR_E.mseed')
print(st)
3 Trace(s) in Stream:
IA.ASJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples

2 Managing station metadata¶

Besides reading seismic data in many formats, obspy can also read and manage station metadata in many formats. Here we read a StationXML file with the instrument and station metadata and use obspy to explore it. The structure of the Inventory object in obspy: inventory obspy

2.1 Reading StationXML¶

StationXML is read with the read_inventory function, because obspy represents station metadata as an Inventory object. The function reads several formats (CSS, KML, SACPZ, SHAPEFILE, STATIONTXT, STATIONXML):

In [ ]:
from obspy import read_inventory
meta = read_inventory("/content/drive/MyDrive/BMKG_Akselerometer/event-sundastrait-20210321/Dataless/ASJR_manopduatiga_PGN_Seismotek_Inventory_IA.xml")
print(meta)
Inventory created at 2023-07-31T02:07:22.664029Z
	Sending institution: scxml import (ObsPy Inventory)
	Contains:
		Networks (1):
			IA
		Stations (1):
			IA.ASJR (REIS Anyer)
		Channels (3):
			IA.ASJR.00.HNZ, IA.ASJR.00.HNN, IA.ASJR.00.HNE
/usr/local/lib/python3.10/dist-packages/obspy/io/seiscomp/inventory.py:427: UserWarning: Sensor is missing elevation information, using 0.0
  warnings.warn(msg)

Because this StationXML file describes only one station, Stations lists just one: REIS Anyer (ASJR). The output also shows other information, such as the creation time, the network and the channels.

2.2 Accessing information in the Inventory¶

Information in the Inventory (metadata) is accessed by index, just like the data in a Stream. For example, the first network has index 0:

In [ ]:
meta[0]
Out[ ]:
Network IA (BMG-Net, Indonesia (IA-Net))
	Station Count: None/None (Selected/Total)
	1980-01-01T00:00:00.000000Z - --
	Access: open
	Contains:
		Stations (1):
			IA.ASJR (REIS Anyer)
		Channels (3):
			IA.ASJR.00.HNZ, IA.ASJR.00.HNN, IA.ASJR.00.HNE

Likewise, to access the first station of the first network, the indices are nested:

In [ ]:
meta[0][0]
Out[ ]:
Station ASJR (REIS Anyer)
	Station Code: ASJR
	Channel Count: None/None (Selected/Total)
	2018-01-02T00:00:00.000000Z - 
	Access: closed 
	Latitude: -6.06, Longitude: 105.92, Elevation: 0.0 m
	Available Channels:
		ASJR.00.HNZ, ASJR.00.HNN, ASJR.00.HNE

This works down to the channel level; here we take the information of the second channel:

In [ ]:
meta[0][0][1]
Out[ ]:
Channel 'HNN', Location '00' 
	Time range: 2018-01-02T00:00:00.000000Z - --
	Latitude: -6.06, Longitude: 105.92, Elevation: 0.0 m, Local Depth: 0.0 m
	Azimuth: 0.00 degrees from north, clockwise
	Dip: 0.00 degrees down from horizontal
	Sampling Rate: 100.00 Hz
	Sensor (Description): SM (GFZ:IA1980:G210S/g=0)
	Response information available

From here we can go into more detail, for example the sensor name:

In [ ]:
meta[0][0][1].sensor
Out[ ]:
Equipment:
	Type: SM
	Description: GFZ:IA1980:G210S/g=0
	Manufacturer: Meisei
	Vendor: None
	Model: G210S
	Serial number: None
	Installation date: None
	Removal date: None
	Resource id: Sensor/20181102134034.587314.41
	Calibration Dates:

2.3 Accessing the instrument response¶

As in 2.2, we get the instrument response with the response key, as in the example below:

In [ ]:
response=meta[0][0][1].response

We can also plot the instrument response:

In [ ]:
response.plot(min_freq=1, output="ACC")
No handles with labels found to put in legend.
No description has been provided for this image
Out[ ]:
No description has been provided for this image

2.4 Saving metadata to a file¶

Besides reading metadata, obspy can also write it to a file with Inventory.write in several formats (CSS, KML, SACPZ, SHAPEFILE, STATIONTXT, STATIONXML). For example, in SAC Pole and Zero format:

In [ ]:
meta.write('/content/drive/MyDrive/BMKG_Akselerometer/metadata_baru.pz', format='SACPZ')

A file named metadata_baru.pz appears in the file explorer and can be opened.

3 Instrument correction¶

With the station metadata we can apply an instrument correction (deconvolution of the instrument response) to the seismic data to obtain the true ground motion. The correction is done with remove_response on the Stream.

3.1 Ground acceleration¶

Acceleration is selected with ACC in the output option:

In [ ]:
st_acc = st.copy()
st_acc.remove_response(inventory=meta, output='ACC', plot=True)
Out[ ]:
3 Trace(s) in Stream:
IA.ASJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

The result has six plots: three in the frequency domain and, in the next column, three in the time domain. They show the raw data, the pre-processed data (none in this case, None) and the corrected data (response removed). The spectrum (blue) changes slightly in amplitude and shape, for example at low frequencies. The waveform shape hardly changes, but the amplitudes are very different.

3.2 Ground velocity¶

As for acceleration, we only change the output parameter to VEL:

In [ ]:
st_vel = st.copy()
st_vel.remove_response(inventory=meta, output='VEL', plot=True)
Out[ ]:
3 Trace(s) in Stream:
IA.ASJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

3.3 Ground displacement¶

In [ ]:
st_disp = st.copy()
st_disp.remove_response(inventory=meta, output='DISP', plot=True)
Out[ ]:
3 Trace(s) in Stream:
IA.ASJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.ASJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

3.4 Further instrument correction¶

The three corrections above use the default parameters. We can see which parameters the instrument correction accepts with:

In [ ]:
help(st[0].remove_response)
Help on method remove_response in module obspy.core.trace:

remove_response(inventory=None, output='VEL', water_level=60, pre_filt=None, zero_mean=True, taper=True, taper_fraction=0.05, plot=False, fig=None, **kwargs) method of obspy.core.trace.Trace instance
    Deconvolve instrument response.
    
    Uses the adequate :class:`obspy.core.inventory.response.Response`
    from the provided
    :class:`obspy.core.inventory.inventory.Inventory` data. Raises an
    exception if the response is not present.
    
    Note that there are two ways to prevent overamplification
    while convolving the inverted instrument spectrum: One possibility is
    to specify a water level which represents a clipping of the inverse
    spectrum and limits amplification to a certain maximum cut-off value
    (`water_level` in dB). The other possibility is to taper the waveform
    data in the frequency domain prior to multiplying with the inverse
    spectrum, i.e. perform a pre-filtering in the frequency domain
    (specifying the four corner frequencies of the frequency taper as a
    tuple in `pre_filt`).
    
    .. note::
    
        Any additional kwargs will be passed on to
        :meth:`obspy.core.inventory.response.Response.get_evalresp_response`,
        see documentation of that method for further customization (e.g.
        start/stop stage and hiding overall sensitivity mismatch warning).
    
    .. note::
    
        Using :meth:`~obspy.core.trace.Trace.remove_response` is equivalent
        to using
        :meth:`~obspy.core.trace.Trace.simulate` with the identical
        response provided as
        a (dataless) SEED or RESP file and when using the same
        `water_level` and `pre_filt` (and options `sacsim=True` and
        `pitsasim=False` which influence very minor details in detrending
        and tapering).
    
    .. rubric:: Example
    
    >>> from obspy import read, read_inventory
    >>> st = read()
    >>> tr = st[0].copy()
    >>> inv = read_inventory()
    >>> tr.remove_response(inventory=inv)  # doctest: +ELLIPSIS
    <...Trace object at 0x...>
    >>> tr.plot()  # doctest: +SKIP
    
    .. plot::
    
        from obspy import read, read_inventory
        st = read()
        tr = st[0]
        inv = read_inventory()
        tr.remove_response(inventory=inv)
        tr.plot()
    
    Using the `plot` option it is possible to visualize the individual
    steps during response removal in the frequency domain to check the
    chosen `pre_filt` and `water_level` options to stabilize the
    deconvolution of the inverted instrument response spectrum:
    
    >>> from obspy import read, read_inventory
    >>> st = read("/path/to/IU_ULN_00_LH1_2015-07-18T02.mseed")
    >>> tr = st[0]
    >>> inv = read_inventory("/path/to/IU_ULN_00_LH1.xml")
    >>> pre_filt = [0.001, 0.005, 45, 50]
    >>> tr.remove_response(inventory=inv, pre_filt=pre_filt, output="DISP",
    ...                    water_level=60, plot=True)  # doctest: +SKIP
    <...Trace object at 0x...>
    
    .. plot::
    
        from obspy import read, read_inventory
        st = read("/path/to/IU_ULN_00_LH1_2015-07-18T02.mseed", "MSEED")
        tr = st[0]
        inv = read_inventory("/path/to/IU_ULN_00_LH1.xml", "STATIONXML")
        pre_filt = [0.001, 0.005, 45, 50]
        output = "DISP"
        tr.remove_response(inventory=inv, pre_filt=pre_filt, output=output,
                           water_level=60, plot=True)
    
    :type inventory: :class:`~obspy.core.inventory.inventory.Inventory`
        or None.
    :param inventory: Station metadata to use in search for adequate
        response. If inventory parameter is not supplied, the response
        has to be attached to the trace with
        :meth:`obspy.core.trace.Trace.attach_response` beforehand.
    :type output: str
    :param output: Output units. One of:
    
        ``"DISP"``
            displacement, output unit is meters
        ``"VEL"``
            velocity, output unit is meters/second
        ``"ACC"``
            acceleration, output unit is meters/second**2
        ``"DEF"``
            default units, the response is calculated in
            output units/input units (last stage/first stage).
            Useful if the units for a particular type of sensor (e.g., a
            pressure sensor) cannot be converted to displacement, velocity
            or acceleration.
    
    :type water_level: float
    :param water_level: Water level for deconvolution.
    :type pre_filt: list or tuple(float, float, float, float)
    :param pre_filt: Apply a bandpass filter in frequency domain to the
        data before deconvolution. The list or tuple defines
        the four corner frequencies `(f1, f2, f3, f4)` of a cosine taper
        which is one between `f2` and `f3` and tapers to zero for
        `f1 < f < f2` and `f3 < f < f4`.
    :type zero_mean: bool
    :param zero_mean: If `True`, the mean of the waveform data is
        subtracted in time domain prior to deconvolution.
    :type taper: bool
    :param taper: If `True`, a cosine taper is applied to the waveform data
        in time domain prior to deconvolution.
    :type taper_fraction: float
    :param taper_fraction: Taper fraction of cosine taper to use.
    :type plot: bool or str
    :param plot: If `True`, brings up a plot that illustrates how the
        data are processed in the frequency domain in three steps. First by
        `pre_filt` frequency domain tapering, then by inverting the
        instrument response spectrum with or without `water_level` and
        finally showing data with inverted instrument response multiplied
        on it in frequency domain. It also shows the comparison of
        raw/corrected data in time domain. If a `str` is provided then the
        plot is saved to file (filename must have a valid image suffix
        recognizable by matplotlib e.g. '.png').

The help text lists the available parameters and their default values: output='VEL', water_level=60, pre_filt=None, zero_mean=True, taper=True, taper_fraction=0.05.

4 Ground-motion simulation¶

The instrument correction in (3) deconvolves the instrument response from the recording to obtain the true ground motion. A simulation does the opposite: it convolves the ground motion with a given instrument. This shows what the recording would look like on a different instrument. In the example below we reverse the instrument correction and simulate the ground motion as recorded by a Guralp CMG-6T broadband sensor (1 s–100 Hz, 2000 V/m/s) with a DM-24 Mk3 Fixed Gain datalogger (gain 1, 1000 sps, tap id 1, 1000 500 250 125 25 and 5 Hz).

4.1 Running the simulation¶

We reverse the earlier instrument correction: the acceleration data st_acc are simulated as if recorded at station ASJR, back into counts. First we convert the instrument response from a Response object into the PAZ object that the simulate function expects. There seems to be no automatic function for this yet, so we do it semi-manually:

In [ ]:
respon_stasiun_ASJR = meta[0][0][0].response.get_paz().__dict__
respon_stasiun_ASJR
Out[ ]:
{'_normalization_frequency': 1.0,
 '_poles': [(-914.825+0j),
  (-6904.65+0j),
  (-3900.17+0j),
  (-67481.5+0j),
  (-7098.57+0j),
  (-98870.4+0j),
  (-3770.74+0j)],
 '_pz_transfer_function_type': 'LAPLACE (RADIANS/SECOND)',
 '_zeros': [(-628.319+0j), (-12566.4+0j), (-62831.9+0j)],
 'decimation_correction': None,
 'decimation_delay': None,
 'decimation_factor': None,
 'decimation_input_sample_rate': None,
 'decimation_offset': None,
 'description': None,
 'input_units': 'M/S**2',
 'input_units_description': None,
 'name': 'GFZ:IA1980:G210S/g=0',
 'normalization_factor': 8868340000000000.0,
 'output_units': 'V',
 'output_units_description': None,
 'resource_id': None,
 'resource_id2': 'ResponsePAZ/20181102134034.587367.42',
 'stage_gain': 0.193877551,
 'stage_gain_frequency': 1.0,
 'stage_sequence_number': 1}

The simulation needs poles, zeros, gain (A0 normalisation factor) and sensitivity (overall), so we adjust them:

In [ ]:
respon_stasiun_ASJR_formatted = dict()
respon_stasiun_ASJR_formatted['poles'] = respon_stasiun_ASJR['_poles']
respon_stasiun_ASJR_formatted['zeros'] = respon_stasiun_ASJR['_zeros']
respon_stasiun_ASJR_formatted['gain'] = respon_stasiun_ASJR['normalization_factor']
respon_stasiun_ASJR_formatted['sensitivity'] = meta[0][0][0].response.instrument_sensitivity.value #overall sensitivity

respon_stasiun_ASJR_formatted
Out[ ]:
{'gain': 8868340000000000.0,
 'poles': [(-914.825+0j),
  (-6904.65+0j),
  (-3900.17+0j),
  (-67481.5+0j),
  (-7098.57+0j),
  (-98870.4+0j),
  (-3770.74+0j)],
 'sensitivity': 279620.2663,
 'zeros': [(-628.319+0j), (-12566.4+0j), (-62831.9+0j)]}

Then we simulate st_acc:

In [ ]:
st_acc_ASJR = st_acc.copy()
st_acc_ASJR.simulate(paz_simulate=respon_stasiun_ASJR_formatted)
st_acc_ASJR.plot()
No description has been provided for this image
Out[ ]:
No description has been provided for this image

We can then compare it with the original data in counts (st), plotted with matplotlib:

In [ ]:
import matplotlib.pyplot as plt

fig=plt.figure(figsize=(10,6))

ax=fig.add_subplot(2,1,1)
ax.plot(st_acc_ASJR[0].times(), st_acc_ASJR[0].data, color="blue", alpha=1, linewidth=.5, label="Hasil simulasi")

ax2=fig.add_subplot(2,1,2)
ax2.plot(st[0].times(), st[0].data, color="green", alpha=1, linewidth=1, label="Rekaman asli")

ax.set_ylabel("Count")
ax2.set_ylabel("Count")
ax2.set_xlabel("Waktu [s]")

fig.legend(loc='upper center')
Out[ ]:
<matplotlib.legend.Legend at 0x7f35746ca090>
No description has been provided for this image

Combined into one plot and zoomed in on 1020–1040 s, for example:

In [ ]:
fig=plt.figure(figsize=(10,3))

ax=fig.add_subplot(1,1,1)
ax.plot(st_acc_ASJR[0].times(), st_acc_ASJR[0].data, color="green", alpha=1, linewidth=1, label="Hasil simulasi")
ax.plot(st[0].times(), st[0].data, color="red", alpha=1, linewidth=1, label="Rekaman asli", linestyle="--")

ax.set_ylabel("Count")
ax.set_xlabel("Waktu [s]")
ax.set_xlim(1020,1040)
ax.set_ylim(-200,200)

ax.legend()
Out[ ]:
<matplotlib.legend.Legend at 0x7f357220fb90>
No description has been provided for this image

In more detail:

In [ ]:
fig=plt.figure(figsize=(10,3))

ax=fig.add_subplot(1,1,1)
ax.plot(st_acc_ASJR[0].times(), st_acc_ASJR[0].data, color="green", alpha=1, linewidth=2, label="Hasil simulasi")
ax.plot(st[0].times(), st[0].data, color="red", alpha=1, linewidth=2, label="Rekaman asli", linestyle="--")

ax.set_ylabel("Count")
ax.set_xlabel("Waktu [s]")
ax.set_xlim(1026,1028)
ax.set_ylim(-200,200)

ax.legend()
Out[ ]:
<matplotlib.legend.Legend at 0x7f3571f88590>
No description has been provided for this image

4.2 Getting an instrument response from the IRIS Nominal Response Library with obspy¶

To simulate other instruments, obspy can fetch a given instrument response from the IRIS NRL:

In [ ]:
from obspy.clients.nrl import NRL
nrl = NRL()
nrl
<ipython-input-3-a98dceb481d9>:2: ObsPyDeprecationWarning: 
        DEPRECATED

        Direct access to online NRL is deprecated as it will stop working when
        the original NRLv1 gets taken offline (Spring 2023), please consider
        working locally with a downloaded full copy of the old NRLv1 or new
        NRLv2 following instructions on the
        `NRL landing page <https://ds.iris.edu/ds/nrl/>`_.
        
  nrl = NRL()
Out[ ]:
NRL library at https://ds.iris.edu/NRL
  Sensors: 42 manufacturers
    'ASIR', 'CEA-DASE', 'CME (now R-Sensors)', 'Chaparral Physics',
    'DTCC (manuafacturers of SmartSolo)', 'EQMet', 'Eentec', 'GEObit'
    'GEOsig', 'GaiaCode', 'Gem', 'Generic', 'Geo Space/OYO',
    'Geodevice', 'Geotech', 'Guralp', 'HGS Products', 'High Tech',
    'Hyperion', 'IESE', 'Johnson Infrasound', 'Kinemetrics', 'LaHusen'
    'Lennartz', 'Lunitek', 'Magseis Fairfield', 'Metrozet',
    'Nanometrics', 'R-Sensors (previously listed as CME', 'REF TEK',
    'RTClark', 'SARA', 'Seismo Wave', 'SensorNederland',
    'Sercel/Mark Products', 'Silicon Audio', 'SolGeo',
    'Sprengnether (now Eentec)', 'Streckeisen', 'Sunfull', 'TDG',
    'iTem'
  Dataloggers: 30 manufacturers
    'Agecodagis', 'CNSN', 'DAQ Systems (NetDAS)',
    'DTCC (manufacturers of SmartSolo', 'DiGOS/Omnirecs', 'EQMet',
    'Earth Data', 'Eentec', 'GEObit', 'Gem', 'Generic', 'GeoSIG',
    'Geodevice', 'Geotech', 'Guralp', 'Kinemetrics', 'Lunitek',
    'Magseis Fairfield', 'Nanometrics', 'Quanterra', 'R-Sensors',
    'REF TEK', 'SARA', 'STANEO', 'Seismic Source',
    'SeismologyResearchCentre', 'Sercel', 'SolGeo', 'TDG',
    'WorldSensing'

For a Guralp sensor:

In [ ]:
nrl.sensors['Guralp']
Out[ ]:
Select the Guralp sensor model (14 items):
  'CMG-1T', 'CMG-3ESP', 'CMG-3ESPC', 'CMG-3T', 'CMG-3T/5T Hybrid',
  'CMG-3TB (borehole)', 'CMG-3v', 'CMG-40T', 'CMG-5', 'CMG-5TC',
  'CMG-6T', 'CMG-6TF', 'CMG-EDU-T', 'Fortis'

The CMG-6T series:

In [ ]:
nrl.sensors['Guralp']['CMG-6T']
Out[ ]:
Select the natural period (or passband) for this sensor (7 items):
  '10s - 100Hz', '1s - 100Hz', '2s - 100Hz', '30s - 100Hz',
  '40s - 100Hz', '5s - 100Hz', '60s - 100Hz'

For example 1 s–100 Hz:

In [ ]:
nrl.sensors['Guralp']['CMG-6T']['1s - 100Hz']['2000']
Out[ ]:
('CMG-6T, 1s-100Hz, 2000 V/m/s',
 'https://ds.iris.edu/NRL/sensors/guralp/RESP.XX.NS070..SHZ.CMG6T.1_100.2000',
 'RESP')

Sensitivity 2000 V/m/s:

In [ ]:
response_cmg6t=nrl.sensors['Guralp']['CMG-6T']['1s - 100Hz']['2000']
response_cmg6t
Out[ ]:
('CMG-6T, 1s-100Hz, 2000 V/m/s',
 'https://ds.iris.edu/NRL/sensors/guralp/RESP.XX.NS070..SHZ.CMG6T.1_100.2000',
 'RESP')

For the datalogger response we use a Guralp DM-24 Mk3 Fixed Gain (gain 1, 1000 sps, tap id 1, 1000 500 250 125 25 and 5 Hz):

In [ ]:
response_guralp=nrl.dataloggers['Guralp']['CMG-DM24']['Mk3']['Fixed']['1-10']['1']['1000']
response_guralp
Out[ ]:
('DM-24 Mk3 Fixed Gain, gain 1, 1000 sps, tap id 1, (1000 500 250 125 25 and 5 Hz)',
 'http://ds.iris.edu/NRL/dataloggers/guralp/CMG_DM24/mk3/fixed/RESP.XX.G0143..HHZ.CMG_DM24_MK3_FIX.1..1000')

4.3 Building a Response object from the sensor and datalogger responses¶

With the sensor and datalogger responses we can build a Response object for the simulation. It is similar to the Inventory metadata, but contains only the instrument response (Response is part of Inventory).

In [ ]:
respon_instrumen = nrl.get_response(
    sensor_keys=['Guralp','CMG-6T','1s - 100Hz','2000'],
    datalogger_keys=['Guralp','CMG-DM24','Mk3','Fixed','1-10','1','1000'])
respon_instrumen
Out[ ]:
Channel Response
	From M/S (Velocity in Meters per Second) to COUNTS (Digital Counts)
	Overall Sensitivity: 6.24981e+08 defined at 5.000 Hz
	9 stages:
		Stage 1: PolesZerosResponseStage from M/S to V, gain: 2000
		Stage 2: ResponseStage from V to V, gain: 1
		Stage 3: CoefficientsTypeResponseStage from V to COUNTS, gain: 312500
		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
		Stage 8: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1
		Stage 9: CoefficientsTypeResponseStage from COUNTS to COUNTS, gain: 1
In [ ]:
respon_instrumen.plot(min_freq=0.01)
No handles with labels found to put in legend.
No description has been provided for this image
Out[ ]:
No description has been provided for this image

4.4 Running the simulation¶

obspy has no function yet to convert a Response into the PAZ dictionary that simulate needs, so we convert it semi-manually:

In [ ]:
respon_instrumen_paz=respon_instrumen.get_paz().__dict__
respon_instrumen_paz
Out[ ]:
{'_normalization_frequency': 5.0,
 '_poles': [(-4.4422+4.4422j),
  (-4.4422-4.4422j),
  (-391.96+850.69j),
  (-391.96-850.69j),
  (-471.24+0j),
  (-2199.1+0j)],
 '_pz_transfer_function_type': 'LAPLACE (RADIANS/SECOND)',
 '_zeros': [0j, 0j],
 'decimation_correction': None,
 'decimation_delay': None,
 'decimation_factor': None,
 'decimation_input_sample_rate': None,
 'decimation_offset': None,
 'description': None,
 'input_units': 'M/S',
 'input_units_description': 'Velocity in Meters per Second',
 'name': None,
 'normalization_factor': 911329000000.0,
 'output_units': 'V',
 'output_units_description': 'Volts',
 'resource_id': None,
 'resource_id2': None,
 'stage_gain': 2000.0,
 'stage_gain_frequency': 5.0,
 'stage_sequence_number': 1}

A few keys need to be adapted to what simulate expects:

In [ ]:
respon_instrumen_paz['poles'] = respon_instrumen_paz['_poles']
respon_instrumen_paz['zeros'] = respon_instrumen_paz['_zeros']
respon_instrumen_paz['gain'] = respon_instrumen_paz['normalization_factor']
respon_instrumen_paz['sensitivity'] = respon_instrumen.instrument_sensitivity.value #overall sensitivity
respon_instrumen_paz
Out[ ]:
{'_normalization_frequency': 5.0,
 '_poles': [(-4.4422+4.4422j),
  (-4.4422-4.4422j),
  (-391.96+850.69j),
  (-391.96-850.69j),
  (-471.24+0j),
  (-2199.1+0j)],
 '_pz_transfer_function_type': 'LAPLACE (RADIANS/SECOND)',
 '_zeros': [0j, 0j],
 'decimation_correction': None,
 'decimation_delay': None,
 'decimation_factor': None,
 'decimation_input_sample_rate': None,
 'decimation_offset': None,
 'description': None,
 'gain': 911329000000.0,
 'input_units': 'M/S',
 'input_units_description': 'Velocity in Meters per Second',
 'name': None,
 'normalization_factor': 911329000000.0,
 'output_units': 'V',
 'output_units_description': 'Volts',
 'poles': [(-4.4422+4.4422j),
  (-4.4422-4.4422j),
  (-391.96+850.69j),
  (-391.96-850.69j),
  (-471.24+0j),
  (-2199.1+0j)],
 'resource_id': None,
 'resource_id2': None,
 'sensitivity': 624981223.3355017,
 'stage_gain': 2000.0,
 'stage_gain_frequency': 5.0,
 'stage_sequence_number': 1,
 'zeros': [0j, 0j]}

Running the simulation:

In [ ]:
st_vel_cmg6t = st_vel.copy()
st_vel_cmg6t.simulate(paz_simulate=respon_instrumen_paz)
st_vel_cmg6t.plot()
No description has been provided for this image
Out[ ]:
No description has been provided for this image

Plot of the true ground motion (velocity) from the ASJR accelerometer:

In [ ]:
st_vel.plot()
No description has been provided for this image
Out[ ]:
No description has been provided for this image

5 Exercises¶

5.1 Read the seismic data of station BLJR¶

In [ ]:
from obspy import read

st=read('')
st+=read('')
st+=read('')
print(st)
3 Trace(s) in Stream:
IA.BLJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.BLJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.BLJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples

5.2 Read the metadata of station BLJR¶

In [ ]:
from obspy import read_inventory
meta = read_inventory("")
print(meta)
Inventory created at 2022-07-15T13:25:33.662082Z
	Sending institution: scxml import (ObsPy Inventory)
	Contains:
		Networks (1):
			IA
		Stations (1):
			IA.BLJR (REIS Bayah)
		Channels (3):
			IA.BLJR.00.HNZ, IA.BLJR.00.HNN, IA.BLJR.00.HNE

5.3 Apply the instrument correction to get acceleration¶

In [ ]:
st_acc = st.copy()
st_acc.remove_response(#isikan disini)
Out[ ]:
3 Trace(s) in Stream:
IA.BLJR.00.HNZ | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.BLJR.00.HNN | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
IA.BLJR.00.HNE | 2021-03-21T05:56:43.000000Z - 2021-03-21T06:31:43.000000Z | 100.0 Hz, 210001 samples
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [ ]: