obspy.core.inventory.inventory.Inventory.remove

Inventory.remove(network='*', station='*', location='*', channel='*', keep_empty=False)[source]

Return a copy of the inventory with selected elements removed.

Returns the Inventory object but excluding the Networks / Stations / Channels that match the given criteria (e.g. remove all EHZ channels with channel="EHZ").

Warning

The returned object is based on a shallow copy of the original object. That means that modifying any mutable child elements will also modify the original object (see https://docs.python.org/3/library/copy.html). Use copy() afterwards to make a new copy of the data in memory.

Example

>>> from obspy import read_inventory, UTCDateTime
>>> inv = read_inventory()
>>> inv_new = inv.remove(network='BW')
>>> print(inv_new)  
Inventory created at 2014-03-03T11:07:06.198000Z
    Created by: fdsn-stationxml-converter/1.0.0
            http://www.iris.edu/fdsnstationconverter
    Sending institution: Erdbebendienst Bayern
    Contains:
        Networks (1):
            GR
        Stations (2):
            GR.FUR (Fuerstenfeldbruck, Bavaria, GR-Net)
            GR.WET (Wettzell, Bavaria, GR-Net)
        Channels (21):
            GR.FUR..BHZ, GR.FUR..BHN, GR.FUR..BHE, GR.FUR..HHZ,
            GR.FUR..HHN, GR.FUR..HHE, GR.FUR..LHZ, GR.FUR..LHN,
            GR.FUR..LHE, GR.FUR..VHZ, GR.FUR..VHN, GR.FUR..VHE,
            GR.WET..BHZ, GR.WET..BHN, GR.WET..BHE, GR.WET..HHZ,
            GR.WET..HHN, GR.WET..HHE, GR.WET..LHZ, GR.WET..LHN,
            GR.WET..LHE
>>> inv_new = inv.remove(network='BW', channel="[EH]*")
>>> print(inv_new)  
Inventory created at 2014-03-03T11:07:06.198000Z
    Created by: fdsn-stationxml-converter/1.0.0
            http://www.iris.edu/fdsnstationconverter
    Sending institution: Erdbebendienst Bayern
    Contains:
        Networks (1):
            GR
        Stations (2):
            GR.FUR (Fuerstenfeldbruck, Bavaria, GR-Net)
            GR.WET (Wettzell, Bavaria, GR-Net)
        Channels (21):
            GR.FUR..BHZ, GR.FUR..BHN, GR.FUR..BHE, GR.FUR..HHZ,
            GR.FUR..HHN, GR.FUR..HHE, GR.FUR..LHZ, GR.FUR..LHN,
            GR.FUR..LHE, GR.FUR..VHZ, GR.FUR..VHN, GR.FUR..VHE,
            GR.WET..BHZ, GR.WET..BHN, GR.WET..BHE, GR.WET..HHZ,
            GR.WET..HHN, GR.WET..HHE, GR.WET..LHZ, GR.WET..LHN,
            GR.WET..LHE
>>> inv_new = inv.remove(network='BW', channel="[EH]*",
...                      keep_empty=True)
>>> print(inv_new)  
Inventory created at 2014-03-03T11:07:06.198000Z
    Created by: fdsn-stationxml-converter/1.0.0
            http://www.iris.edu/fdsnstationconverter
    Sending institution: Erdbebendienst Bayern
    Contains:
        Networks (2):
            BW, GR
        Stations (5):
            BW.RJOB (Jochberg, Bavaria, BW-Net) (3x)
            GR.FUR (Fuerstenfeldbruck, Bavaria, GR-Net)
            GR.WET (Wettzell, Bavaria, GR-Net)
        Channels (21):
            GR.FUR..BHZ, GR.FUR..BHN, GR.FUR..BHE, GR.FUR..HHZ,
            GR.FUR..HHN, GR.FUR..HHE, GR.FUR..LHZ, GR.FUR..LHN,
            GR.FUR..LHE, GR.FUR..VHZ, GR.FUR..VHN, GR.FUR..VHE,
            GR.WET..BHZ, GR.WET..BHN, GR.WET..BHE, GR.WET..HHZ,
            GR.WET..HHN, GR.WET..HHE, GR.WET..LHZ, GR.WET..LHN,
            GR.WET..LHE

The network, station, location and channel selection criteria may also contain UNIX style wildcards (e.g. *, ?, …; see fnmatch()).

Parameters:
  • network (str) – Potentially wildcarded network code. If not specified, then all network codes will be matched for removal (combined with other options).

  • station (str) – Potentially wildcarded station code. If not specified, then all station codes will be matched for removal (combined with other options).

  • location (str) – Potentially wildcarded location code. If not specified, then all location codes will be matched for removal (combined with other options).

  • channel (str) – Potentially wildcarded channel code. If not specified, then all channel codes will be matched for removal (combined with other options).

  • keep_empty (bool) – If set to True, networks/stations that are left without child elements (stations/channels) will still be included in the result.