Category: PALNews (page 8 of 9)

News related to the PAL

Python script to plot an epicentral distance on a map

In GEOPHYS310, we learn python. One of the exercises is to plot a station (circle) on a map, with a circle representing some epicentral distance to an earthquake:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

proj = ccrs.PlateCarree(central_<wbr>longitude=180)

ax1 = plt.subplot(111, projection=proj)
ax1.set_extent([-50, 50, -40, 40], crs=proj)
ax1.stock_img()

ax1.tissot(rad_km=3200, lons=180, lats=10, alpha=0.3)
ax1.plot(0,10,'rv') # note the longitude is now with respect to the central_longitude, but NOT for the tissot circle! 

plt.show()

A python script to estimate the epicentral distance and origin time of an earthquake

In GEOPHYS330, we do a ray tracing exercise. Here is some code to perform the task of estimating the origin time and the epicentral distance of an earthquake:

from obspy import UTCDateTime
import numpy as np
import matplotlib.pyplot as plt
from obspy import read
from obspy.taup import TauPyModel

def main():
    # estimate the epicentral distance. This is one of your free parameters:
    Delta = 35 # in degrees
    # estimate the origin time of the earthquake; your other free parameter:
    t0=UTCDateTime("2014-04-13T12:25:19")

    maxamp = readandplotseismogram("https://pal.auckland.ac.nz/files/2014/08/quake.sac_.gz")
    computeandplottts(Delta,t0,maxamp)

    # tighten up the axes, and show:
    plt.axis('tight')
    plt.show()
    #return

def readandplotseismogram(seismogram):
    '''read and plot the seismogram'''
    # read the stream
    st = read(seismogram)
    starttime = UTCDateTime("2014-04-13T12:38:00")
    st.trim(starttime,starttime+1000)
    # the trace in the stream is
    tr = st[0]
    # Make a time array and an amps array:
    t1= tr.stats.starttime.timestamp
    t2= tr.stats.endtime.timestamp
    npts = tr.stats.npts
    times = np.linspace(t1,t2,npts)
    amps = tr.data
    maxamp = max(amps)
    #Plot the seismogram against a grid
    plt.figure(figsize=(12,3))
    plt.plot(times,amps,color='blue')
    #Converting tick marks to actual times:
    locs, labels = plt.xticks()
    new_label=[]
    for loc in locs:
        new_label.append(UTCDateTime(loc).strftime("%H-%M-%S"))
        plt.xticks(locs,new_label,rotation=10)
        plt.xlabel('Time (HH-MM-SS UTC)')
        plt.ylabel('Displacement')
        plt.grid()
    return maxamp

def computeandplottts(Delta,t0,maxamp):
    # compute arrival times based on a epicentral distance (and depth, but
    # I fixed depth to a constant value):
    model = TauPyModel(model="iasp91")      
    arrivals = model.get_travel_times(distance_in_degree=Delta,source_depth_in_km=10)
    #Construct vertical lines to show arrival times of predicted seismic waves
    for arrival in arrivals:
        dummy = t0+ arrival.time
        if arrival.name == "P":
            plt.vlines(dummy,-maxamp/2,maxamp/2)
            plt.text(dummy,maxamp/2+0.05*maxamp,arrival.name)
        if arrival.name == "PP":
            plt.vlines(dummy,-maxamp/2,maxamp/2)
            plt.text(dummy,maxamp/2+0.05*maxamp,arrival.name)
        if arrival.name == "S":
            plt.vlines(dummy,-maxamp/2,maxamp/2)
            plt.text(dummy,maxamp/2+0.05*maxamp,arrival.name)
        if arrival.name == "SS":
            plt.vlines(dummy,-maxamp/2,maxamp/2)
            plt.text(dummy,maxamp/2+0.05*maxamp,arrival.name)
    return()

# this will actually run the code if called stand-alone:
if __name__ == '__main__':
    main()

An implementation of raytracing software Taup in obspy

In one of our labs for GEOPHYS330, we use the ray tracing software TauP. Below is an example of how to use TauP from within python (using obspy), our computer language of choice for the lab, course, and department:

