Raw waveforms stored in hdf5 format#

If you saved your raw wavforms hdf5 format, you can use the RawDataBase class to access and manipulate your database.

As a user, you will only ever be calling the RawataBase class. The only function of this class is to return a DBHandler, which hold all the “useful” functions. To call RawDataBase, use a context manager like so:

>>> from pyglimer.database.raw import RawDataBase
>>> with RawDataBase('/path/to/myfile.h5') as rdb:
>>>     type(rdb)  # This is a DBHandler
<class 'pyglimer.database.raw.DBHandler'>

Warning

Do not call DBHandler directly! This might lead to unexpected behaviour or even dataloss due to corrupted hdf5 files.

Warning

If you should for some reason decide to not use the context manager, you will have to close the hdf5 file with _close() to avoid corrupting your files!

DBHandler has the following public methods:

  • add_waveform() to add waveforms to the database

  • add_response() to add stations response data to the database

  • get_data() to read data from this file

  • get_response() to get the station inventory of the associated station

  • walk() to iterate over all waveforms in a subset defined by the provided arguments

Reading data#

You can access downloaded waveform data using the get_data() method:

>>> from pyglimer.database.raw import RawDataBase
>>> with RawDataBase('/path/to/myfile.h5') as rdb:
>>>     st = rdb.get_data(
>>>         network='IU', station='*', evt_id='*', tag='raw')
>>>     # st is an ObsPy Stream object
>>>     inv = rdb.get_response(network='IU', station='HRV')
>>>     # inv is an ObsPy inventory object.

As you can see, we use seed station codes to identify data. All arguments accept wildcards. Each waveform is associated to an event identified by its origin time (evt_id='*', this can be a UTCDateTime).

See also

To iterate over raw waveforms use walk().

Tags#

PyGLImER uses tags to identify your data. You could for example use different tags for differently processed data. raw is the standard tag for raw waveform data.

Writing data to hdf5#

If you postprocess your receiver functions (e.g., stacking), you might want to save the data afterwards. You can do that like below:

1from pyglimer.database.raw import RawDataBase
2
3# Suppose you have a obspy Stream or Trace object st
4# event is an obspy Event that st is associated to
5
6with RawDataBase('/path/to/myfile.h5') as rdb:
7    rfst = rdb.add_data(
8        st, event.preferred_origin().time)

See also

DBHandler (raw data specific) handles very similarly to DBHandler (receiver function specific).