SSBW - Python Tutorial 4: Introduction to ObsPy

Mike Brudzinski, Miami University-Oxford
Author Profile
Initial Publication Date: August 18, 2021


In this interactive tutorial built for a learning management system, students 1) practice using the basic syntax of Python commands, 2) use the functionality of the ObsPy library to load, plot, and analyze data or metadata 3) use the ObsPy library to create stream objects for seismograms, catalog objects for earthquake lists, and inventory objects for metadata, 4) use the UTCDateTime function to convert between different date and time formats, and 5) evaluate a mainshock-aftershock sequence in Chile.

Used this activity? Share your experiences and modifications



The IRIS Seismology Skill Building Workshop (SSBW), which is a free, online, open-access, large-enrollment, 12-week summer workshop for upper level undergraduates.

Skills and concepts that students must have mastered

This assignment builds on prior experience using basic Python command syntax and variables, the seismological syntax of network, station, channel, and location codes for specifying a given recording, and the ability to retrieve relevant information about programming and seismology from internet research or help pages.

How the activity is situated in the course

This is assignment number 28 of 35 in the Seismology Skill Building Workshop (SSBW).


Content/concepts goals for this activity

Proficiency with Python, ObsPy, object structures, conversion between different date and time formats.

Higher order thinking skills goals for this activity

Retrieving relevant information from digital sources to accomplish tasks, using correct programming syntax, evaluating and describing computing output in the context of science concepts.

Other skills goals for this activity

Description and Teaching Materials

Students will:
1. Load the ObsPy library in the Python command line environment 
2. Use the UTCDateTime to convert between date and time formats, including epoch time 
3. Use attributes of a variable to retrieve information like day of the week 
4. Use ObsPy to read in a 12 hour-long seismogram from April 17, 2012 during which multiple triggered earthquakes occurred 
5. Plot, trim, and filter the seismogram using ObsPy stream object functions 
6. Use the dayplot option to show a traditional "drum plot" with cataloged earthquake times 
7. Use both the ObsPy Client and read_event functions to input a catalog of earthquakes 
8. Plot a map of earthquakes using ObsPy catalog object functions 
9. Use Client functions to input a set of station metadata 
10. Plot a map of stations using ObsPy inventory object functions 
11. Use Client functions to input seismogram data using metadata descriptors


Teaching Notes and Tips

This assignment was constructed in the Moodle learning management system, and has been exported in the GIFT format. More information about the syntax of this format can be found here:


This assignment is automatically graded by the learning management system. The number of questions of each type used are:
22 multiple choice questions
4 multiple answer question
8 numeric questions (output values, quantifying output, unit conversion)
1 short answer (auto-graded) question
2 free response (all accepted) question

References and Resources

During the Seismology Skill Building Workshop, students are provided with a virtual Linux machine that was tailored to include the software specifically needed to complete the assignments. This software is all freely available on the internet, but interested parties are encouraged to contact the instructor for access to this tailored virtual machine.