FDSN Guide

Version 2.4 by robert on 2025/03/24 10:30

How to Install ObsPy

Seed-Vault

Connecting to an FDSN Server

How to connect to AusPass with & without authenticated access

import obspy
from obspy.clients.fdsn import Client

# Initialize FDSN client for AusPass

# For open access data, no username or password is required.
client = Client('AUSPASS')

# To access restricted data, supply your username and password
# Replace 'Z1' and '12345' with your actual credentials
client = Client('AUSPASS', user='Z1', password='12345')

Station Metadata

Information such as site locations, sensor and data logger types, response information, etc are in the station metadata. This can be accessed directly(link) or via the obspy get_stations (link) tool.

How to download event, station, instrument response

import obspy
from obspy.clients.fdsn import Client

# Use AusPass client for station, waveform, and earthquake information
client = Client("AUSPASS")


# Download station information for AUMTC station in S1 network at the response level
inv = client.get_stations(network="S1", station="AUMTC", location="*",
                           channel="*", starttime=event_time - 60,
                           endtime=event_time + 1000, level="response")
print(inv)

# Inventory metadata is stored in a Inventory > Network > Station > Channel hierarchy

print(inv) #inventory level

print(inv[0]) # network level (the first network in the inventory)

print(inv[0][0]) # station level (the first station of the first network in the inventory)

print(inv[0][0][0]) # channel level (the first channel of the first station of the first network in the inventoy)

# you can also select items directly

print(inv.select(station='AUMTC',channel='HHZ')[0][0][0])

# instrument response is attached to a channel object

response = inv.select(station='AUMTC',channel='HHZ')[0][0][0].response

Sub-sub paragraph

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Waveform Data

Waveform data (e.g. the actual seismic data) can be accessed directly (link) or via obspy's get_waveforms (link) tool. It can also be accessed via various tools such as seed-vault, pyweed, etc (add links).

How to download waveform data

from obspy import UTCDateTime
from obspy.clients.fdsn import Client

# Initialize the FDSN client (you can also specify other data centers)
client = Client("AUSPASS")

# Event information
network = "S1"
station = "AUGRF"
starttime = UTCDateTime("2021-09-21T23:15:53")  # The time of the earthquake
endtime = starttime + 360  # One hour of data after the earthquake

# Download the MiniSEED data
st = client.get_waveforms(network=network, station=station, location="*", channel="BHZ",
                        starttime=starttime, endtime=endtime)
# Save the stream to a MiniSEED file
st.write("Woodspoint_2021.mseed", format="MSEED")
print("Downloaded and saved the MiniSEED file.")

How to remove instrument response

from obspy import read
from obspy.core.util import AttribDict

# Load the MiniSEED file
st = read("Woodspoint_2021.mseed")

# Download the instrument response
inv = client.get_stations(network=network, station=station, location="*",
                          channel="*", starttime=starttime, endtime=endtime,
                          level="response")
                        
# Remove the instrument response
output = 'VEL'  # Output unit ('VEL' = velocity (default), 'DISP' = displacement, 'ACC' = acceleration)

for tr in st:
    tr.remove_response(inventory=inv, output=output, plot=True)

# Save the corrected MiniSEED file
st.write("Woodspoint_2021_corrected.mseed", format="MSEED")

How to apply a bandpass filter

from obspy import read

# Load the MiniSEED file
st = read("Woodspoint_2021.mseed")

# Define the frequency band
freq_min = 0.1  # Minimum frequency in Hz
freq_max = 1.0  # Maximum frequency in Hz

# Apply the bandpass filter
for tr in st:
    tr.filter(type='bandpass', freqmin=freq_min, freqmax=freq_max)

# Save the filtered MiniSEED file
st.write("Woodspoint_2021_filtered.mseed", format="MSEED")

How to slice a waveform

from obspy import read, UTCDateTime, Stream  # Importing Stream here

# Load the filtered MiniSEED file
st = read("Woodspoint_2021_filtered.mseed")

# Define the time window for slicing
slice_start = UTCDateTime("2021-09-21T23:20:00")
slice_end = slice_start +10

# Slice the waveform for each Trace in the Stream
sliced_st = Stream()  # Now Stream is defined
for tr in st:
    sliced_tr = tr.slice(starttime=slice_start, endtime=slice_end)
    sliced_st.append(sliced_tr)

# Save the sliced MiniSEED file
sliced_st.write("Woodspoint_2021_filtered_sliced.mseed", format="MSEED")

How to save a waveform

# Save the sliced file as MiniSEED
sliced_st.write("Woodspoint_2021_filtered_sliced.mseed", format="MSEED")

# Or, save the sliced SAC file
sliced_st.write("Woodspoint_2021_filtered_sliced.sac", format="SAC")

How to convert miniseed to sac

from obspy import read

# Read the MiniSEED file
st = read("Woodspoint_2021.mseed")

# Take the first Trace from the Stream
tr = st[0]

# Save that Trace as a SAC file
tr.write("Woodspoint_2021.sac", format="SAC")

Earthquake Data

How to download an Earthquake Catalog

from obspy.clients.fdsn import Client
from obspy import UTCDateTime

# Initialize the AusPass FDSN client
client = Client("AUSPASS")

# Define the time range for the earthquake catalog
start_time = UTCDateTime("2021-08-01")
end_time = UTCDateTime("2022-01-01")  # End of year

# Define the geographic region (latitude and longitude for Woodspoint, Victoria, Australia)
latitude = -37.47
longitude = 146.10
max_radius = 5  # in degrees

# Download the earthquake catalog
catalog = client.get_events(starttime=start_time, endtime=end_time,
                            minmagnitude=2, latitude=latitude, longitude=longitude,
                            maxradius=max_radius)

# Save the catalog to a file (e.g., QuakeML format)
catalog.write("Woodspoint_earthquakes.xml", format="QUAKEML")

How to plot (Global) Earthquakes

from obspy import UTCDateTime
from obspy.clients.fdsn import Client

# Initialize FDSN client to connect to the IRIS data center
client = Client("IRIS")

# Set the time range for fetching earthquake data
# Start time: January 1, 2023
# End time: Current time
starttime = UTCDateTime("2023-01-01")
endtime = UTCDateTime()

# Fetch earthquake events with a minimum magnitude of 7
catalog = client.get_events(starttime=starttime, endtime=endtime, minmagnitude=7)
#client.get_events(). This function returns a Catalog object that contains a list of Event objects. 
#Each Event object, in turn, has an Origins attribute that contains the depth information

# Plot the fetched earthquake data using an orthographic projection
catalog.plot(projection="ortho", title="Global Earthquakes with Magnitude >= 7 since 2023")
#catalog.plot(), ObsPy automatically uses the depth information to color the events in the plot

How to plot (Local) Earthquakes

from obspy import UTCDateTime
from obspy.clients.fdsn import Client

# Initialize FDSN client
client = Client("AUSPASS")

# Define time range
starttime = UTCDateTime("2023-01-01")
endtime = UTCDateTime()

# Latitude and longitude bounds for Australia
minlatitude = -44.0
maxlatitude = -10.0
minlongitude = 113.0
maxlongitude = 154.0

# Fetch event data for Australia with a minimum magnitude 
catalog = client.get_events(starttime=starttime, endtime=endtime, minmagnitude=4,
                            minlatitude=minlatitude, maxlatitude=maxlatitude,
                            minlongitude=minlongitude, maxlongitude=maxlongitude)

# Plot the earthquakes
catalog.plot(projection="local", title="Australia Earthquakes", resolution="i")