from obspy.taup.tau import plot_ray_paths
plot_ray_paths(source_depth=100,phase_list=['P'],npoints=25)

python script to plot and analyse sea level data from the Auckland harbour

In GEOPHYS330, we use python to download, plot and do a regression on a hundred years of sea level measurements in the Auckland harbour:

# these are the modules that contain functions we will use in the script:
import csv # this is to read a "comma separate values" file 
from urllib.request import urlopen # to read csv data from a website
import matplotlib.pyplot as plt # plotting functions
import numpy as np # numerical tools
from scipy.stats import linregress # linear regression function
import pandas as pd

# you can find and load the sea level data for Auckland here:
url="http://www.psmsl.org/data/obtaining/rlr.monthly.data/150.rlrdata"
df = pd.read_csv(url,delimiter=';')

# "bad" values are defined by a large negative number, so we only
# accept positive values:
df = df[df.iloc[:,1] >= 0]

# convert the pandas dataframe to numpy matrix:
npdat =df.as_matrix()
time= npdat[:,0]
height = npdat[:,1]

slope, intercept, r_value, p_value, std_err = linregress(time,height)
print("r-squared: %f", r_value**2)

# plot the sea height data:
plt.plot(time,height,'ro')
plt.plot(time,intercept+slope*time,'k')
plt.grid()
plt.xlabel('Date (year)')
plt.ylabel('Sea height (mm)')
plt.title('Sea height at Princes Wharf, Auckland (New Zealand)')
plt.legend(['measurements','best linear fit'],loc=4)
plt.axis('tight')
#plt.savefig('sealevel_auckland.png')
plt.show()

A spiffy new home for station AUCK

As of today, station AUCK is in the basement of the Science Centre, City Campus of the University of Auckland. With its design, the SeisNZ project will be able to reach out to students, visitors, or any other interested parties.This station is part of a growing network of educational seismometers around the country. From now on, you will be able to hunt for earthquake signals in AUCK data from the latest NZ earthquakes and beyond.

 

Leighton is famous (on the North Shore, at least)

One of our PALs — Leighton Watson — is featured in the North Shore Times, showing this is not just some door-to-door rag, but a bastion of high-quality journalism, tailoring to the well-educated. When he wraps up his Honours project, he’ll be famous among rock physicists as well….. In any case, congrats to Leighton and we wish him all the best next year at Stanford!

Screenshot from 2014-05-20 15:26:57

Just in case: Leighton Watson is the one on the left.

A deep earthquake on the eastern margin of the Australian plate

Yesterday, we recorded seismic waves on our station AUCK from an Earthquake roughly 11 degrees to our North. This event is characterized by a strong P- and S-wave arrival as you can see in this figure:

fiji65_AUCKdata

Given the usual limitations of our (vertical) sensor when it comes to S-wave recordings, this is indicative of a very deep earthquake. The USGS estimates that this earthquake happened at a depth of 460 km. Now, under most places on Earth the rocks at those depths are too ductile to support the brittle breaking necessary for an earthquake, but in this case, the earthquake happened in — or on the boundary of — the brittle Pacific Plate subducted under the Australian Plate. Note that the epicentre of this event is about 500 km from the surface expression of the boundary between these plates. From the depth of the event and the offset to the plate boundary at the surface, we can estimate the angle of subduction may be around 45 degrees.

FIJI65_2014epicentre

The P- and S-wave markers are based on the average wave speed in the earth. In this case, they are a bit earlier than expected, because the subsurface between earthquake and the AUCK recording station is slower than average. As discussed previously, this is indicative of a young, warmer (and thus slower) lithosphere.

Furthermore, such deep earthquakes cause relatively little surface wave energy. The signal after the S-waves is likely a guided wave in the Pacific plate called a “leaky mode.” If you want to learn more about leaky modes in the Kermadecs, you should read this paper.

Our computing environment

As 21st century researchers, we have access to a tremendous amount of software to practice our trade. In fact, it seems every day new software appears (and some old favourites go out of style, or cease to be supported).  Below is a list of my personal favourites. The common thread here is that these are all open-source software. The reason for this is that open-source software is community supported (and often community-built). There is no messing around with the license files,  there are no black-box results (you have the source code) and even if your institution could afford the commercial programme, maybe your collaborators cannot. Or you can’t run it on your computer at home. By the way, while I shortly will advocate for the linux computer operating system, the software we list is all platform independent.

  • Our operating system of choice is linux. While there is still a bit of a learning curve, installing and learning linux these days is easy. Certainly easier than it was! As is maintenance and upgrading with tools such as apt-get and dnf. There are many flavours of linux, and the differences are really not that great. Within linux, emacs is my personal favorite text editor, but there are plenty of other good ones. Gone are the days of straight-up vi!
  • Our computer programs are in python, using scipy and numpy. Python is growing so fast that every time I look, there is another new part to python that makes the life of a researcher easier. Processing seismic data was done in SAC or Seismic Unix, but now there is obspy. Making maps without the commercial GIS software required Generic Mapping Tools, but now python with matplotlib, basemap and cartopy ensure vectorised figures and maps. In experiments, we control the hardware in our lab with python. Commercial options such as Labview and matlab are simply obsolete.
  • Document processing is done in LaTeX. You can spot a LaTeX document from a mile away by its beautiful layout, fonts, figures, and maybe most importantly: its equations. Figure labels, section headings, equation numbers are all dynamically linked, making editing a breeze. With only a few lines difference, you can turn a paper into a presentation or a poster, too. Libreoffice, which used to be openoffice, is not bad, but often does not map one-to-one between commercial versions of Word.
  • We draw in inkscape. I love all the vectorized plotting options, and LaTeX implementations with pdf outputs. Wow! Even an awful drawer like me can make something look decent.
  • We tinker with arduino. Projects on school seismometers and a so-called bat-hat for a local museum rely on the wonderful open-hardware that is arduino. We foresee arduinos taking over simple lab tasks in the near future.

Our "seismometers in schools" project received SEG support and is in the news

One of our favourite projects in the Physical Acoustics Lab involves outreach and education in seismology with the TC1 seismometer. This week has been a good week, as we were informed that the Foundation of the Society of Exploration Geophysicists (SEG) will support the instrumentation of a number of NZ schools with seismometers. In addition, Ian Randall wrote a wonderful article on the topic in Physics World.

M6.3 earthquake, 15 km east of Eketahuna

greatcircle

 
In the Science Centre of the City Campus of the University of Auckland we record seismic waves with the TC1 seismometer. Routinely, our station AUCK records seismic waves from earthquakes in New Zealand and beyond. On January 20th, 2014, an earthquake occurred on the South side of the North Island, 15 km east of Ekatahuna. Here is a map of the epicentre, our station location, and the great-circle path between them.

 

 

2014-01-20-02-52-44

On the left you can see 10 minutes of recordings, starting at the origin time of this earthquake. The green marker annotated with a Pn is the predicted arrival of the first wave traveling 4 degrees from the epicentre, 15 km east of Eketahuna, to Auckland. This prediction is based on a spherically symmetric model of the Earth, by Brian Kennett, and certainly seems to mark the start of minutes of vibrations in Auckland from this earthquake. In fact, if you look carefully you see that the wiggles after 10 minutes are still larger than before the first wave from this earthquake arrived. Larger earthquakes can make the Earth “ring” for many hours.

2014-01-20-02-52-44_zoom
In the image on the right, we zoomed in on the first-arriving wave, almost exactly one minute after the earthquake originated. Now, you can see that the prediction is actually a few seconds before the arrival. This means the lithosphere under the North Island of New Zealand is a bit slower (~3% on this path) than the average on Earth. In general, a hotter lithosphere is slower than a cold one. This makes seismic waves traversing old, cold, continents relatively fast, and those sampling younger lithosphere like ours in New Zealand, relatively slow.

In general, it is these small travel time differences that provide images of the (deep) earth through a process called seismic tomography.